From 3275970ab8046022b8d2069b5c21bf117c223db7 Mon Sep 17 00:00:00 2001
From: Veronika Irvine
Date: Fri, 11 May 2001 13:46:50 +0000
Subject: initializing database with SWT 0.105
---
bundles/org.eclipse.swt/.classpath_motif | 0
bundles/org.eclipse.swt/.classpath_win32 | 16 +
bundles/org.eclipse.swt/.cvsignore | 2 +
bundles/org.eclipse.swt/.vcm_meta | 6 +
.../eclipse/swt/internal/awt/win32/SWT_AWT.java | 67 +
.../eclipse/swt/internal/awt/win32/package.html | 13 +
.../org/eclipse/swt/custom/AnimatedProgress.java | 168 +
.../org/eclipse/swt/custom/BusyIndicator.java | 111 +
.../common/org/eclipse/swt/custom/CCombo.java | 950 +++
.../common/org/eclipse/swt/custom/CLabel.java | 462 ++
.../common/org/eclipse/swt/custom/CTabFolder.java | 1535 ++++
.../org/eclipse/swt/custom/CTabFolderAdapter.java | 10 +
.../org/eclipse/swt/custom/CTabFolderEvent.java | 18 +
.../org/eclipse/swt/custom/CTabFolderListener.java | 12 +
.../common/org/eclipse/swt/custom/CTabItem.java | 406 +
.../org/eclipse/swt/custom/ControlEditor.java | 238 +
.../org/eclipse/swt/custom/DefaultContent.java | 797 ++
.../org/eclipse/swt/custom/DefaultLineStyler.java | 599 ++
.../eclipse/swt/custom/ExtendedModifyEvent.java | 24 +
.../eclipse/swt/custom/ExtendedModifyListener.java | 22 +
.../eclipse/swt/custom/LineBackgroundEvent.java | 26 +
.../eclipse/swt/custom/LineBackgroundListener.java | 24 +
.../org/eclipse/swt/custom/LineStyleEvent.java | 25 +
.../org/eclipse/swt/custom/LineStyleListener.java | 21 +
.../common/org/eclipse/swt/custom/PopupList.java | 249 +
.../common/org/eclipse/swt/custom/ST.java | 57 +
.../common/org/eclipse/swt/custom/SashForm.java | 384 +
.../org/eclipse/swt/custom/ScrolledComposite.java | 202 +
.../common/org/eclipse/swt/custom/StackLayout.java | 74 +
.../common/org/eclipse/swt/custom/StyleRange.java | 147 +
.../common/org/eclipse/swt/custom/StyledText.java | 5426 ++++++++++++++
.../org/eclipse/swt/custom/StyledTextContent.java | 177 +
.../org/eclipse/swt/custom/StyledTextEvent.java | 31 +
.../org/eclipse/swt/custom/StyledTextListener.java | 62 +
.../org/eclipse/swt/custom/StyledTextPrinter.java | 344 +
.../common/org/eclipse/swt/custom/TableEditor.java | 179 +
.../common/org/eclipse/swt/custom/TableTree.java | 701 ++
.../org/eclipse/swt/custom/TableTreeEditor.java | 100 +
.../org/eclipse/swt/custom/TableTreeItem.java | 561 ++
.../org/eclipse/swt/custom/TextChangedEvent.java | 41 +
.../eclipse/swt/custom/TextChangedListener.java | 41 +
.../common/org/eclipse/swt/custom/TreeEditor.java | 163 +
.../org/eclipse/swt/custom/VerifyKeyListener.java | 19 +
.../common/org/eclipse/swt/custom/ViewForm.java | 477 ++
.../common/org/eclipse/swt/custom/package.html | 13 +
.../common/org/eclipse/swt/dnd/DND.java | 128 +
.../common/org/eclipse/swt/dnd/DNDEvent.java | 12 +
.../common/org/eclipse/swt/dnd/DNDListener.java | 77 +
.../org/eclipse/swt/dnd/DragSourceAdapter.java | 12 +
.../org/eclipse/swt/dnd/DragSourceEvent.java | 67 +
.../org/eclipse/swt/dnd/DragSourceListener.java | 70 +
.../org/eclipse/swt/dnd/DragUnderEffect.java | 14 +
.../org/eclipse/swt/dnd/DropTargetAdapter.java | 18 +
.../org/eclipse/swt/dnd/DropTargetEvent.java | 98 +
.../org/eclipse/swt/dnd/DropTargetListener.java | 172 +
.../org/eclipse/swt/dnd/NoDragUnderEffect.java | 14 +
.../common/org/eclipse/swt/dnd/package.html | 13 +
.../org/eclipse/swt/dnd/ByteArrayTransfer.java | 48 +
.../motif/org/eclipse/swt/dnd/Clipboard.java | 206 +
.../motif/org/eclipse/swt/dnd/DragSource.java | 460 ++
.../motif/org/eclipse/swt/dnd/DropTarget.java | 540 ++
.../motif/org/eclipse/swt/dnd/FileTransfer.java | 66 +
.../motif/org/eclipse/swt/dnd/RTFTransfer.java | 42 +
.../org/eclipse/swt/dnd/TableDragUnderEffect.java | 63 +
.../motif/org/eclipse/swt/dnd/TextTransfer.java | 42 +
.../motif/org/eclipse/swt/dnd/Transfer.java | 26 +
.../motif/org/eclipse/swt/dnd/TransferData.java | 18 +
.../org/eclipse/swt/dnd/TreeDragUnderEffect.java | 100 +
.../org/eclipse/swt/dnd/ByteArrayTransfer.java | 48 +
.../photon/org/eclipse/swt/dnd/Clipboard.java | 94 +
.../photon/org/eclipse/swt/dnd/DragSource.java | 196 +
.../photon/org/eclipse/swt/dnd/DropTarget.java | 214 +
.../photon/org/eclipse/swt/dnd/FileTransfer.java | 66 +
.../photon/org/eclipse/swt/dnd/RTFTransfer.java | 42 +
.../org/eclipse/swt/dnd/TableDragUnderEffect.java | 63 +
.../photon/org/eclipse/swt/dnd/TextTransfer.java | 42 +
.../photon/org/eclipse/swt/dnd/Transfer.java | 18 +
.../photon/org/eclipse/swt/dnd/TransferData.java | 18 +
.../org/eclipse/swt/dnd/TreeDragUnderEffect.java | 102 +
.../org/eclipse/swt/dnd/ByteArrayTransfer.java | 130 +
.../win32/org/eclipse/swt/dnd/Clipboard.java | 357 +
.../win32/org/eclipse/swt/dnd/DragSource.java | 437 ++
.../win32/org/eclipse/swt/dnd/DropTarget.java | 610 ++
.../win32/org/eclipse/swt/dnd/FileTransfer.java | 136 +
.../org/eclipse/swt/dnd/OleEnumFORMATETC.java | 157 +
.../win32/org/eclipse/swt/dnd/RTFTransfer.java | 81 +
.../org/eclipse/swt/dnd/TableDragUnderEffect.java | 61 +
.../win32/org/eclipse/swt/dnd/TextTransfer.java | 78 +
.../win32/org/eclipse/swt/dnd/Transfer.java | 87 +
.../win32/org/eclipse/swt/dnd/TransferData.java | 50 +
.../org/eclipse/swt/dnd/TreeDragUnderEffect.java | 108 +
.../org/eclipse/swt/internal/ole/win32/CAUUID.java | 14 +
.../org/eclipse/swt/internal/ole/win32/COM.java | 562 ++
.../eclipse/swt/internal/ole/win32/COMObject.java | 1024 +++
.../swt/internal/ole/win32/CONTROLINFO.java | 17 +
.../swt/internal/ole/win32/COSERVERINFO.java | 15 +
.../eclipse/swt/internal/ole/win32/DISPPARAMS.java | 17 +
.../eclipse/swt/internal/ole/win32/DROPFILES.java | 21 +
.../swt/internal/ole/win32/DVTARGETDEVICE.java | 18 +
.../eclipse/swt/internal/ole/win32/EXCEPINFO.java | 21 +
.../eclipse/swt/internal/ole/win32/FORMATETC.java | 17 +
.../eclipse/swt/internal/ole/win32/FUNCDESC1.java | 32 +
.../eclipse/swt/internal/ole/win32/FUNCDESC2.java | 32 +
.../org/eclipse/swt/internal/ole/win32/GUID.java | 23 +
.../swt/internal/ole/win32/IClassFactory2.java | 22 +
.../swt/internal/ole/win32/IConnectionPoint.java | 19 +
.../ole/win32/IConnectionPointContainer.java | 16 +
.../swt/internal/ole/win32/IDataObject.java | 42 +
.../eclipse/swt/internal/ole/win32/IDispatch.java | 61 +
.../org/eclipse/swt/internal/ole/win32/IEnum.java | 25 +
.../swt/internal/ole/win32/IEnumFORMATETC.java | 12 +
.../swt/internal/ole/win32/IEnumSTATSTG.java | 12 +
.../org/eclipse/swt/internal/ole/win32/IFont.java | 19 +
.../eclipse/swt/internal/ole/win32/IMoniker.java | 13 +
.../swt/internal/ole/win32/IOleCommandTarget.java | 35 +
.../swt/internal/ole/win32/IOleControl.java | 16 +
.../ole/win32/IOleInPlaceActiveObject.java | 18 +
.../swt/internal/ole/win32/IOleInPlaceObject.java | 21 +
.../eclipse/swt/internal/ole/win32/IOleLink.java | 19 +
.../eclipse/swt/internal/ole/win32/IOleObject.java | 55 +
.../eclipse/swt/internal/ole/win32/IOleWindow.java | 19 +
.../eclipse/swt/internal/ole/win32/IPersist.java | 16 +
.../swt/internal/ole/win32/IPersistStorage.java | 31 +
.../swt/internal/ole/win32/IProvideClassInfo.java | 16 +
.../swt/internal/ole/win32/IProvideClassInfo2.java | 16 +
.../internal/ole/win32/ISpecifyPropertyPages.java | 16 +
.../eclipse/swt/internal/ole/win32/IStorage.java | 144 +
.../eclipse/swt/internal/ole/win32/IStream.java | 30 +
.../eclipse/swt/internal/ole/win32/ITypeInfo.java | 155 +
.../eclipse/swt/internal/ole/win32/IUnknown.java | 26 +
.../swt/internal/ole/win32/IViewObject2.java | 21 +
.../eclipse/swt/internal/ole/win32/LICINFO.java | 15 +
.../org/eclipse/swt/internal/ole/win32/OLECMD.java | 13 +
.../eclipse/swt/internal/ole/win32/OLECMDTEXT.java | 17 +
.../internal/ole/win32/OLEINPLACEFRAMEINFO.java | 19 +
.../eclipse/swt/internal/ole/win32/STATSTG.java | 39 +
.../eclipse/swt/internal/ole/win32/STGMEDIUM.java | 15 +
.../eclipse/swt/internal/ole/win32/TYPEATTR.java | 50 +
.../eclipse/swt/internal/ole/win32/VARDESC1.java | 26 +
.../eclipse/swt/internal/ole/win32/VARDESC2.java | 26 +
.../eclipse/swt/internal/ole/win32/package.html | 13 +
.../win32/org/eclipse/swt/ole/win32/OLE.java | 420 ++
.../org/eclipse/swt/ole/win32/OleAutomation.java | 588 ++
.../org/eclipse/swt/ole/win32/OleClientSite.java | 1306 ++++
.../org/eclipse/swt/ole/win32/OleControlSite.java | 521 ++
.../win32/org/eclipse/swt/ole/win32/OleEvent.java | 16 +
.../org/eclipse/swt/ole/win32/OleEventSink.java | 269 +
.../org/eclipse/swt/ole/win32/OleEventTable.java | 68 +
.../win32/org/eclipse/swt/ole/win32/OleFile.java | 128 +
.../win32/org/eclipse/swt/ole/win32/OleFrame.java | 626 ++
.../swt/ole/win32/OleFunctionDescription.java | 24 +
.../org/eclipse/swt/ole/win32/OleListener.java | 17 +
.../swt/ole/win32/OleParameterDescription.java | 12 +
.../swt/ole/win32/OlePropertyChangeSink.java | 179 +
.../swt/ole/win32/OlePropertyDescription.java | 16 +
.../win32/org/eclipse/swt/ole/win32/Variant.java | 524 ++
.../win32/org/eclipse/swt/ole/win32/package.html | 13 +
.../org/eclipse/swt/printing/PrinterData.java | 158 +
.../common/org/eclipse/swt/printing/package.html | 13 +
.../org/eclipse/swt/printing/PrintDialog.java | 51 +
.../motif/org/eclipse/swt/printing/Printer.java | 261 +
.../org/eclipse/swt/printing/PrintDialog.java | 254 +
.../win32/org/eclipse/swt/printing/Printer.java | 499 ++
.../common/org/eclipse/swt/program/package.html | 13 +
.../motif/org/eclipse/swt/program/Program.java | 698 ++
.../photon/org/eclipse/swt/program/Program.java | 169 +
.../org/eclipse/swt/program/ProgramSupport.java | 215 +
.../win32/org/eclipse/swt/program/Program.java | 259 +
.../Eclipse SWT/common/library/callback.c | 328 +
.../Eclipse SWT/common/library/callback.h | 49 +
.../Eclipse SWT/common/library/globals.c | 122 +
.../Eclipse SWT/common/library/globals.h | 71 +
.../Eclipse SWT/common/library/library.h | 18 +
.../Eclipse SWT/common/org/eclipse/swt/SWT.java | 1810 +++++
.../common/org/eclipse/swt/SWTError.java | 80 +
.../common/org/eclipse/swt/SWTException.java | 73 +
.../common/org/eclipse/swt/events/ArmEvent.java | 29 +
.../common/org/eclipse/swt/events/ArmListener.java | 32 +
.../org/eclipse/swt/events/ControlAdapter.java | 40 +
.../org/eclipse/swt/events/ControlEvent.java | 31 +
.../org/eclipse/swt/events/ControlListener.java | 42 +
.../org/eclipse/swt/events/DisposeEvent.java | 30 +
.../org/eclipse/swt/events/DisposeListener.java | 33 +
.../org/eclipse/swt/events/FocusAdapter.java | 39 +
.../common/org/eclipse/swt/events/FocusEvent.java | 30 +
.../org/eclipse/swt/events/FocusListener.java | 42 +
.../common/org/eclipse/swt/events/HelpEvent.java | 30 +
.../org/eclipse/swt/events/HelpListener.java | 34 +
.../common/org/eclipse/swt/events/KeyAdapter.java | 39 +
.../common/org/eclipse/swt/events/KeyEvent.java | 48 +
.../common/org/eclipse/swt/events/KeyListener.java | 41 +
.../common/org/eclipse/swt/events/MenuAdapter.java | 39 +
.../common/org/eclipse/swt/events/MenuEvent.java | 30 +
.../org/eclipse/swt/events/MenuListener.java | 40 +
.../common/org/eclipse/swt/events/ModifyEvent.java | 30 +
.../org/eclipse/swt/events/ModifyListener.java | 32 +
.../org/eclipse/swt/events/MouseAdapter.java | 52 +
.../common/org/eclipse/swt/events/MouseEvent.java | 68 +
.../org/eclipse/swt/events/MouseListener.java | 51 +
.../org/eclipse/swt/events/MouseMoveListener.java | 32 +
.../org/eclipse/swt/events/MouseTrackAdapter.java | 53 +
.../org/eclipse/swt/events/MouseTrackListener.java | 53 +
.../common/org/eclipse/swt/events/PaintEvent.java | 76 +
.../org/eclipse/swt/events/PaintListener.java | 33 +
.../org/eclipse/swt/events/SelectionAdapter.java | 39 +
.../org/eclipse/swt/events/SelectionEvent.java | 76 +
.../org/eclipse/swt/events/SelectionListener.java | 50 +
.../org/eclipse/swt/events/ShellAdapter.java | 66 +
.../common/org/eclipse/swt/events/ShellEvent.java | 30 +
.../org/eclipse/swt/events/ShellListener.java | 61 +
.../org/eclipse/swt/events/TraverseEvent.java | 41 +
.../org/eclipse/swt/events/TraverseListener.java | 40 +
.../common/org/eclipse/swt/events/TreeAdapter.java | 39 +
.../common/org/eclipse/swt/events/TreeEvent.java | 30 +
.../org/eclipse/swt/events/TreeListener.java | 41 +
.../common/org/eclipse/swt/events/TypedEvent.java | 56 +
.../common/org/eclipse/swt/events/VerifyEvent.java | 51 +
.../org/eclipse/swt/events/VerifyListener.java | 39 +
.../common/org/eclipse/swt/events/package.html | 22 +
.../common/org/eclipse/swt/graphics/Drawable.java | 45 +
.../common/org/eclipse/swt/graphics/ImageData.java | 3451 +++++++++
.../org/eclipse/swt/graphics/ImageLoader.java | 284 +
.../org/eclipse/swt/graphics/ImageLoaderEvent.java | 78 +
.../eclipse/swt/graphics/ImageLoaderListener.java | 39 +
.../org/eclipse/swt/graphics/PaletteData.java | 205 +
.../common/org/eclipse/swt/graphics/Point.java | 93 +
.../common/org/eclipse/swt/graphics/RGB.java | 108 +
.../common/org/eclipse/swt/graphics/Rectangle.java | 264 +
.../common/org/eclipse/swt/graphics/package.html | 17 +
.../common/org/eclipse/swt/internal/Callback.java | 270 +
.../org/eclipse/swt/internal/image/FileFormat.java | 108 +
.../eclipse/swt/internal/image/GIFFileFormat.java | 522 ++
.../org/eclipse/swt/internal/image/JPEGAppn.java | 24 +
.../image/JPEGArithmeticConditioningTable.java | 17 +
.../eclipse/swt/internal/image/JPEGComment.java | 21 +
.../eclipse/swt/internal/image/JPEGEndOfImage.java | 25 +
.../eclipse/swt/internal/image/JPEGFileFormat.java | 1891 +++++
.../swt/internal/image/JPEGFixedSizeSegment.java | 38 +
.../swt/internal/image/JPEGFrameHeader.java | 203 +
.../swt/internal/image/JPEGHuffmanTable.java | 262 +
.../swt/internal/image/JPEGQuantizationTable.java | 159 +
.../swt/internal/image/JPEGRestartInterval.java | 25 +
.../eclipse/swt/internal/image/JPEGScanHeader.java | 117 +
.../eclipse/swt/internal/image/JPEGSegment.java | 54 +
.../swt/internal/image/JPEGStartOfImage.java | 29 +
.../internal/image/JPEGVariableSizeSegment.java | 32 +
.../swt/internal/image/LEDataInputStream.java | 88 +
.../swt/internal/image/LEDataOutputStream.java | 54 +
.../org/eclipse/swt/internal/image/LZWCodec.java | 479 ++
.../org/eclipse/swt/internal/image/LZWNode.java | 13 +
.../eclipse/swt/internal/image/PNGFileFormat.java | 525 ++
.../org/eclipse/swt/internal/image/PngChunk.java | 333 +
.../eclipse/swt/internal/image/PngChunkReader.java | 64 +
.../swt/internal/image/PngDecodingDataStream.java | 131 +
.../swt/internal/image/PngFileReadState.java | 20 +
.../swt/internal/image/PngHuffmanTable.java | 122 +
.../swt/internal/image/PngHuffmanTables.java | 156 +
.../eclipse/swt/internal/image/PngIdatChunk.java | 36 +
.../eclipse/swt/internal/image/PngIendChunk.java | 39 +
.../eclipse/swt/internal/image/PngIhdrChunk.java | 372 +
.../swt/internal/image/PngLzBlockReader.java | 169 +
.../eclipse/swt/internal/image/PngPlteChunk.java | 87 +
.../eclipse/swt/internal/image/PngTrnsChunk.java | 133 +
.../swt/internal/image/WinBMPFileFormat.java | 667 ++
.../swt/internal/image/WinICOFileFormat.java | 284 +
.../org/eclipse/swt/internal/image/package.html | 18 +
.../common/org/eclipse/swt/internal/package.html | 20 +
.../common/org/eclipse/swt/layout/FillLayout.java | 67 +
.../common/org/eclipse/swt/layout/GridData.java | 157 +
.../common/org/eclipse/swt/layout/GridLayout.java | 638 ++
.../common/org/eclipse/swt/layout/RowData.java | 29 +
.../common/org/eclipse/swt/layout/RowLayout.java | 151 +
.../common/org/eclipse/swt/layout/package.html | 13 +
.../common/org/eclipse/swt/package.html | 15 +
.../common/org/eclipse/swt/widgets/Dialog.java | 207 +
.../common/org/eclipse/swt/widgets/Event.java | 84 +
.../common/org/eclipse/swt/widgets/EventTable.java | 85 +
.../common/org/eclipse/swt/widgets/Item.java | 110 +
.../common/org/eclipse/swt/widgets/Layout.java | 76 +
.../common/org/eclipse/swt/widgets/Listener.java | 45 +
.../org/eclipse/swt/widgets/RunnableLock.java | 32 +
.../org/eclipse/swt/widgets/Synchronizer.java | 140 +
.../org/eclipse/swt/widgets/TypedListener.java | 222 +
.../common/org/eclipse/swt/widgets/package.html | 15 +
.../Eclipse SWT/common/readme_swt.html | 550 ++
.../Eclipse SWT/motif/library/build.csh | 59 +
.../Eclipse SWT/motif/library/gnome.c | 153 +
.../Eclipse SWT/motif/library/kde.cc | 509 ++
.../Eclipse SWT/motif/library/library.c | 32 +
.../Eclipse SWT/motif/library/make_linux.mak | 86 +
.../Eclipse SWT/motif/library/make_solaris.mak | 69 +
.../Eclipse SWT/motif/library/structs.c | 1364 ++++
.../Eclipse SWT/motif/library/structs.h | 459 ++
.../Eclipse SWT/motif/library/swt.c | 7899 ++++++++++++++++++++
.../Eclipse SWT/motif/libswt-gnome0105.so | Bin 0 -> 4713 bytes
.../Eclipse SWT/motif/libswt0105.so | Bin 0 -> 1825715 bytes
.../motif/org/eclipse/swt/graphics/Color.java | 197 +
.../motif/org/eclipse/swt/graphics/Cursor.java | 154 +
.../motif/org/eclipse/swt/graphics/Device.java | 434 ++
.../motif/org/eclipse/swt/graphics/DeviceData.java | 24 +
.../motif/org/eclipse/swt/graphics/Font.java | 164 +
.../motif/org/eclipse/swt/graphics/FontData.java | 321 +
.../org/eclipse/swt/graphics/FontMetrics.java | 47 +
.../motif/org/eclipse/swt/graphics/GC.java | 1367 ++++
.../motif/org/eclipse/swt/graphics/GCData.java | 17 +
.../motif/org/eclipse/swt/graphics/Image.java | 872 +++
.../motif/org/eclipse/swt/graphics/Region.java | 79 +
.../motif/org/eclipse/swt/internal/Converter.java | 71 +
.../org/eclipse/swt/internal/motif/GNOME.java | 18 +
.../motif/org/eclipse/swt/internal/motif/KDE.java | 54 +
.../motif/org/eclipse/swt/internal/motif/OS.java | 1250 ++++
.../org/eclipse/swt/internal/motif/Visual.java | 16 +
.../org/eclipse/swt/internal/motif/XAnyEvent.java | 11 +
.../eclipse/swt/internal/motif/XButtonEvent.java | 12 +
.../eclipse/swt/internal/motif/XCharStruct.java | 16 +
.../org/eclipse/swt/internal/motif/XColor.java | 14 +
.../swt/internal/motif/XConfigureEvent.java | 16 +
.../eclipse/swt/internal/motif/XCrossingEvent.java | 19 +
.../org/eclipse/swt/internal/motif/XEvent.java | 15 +
.../eclipse/swt/internal/motif/XExposeEvent.java | 14 +
.../swt/internal/motif/XFocusChangeEvent.java | 18 +
.../eclipse/swt/internal/motif/XFontStruct.java | 36 +
.../org/eclipse/swt/internal/motif/XGCValues.java | 33 +
.../org/eclipse/swt/internal/motif/XImage.java | 25 +
.../eclipse/swt/internal/motif/XInputEvent.java | 10 +
.../org/eclipse/swt/internal/motif/XKeyEvent.java | 12 +
.../eclipse/swt/internal/motif/XMotionEvent.java | 12 +
.../org/eclipse/swt/internal/motif/XRectangle.java | 14 +
.../swt/internal/motif/XSetWindowAttributes.java | 25 +
.../swt/internal/motif/XWindowAttributes.java | 31 +
.../eclipse/swt/internal/motif/XWindowChanges.java | 15 +
.../eclipse/swt/internal/motif/XWindowEvent.java | 14 +
.../swt/internal/motif/XmAnyCallbackStruct.java | 12 +
.../swt/internal/motif/XmDragProcCallback.java | 21 +
.../swt/internal/motif/XmDropFinishCallback.java | 19 +
.../swt/internal/motif/XmDropProcCallback.java | 21 +
.../eclipse/swt/internal/motif/XmTextBlockRec.java | 13 +
.../internal/motif/XmTextVerifyCallbackStruct.java | 16 +
.../swt/internal/motif/XtWidgetGeometry.java | 15 +
.../org/eclipse/swt/widgets/AbstractTreeItem.java | 318 +
.../motif/org/eclipse/swt/widgets/Button.java | 631 ++
.../motif/org/eclipse/swt/widgets/Canvas.java | 212 +
.../motif/org/eclipse/swt/widgets/Caret.java | 402 +
.../motif/org/eclipse/swt/widgets/ColorDialog.java | 525 ++
.../motif/org/eclipse/swt/widgets/Combo.java | 1196 +++
.../motif/org/eclipse/swt/widgets/Composite.java | 439 ++
.../motif/org/eclipse/swt/widgets/Control.java | 1813 +++++
.../motif/org/eclipse/swt/widgets/CoolBar.java | 544 ++
.../motif/org/eclipse/swt/widgets/CoolItem.java | 296 +
.../motif/org/eclipse/swt/widgets/Decorations.java | 324 +
.../org/eclipse/swt/widgets/DirectoryDialog.java | 220 +
.../motif/org/eclipse/swt/widgets/Display.java | 1401 ++++
.../motif/org/eclipse/swt/widgets/FileDialog.java | 254 +
.../motif/org/eclipse/swt/widgets/FontDialog.java | 870 +++
.../org/eclipse/swt/widgets/FontExtStyle.java | 91 +
.../org/eclipse/swt/widgets/FontExtStyles.java | 133 +
.../motif/org/eclipse/swt/widgets/Group.java | 246 +
.../motif/org/eclipse/swt/widgets/Header.java | 336 +
.../motif/org/eclipse/swt/widgets/Label.java | 408 +
.../motif/org/eclipse/swt/widgets/List.java | 1584 ++++
.../motif/org/eclipse/swt/widgets/Menu.java | 648 ++
.../motif/org/eclipse/swt/widgets/MenuItem.java | 705 ++
.../motif/org/eclipse/swt/widgets/MessageBox.java | 319 +
.../motif/org/eclipse/swt/widgets/ProgressBar.java | 262 +
.../motif/org/eclipse/swt/widgets/Sash.java | 227 +
.../motif/org/eclipse/swt/widgets/Scale.java | 300 +
.../motif/org/eclipse/swt/widgets/ScrollBar.java | 558 ++
.../motif/org/eclipse/swt/widgets/Scrollable.java | 217 +
.../org/eclipse/swt/widgets/SelectableItem.java | 320 +
.../eclipse/swt/widgets/SelectableItemWidget.java | 2027 +++++
.../motif/org/eclipse/swt/widgets/Shell.java | 865 +++
.../motif/org/eclipse/swt/widgets/Slider.java | 406 +
.../motif/org/eclipse/swt/widgets/TabFolder.java | 885 +++
.../motif/org/eclipse/swt/widgets/TabItem.java | 337 +
.../motif/org/eclipse/swt/widgets/Table.java | 2361 ++++++
.../motif/org/eclipse/swt/widgets/TableColumn.java | 461 ++
.../motif/org/eclipse/swt/widgets/TableItem.java | 1032 +++
.../motif/org/eclipse/swt/widgets/Text.java | 1261 ++++
.../motif/org/eclipse/swt/widgets/ToolBar.java | 211 +
.../org/eclipse/swt/widgets/ToolDrawable.java | 31 +
.../motif/org/eclipse/swt/widgets/ToolItem.java | 763 ++
.../motif/org/eclipse/swt/widgets/Tracker.java | 193 +
.../motif/org/eclipse/swt/widgets/Tree.java | 1469 ++++
.../motif/org/eclipse/swt/widgets/TreeItem.java | 1146 +++
.../motif/org/eclipse/swt/widgets/TreeRoots.java | 157 +
.../motif/org/eclipse/swt/widgets/Widget.java | 725 ++
.../motif/org/eclipse/swt/widgets/WidgetTable.java | 121 +
.../Eclipse SWT/photon/library/build.sh | 12 +
.../Eclipse SWT/photon/library/library.c | 32 +
.../Eclipse SWT/photon/library/makefile.mak | 34 +
.../Eclipse SWT/photon/library/structs.c | 1091 +++
.../Eclipse SWT/photon/library/structs.h | 298 +
.../Eclipse SWT/photon/library/swt.c | 5896 +++++++++++++++
.../Eclipse SWT/photon/libswt0104.so | Bin 0 -> 372486 bytes
.../photon/org/eclipse/swt/graphics/Color.java | 99 +
.../photon/org/eclipse/swt/graphics/Cursor.java | 112 +
.../photon/org/eclipse/swt/graphics/Device.java | 253 +
.../org/eclipse/swt/graphics/DeviceData.java | 17 +
.../photon/org/eclipse/swt/graphics/Font.java | 107 +
.../photon/org/eclipse/swt/graphics/FontData.java | 188 +
.../org/eclipse/swt/graphics/FontMetrics.java | 78 +
.../photon/org/eclipse/swt/graphics/GC.java | 1407 ++++
.../photon/org/eclipse/swt/graphics/GCData.java | 23 +
.../photon/org/eclipse/swt/graphics/Image.java | 612 ++
.../photon/org/eclipse/swt/graphics/Region.java | 153 +
.../photon/org/eclipse/swt/internal/Converter.java | 71 +
.../eclipse/swt/internal/photon/FontDetails.java | 15 +
.../eclipse/swt/internal/photon/FontQueryInfo.java | 19 +
.../photon/org/eclipse/swt/internal/photon/OS.java | 2893 +++++++
.../org/eclipse/swt/internal/photon/PgAlpha_t.java | 24 +
.../org/eclipse/swt/internal/photon/PgMap_t.java | 16 +
.../org/eclipse/swt/internal/photon/PhArea_t.java | 14 +
.../swt/internal/photon/PhCursorInfo_t.java | 38 +
.../org/eclipse/swt/internal/photon/PhDim_t.java | 12 +
.../org/eclipse/swt/internal/photon/PhEvent_t.java | 27 +
.../org/eclipse/swt/internal/photon/PhImage_t.java | 28 +
.../eclipse/swt/internal/photon/PhKeyEvent_t.java | 21 +
.../org/eclipse/swt/internal/photon/PhPoint_t.java | 12 +
.../swt/internal/photon/PhPointerEvent_t.java | 20 +
.../org/eclipse/swt/internal/photon/PhRect_t.java | 14 +
.../eclipse/swt/internal/photon/PhRegion_t.java | 32 +
.../org/eclipse/swt/internal/photon/PhTile_t.java | 16 +
.../swt/internal/photon/PhWindowEvent_t.java | 22 +
.../swt/internal/photon/PtCallbackInfo_t.java | 14 +
.../swt/internal/photon/PtColorSelectInfo_t.java | 27 +
.../swt/internal/photon/PtFileSelectionInfo_t.java | 25 +
.../swt/internal/photon/PtScrollbarCallback_t.java | 12 +
.../swt/internal/photon/PtTextCallback_t.java | 18 +
.../eclipse/swt/internal/photon/PtTreeItem_t.java | 25 +
.../org/eclipse/swt/widgets/AbstractTreeItem.java | 318 +
.../photon/org/eclipse/swt/widgets/Button.java | 337 +
.../photon/org/eclipse/swt/widgets/Canvas.java | 180 +
.../photon/org/eclipse/swt/widgets/Caret.java | 222 +
.../org/eclipse/swt/widgets/ColorDialog.java | 51 +
.../photon/org/eclipse/swt/widgets/Combo.java | 497 ++
.../photon/org/eclipse/swt/widgets/Composite.java | 258 +
.../photon/org/eclipse/swt/widgets/Control.java | 991 +++
.../org/eclipse/swt/widgets/Decorations.java | 174 +
.../org/eclipse/swt/widgets/DirectoryDialog.java | 61 +
.../photon/org/eclipse/swt/widgets/Display.java | 943 +++
.../photon/org/eclipse/swt/widgets/FileDialog.java | 125 +
.../photon/org/eclipse/swt/widgets/FontDialog.java | 59 +
.../photon/org/eclipse/swt/widgets/Group.java | 122 +
.../photon/org/eclipse/swt/widgets/Header.java | 336 +
.../photon/org/eclipse/swt/widgets/Label.java | 231 +
.../photon/org/eclipse/swt/widgets/List.java | 589 ++
.../photon/org/eclipse/swt/widgets/Menu.java | 338 +
.../photon/org/eclipse/swt/widgets/MenuItem.java | 371 +
.../photon/org/eclipse/swt/widgets/MessageBox.java | 99 +
.../org/eclipse/swt/widgets/ProgressBar.java | 121 +
.../photon/org/eclipse/swt/widgets/Sash.java | 225 +
.../photon/org/eclipse/swt/widgets/Scale.java | 167 +
.../photon/org/eclipse/swt/widgets/ScrollBar.java | 306 +
.../photon/org/eclipse/swt/widgets/Scrollable.java | 120 +
.../org/eclipse/swt/widgets/SelectableItem.java | 320 +
.../eclipse/swt/widgets/SelectableItemWidget.java | 2027 +++++
.../photon/org/eclipse/swt/widgets/Shell.java | 541 ++
.../photon/org/eclipse/swt/widgets/Slider.java | 236 +
.../photon/org/eclipse/swt/widgets/TabFolder.java | 360 +
.../photon/org/eclipse/swt/widgets/TabItem.java | 135 +
.../photon/org/eclipse/swt/widgets/Table.java | 2361 ++++++
.../org/eclipse/swt/widgets/TableColumn.java | 461 ++
.../photon/org/eclipse/swt/widgets/TableItem.java | 1032 +++
.../photon/org/eclipse/swt/widgets/Text.java | 619 ++
.../photon/org/eclipse/swt/widgets/ToolBar.java | 155 +
.../photon/org/eclipse/swt/widgets/ToolItem.java | 325 +
.../photon/org/eclipse/swt/widgets/Tracker.java | 115 +
.../photon/org/eclipse/swt/widgets/Tree.java | 1469 ++++
.../photon/org/eclipse/swt/widgets/TreeItem.java | 1146 +++
.../photon/org/eclipse/swt/widgets/TreeRoots.java | 157 +
.../photon/org/eclipse/swt/widgets/Widget.java | 441 ++
.../org/eclipse/swt/widgets/WidgetTable.java | 101 +
.../Eclipse SWT/win32/library/build.bat | 23 +
.../Eclipse SWT/win32/library/library.c | 28 +
.../Eclipse SWT/win32/library/makefile.mak | 67 +
.../Eclipse SWT/win32/library/structs.c | 3976 ++++++++++
.../Eclipse SWT/win32/library/structs.h | 1514 ++++
.../Eclipse SWT/win32/library/swt.c | 7893 +++++++++++++++++++
.../Eclipse SWT/win32/library/swt.rc | 108 +
.../Eclipse SWT/win32/library/swtole.c | 3418 +++++++++
.../win32/org/eclipse/swt/graphics/Color.java | 303 +
.../win32/org/eclipse/swt/graphics/Cursor.java | 344 +
.../win32/org/eclipse/swt/graphics/Device.java | 684 ++
.../win32/org/eclipse/swt/graphics/DeviceData.java | 17 +
.../win32/org/eclipse/swt/graphics/Font.java | 203 +
.../win32/org/eclipse/swt/graphics/FontData.java | 599 ++
.../org/eclipse/swt/graphics/FontMetrics.java | 171 +
.../win32/org/eclipse/swt/graphics/GC.java | 1656 ++++
.../win32/org/eclipse/swt/graphics/GCData.java | 31 +
.../win32/org/eclipse/swt/graphics/Image.java | 1601 ++++
.../win32/org/eclipse/swt/graphics/Region.java | 252 +
.../win32/org/eclipse/swt/internal/Converter.java | 181 +
.../org/eclipse/swt/internal/win32/ACCEL.java | 13 +
.../org/eclipse/swt/internal/win32/BITMAP.java | 17 +
.../org/eclipse/swt/internal/win32/BROWSEINFO.java | 18 +
.../eclipse/swt/internal/win32/CHOOSECOLOR.java | 19 +
.../org/eclipse/swt/internal/win32/CHOOSEFONT.java | 26 +
.../swt/internal/win32/COMPOSITIONFORM.java | 15 +
.../eclipse/swt/internal/win32/CREATESTRUCT.java | 22 +
.../org/eclipse/swt/internal/win32/DIBSECTION.java | 26 +
.../eclipse/swt/internal/win32/DLLVERSIONINFO.java | 15 +
.../org/eclipse/swt/internal/win32/DOCINFO.java | 15 +
.../eclipse/swt/internal/win32/DRAWITEMSTRUCT.java | 20 +
.../org/eclipse/swt/internal/win32/HDITEM.java | 19 +
.../org/eclipse/swt/internal/win32/HELPINFO.java | 18 +
.../org/eclipse/swt/internal/win32/ICONINFO.java | 15 +
.../swt/internal/win32/INITCOMMONCONTROLSEX.java | 12 +
.../org/eclipse/swt/internal/win32/LOGBRUSH.java | 13 +
.../org/eclipse/swt/internal/win32/LOGFONT.java | 33 +
.../org/eclipse/swt/internal/win32/LOGPEN.java | 15 +
.../org/eclipse/swt/internal/win32/LRESULT.java | 15 +
.../org/eclipse/swt/internal/win32/LVCOLUMN.java | 18 +
.../eclipse/swt/internal/win32/LVHITTESTINFO.java | 16 +
.../org/eclipse/swt/internal/win32/LVITEM.java | 20 +
.../swt/internal/win32/MEASUREITEMSTRUCT.java | 16 +
.../org/eclipse/swt/internal/win32/MENUINFO.java | 17 +
.../eclipse/swt/internal/win32/MENUITEMINFO.java | 35 +
.../win32/org/eclipse/swt/internal/win32/MSG.java | 17 +
.../org/eclipse/swt/internal/win32/NMHDR.java | 13 +
.../org/eclipse/swt/internal/win32/NMHEADER.java | 13 +
.../org/eclipse/swt/internal/win32/NMLISTVIEW.java | 18 +
.../org/eclipse/swt/internal/win32/NMTOOLBAR.java | 23 +
.../eclipse/swt/internal/win32/NMTTDISPINFO.java | 17 +
.../eclipse/swt/internal/win32/OPENFILENAME.java | 30 +
.../win32/org/eclipse/swt/internal/win32/OS.java | 4445 +++++++++++
.../eclipse/swt/internal/win32/PAINTSTRUCT.java | 18 +
.../org/eclipse/swt/internal/win32/POINT.java | 12 +
.../org/eclipse/swt/internal/win32/PRINTDLG.java | 29 +
.../eclipse/swt/internal/win32/REBARBANDINFO.java | 30 +
.../win32/org/eclipse/swt/internal/win32/RECT.java | 14 +
.../org/eclipse/swt/internal/win32/SCROLLINFO.java | 17 +
.../win32/org/eclipse/swt/internal/win32/SIZE.java | 12 +
.../org/eclipse/swt/internal/win32/TBBUTTON.java | 17 +
.../eclipse/swt/internal/win32/TBBUTTONINFO.java | 20 +
.../org/eclipse/swt/internal/win32/TCITEM.java | 17 +
.../org/eclipse/swt/internal/win32/TEXTMETRIC.java | 32 +
.../org/eclipse/swt/internal/win32/TOOLINFO.java | 19 +
.../swt/internal/win32/TRACKMOUSEEVENT.java | 14 +
.../eclipse/swt/internal/win32/TVHITTESTINFO.java | 15 +
.../eclipse/swt/internal/win32/TVINSERTSTRUCT.java | 23 +
.../org/eclipse/swt/internal/win32/TVITEM.java | 20 +
.../swt/internal/win32/WINDOWPLACEMENT.java | 24 +
.../org/eclipse/swt/internal/win32/WINDOWPOS.java | 17 +
.../org/eclipse/swt/internal/win32/WNDCLASSEX.java | 22 +
.../org/eclipse/swt/internal/win32/package.html | 22 +
.../win32/org/eclipse/swt/widgets/Button.java | 627 ++
.../win32/org/eclipse/swt/widgets/Canvas.java | 205 +
.../win32/org/eclipse/swt/widgets/Caret.java | 488 ++
.../win32/org/eclipse/swt/widgets/ColorDialog.java | 181 +
.../win32/org/eclipse/swt/widgets/Combo.java | 1247 +++
.../win32/org/eclipse/swt/widgets/Composite.java | 608 ++
.../win32/org/eclipse/swt/widgets/Control.java | 3556 +++++++++
.../win32/org/eclipse/swt/widgets/CoolBar.java | 567 ++
.../win32/org/eclipse/swt/widgets/CoolItem.java | 381 +
.../win32/org/eclipse/swt/widgets/Decorations.java | 1000 +++
.../org/eclipse/swt/widgets/DirectoryDialog.java | 233 +
.../win32/org/eclipse/swt/widgets/Display.java | 1502 ++++
.../win32/org/eclipse/swt/widgets/FileDialog.java | 252 +
.../win32/org/eclipse/swt/widgets/FontDialog.java | 110 +
.../win32/org/eclipse/swt/widgets/Group.java | 283 +
.../win32/org/eclipse/swt/widgets/ImageList.java | 262 +
.../win32/org/eclipse/swt/widgets/Label.java | 510 ++
.../win32/org/eclipse/swt/widgets/List.java | 1427 ++++
.../win32/org/eclipse/swt/widgets/Menu.java | 716 ++
.../win32/org/eclipse/swt/widgets/MenuItem.java | 657 ++
.../win32/org/eclipse/swt/widgets/MessageBox.java | 158 +
.../win32/org/eclipse/swt/widgets/ProgressBar.java | 223 +
.../win32/org/eclipse/swt/widgets/Sash.java | 284 +
.../win32/org/eclipse/swt/widgets/Scale.java | 369 +
.../win32/org/eclipse/swt/widgets/ScrollBar.java | 884 +++
.../win32/org/eclipse/swt/widgets/Scrollable.java | 313 +
.../win32/org/eclipse/swt/widgets/Shell.java | 944 +++
.../win32/org/eclipse/swt/widgets/Slider.java | 734 ++
.../win32/org/eclipse/swt/widgets/TabFolder.java | 685 ++
.../win32/org/eclipse/swt/widgets/TabItem.java | 193 +
.../win32/org/eclipse/swt/widgets/Table.java | 2149 ++++++
.../win32/org/eclipse/swt/widgets/TableColumn.java | 369 +
.../win32/org/eclipse/swt/widgets/TableItem.java | 527 ++
.../win32/org/eclipse/swt/widgets/Text.java | 1652 ++++
.../win32/org/eclipse/swt/widgets/ToolBar.java | 612 ++
.../win32/org/eclipse/swt/widgets/ToolItem.java | 581 ++
.../win32/org/eclipse/swt/widgets/Tracker.java | 272 +
.../win32/org/eclipse/swt/widgets/Tree.java | 1397 ++++
.../win32/org/eclipse/swt/widgets/TreeItem.java | 439 ++
.../win32/org/eclipse/swt/widgets/Widget.java | 971 +++
.../win32/org/eclipse/swt/widgets/WidgetTable.java | 113 +
.../org.eclipse.swt/Eclipse SWT/win32/swt0105.dll | Bin 0 -> 237568 bytes
587 files changed, 186648 insertions(+)
create mode 100755 bundles/org.eclipse.swt/.classpath_motif
create mode 100755 bundles/org.eclipse.swt/.classpath_win32
create mode 100755 bundles/org.eclipse.swt/.cvsignore
create mode 100755 bundles/org.eclipse.swt/.vcm_meta
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IFont.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStream.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/ProgramSupport.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/library/library.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/common/readme_swt.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/gnome.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/library.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_solaris.mak
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/libswt-gnome0105.so
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/libswt0105.so
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/GNOME.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/Visual.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCharStruct.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XColor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFontStruct.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XGCValues.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XImage.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XInputEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XRectangle.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyle.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyles.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/build.sh
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/library.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/libswt0104.so
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/build.bat
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/library.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/library/swtole.c
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ACCEL.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BITMAP.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DOCINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HDITEM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HELPINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ICONINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGFONT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGPEN.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LRESULT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVITEM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MSG.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHDR.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHEADER.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/POINT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/RECT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SIZE.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TCITEM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVITEM.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WNDCLASSEX.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/package.html
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java
create mode 100755 bundles/org.eclipse.swt/Eclipse SWT/win32/swt0105.dll
(limited to 'bundles')
diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/bundles/org.eclipse.swt/.classpath_win32 b/bundles/org.eclipse.swt/.classpath_win32
new file mode 100755
index 0000000000..6cd92d2205
--- /dev/null
+++ b/bundles/org.eclipse.swt/.classpath_win32
@@ -0,0 +1,16 @@
+
+
Runnable
while providing
+ * busy feedback using this busy indicator.
+ *
+ * @param 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 the runnable for which busy feedback is to be shown
+ * @see #showWhile
+ */
+
+public static void showWhile(Display display, Runnable runnable) {
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ runnable.run();
+ return;
+ }
+ }
+
+ int index = 0;
+ while (index < displays.length) {
+ if (displays[index] == display) break;
+ index++;
+ }
+ if (index == displays.length) {
+ Display[] newDisplays = new Display[displays.length + 1];
+ System.arraycopy(displays, 0, newDisplays, 0, displays.length);
+ displays = newDisplays;
+ displays[index] = display;
+ final Display d = display;
+ display.disposeExec( new Runnable() {
+ public void run() {
+ clear (d);
+ }
+ });
+
+ int[] newCounts = new int[counts.length + 1];
+ System.arraycopy(counts, 0, newCounts, 0, counts.length);
+ counts = newCounts;
+
+ Cursor[] newCursors = new Cursor[cursors.length + 1];
+ System.arraycopy(cursors, 0, newCursors, 0, cursors.length);
+ cursors = newCursors;
+ }
+
+ if (counts[index] == 0) {
+ cursors[index] = new Cursor(display, SWT.CURSOR_WAIT);
+ }
+
+ counts[index]++;
+
+ Shell[] shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].setCursor(cursors[index]);
+ }
+
+ try {
+ runnable.run();
+ } finally {
+ counts[index]--;
+ if (counts[index] == 0) {
+ shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].setCursor(null);
+ }
+ cursors[index].dispose();
+ cursors[index] = null;
+ }
+ }
+}
+
+static void clear(Display display) {
+ int index = 0;
+ while (index < displays.length) {
+ if (displays[index] == display) break;
+ index++;
+ }
+
+ if (index == displays.length) return;
+
+ if (cursors[index] != null) {
+ cursors[index].dispose();
+ }
+ cursors[index] = null;
+ counts[index] = 0;
+ displays[index] = null;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
new file mode 100755
index 0000000000..f263e2b2fd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
@@ -0,0 +1,950 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The CCombo class represents a selectable user interface object
+ * that combines a text field and a list and issues notificiation
+ * when an item is selected from the list.
+ * + *
+* The item is placed at an index in the list. +* Indexing is zero based. +* +* This operation will fail when the index is +* out of range. +* +* @param string the new item +* @param index the index for the item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when the string is null +* @exception SWTError(ERROR_ITEM_NOT_ADDED) +* when the item cannot be added +*/ +public void add (String string, int index) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + list.add (string, index); +} +/** +* Adds the listener to receive events. +*
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addModifyListener (ModifyListener listener) {; + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Modify, typedListener); +} +/** +* Adds the listener to receive events. +*
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addSelectionListener(SelectionListener listener) { + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Selection,typedListener); + addListener (SWT.DefaultSelection,typedListener); +} +void arrowEvent (Event event) { + if (event.type != SWT.MouseDown || event.button != 1) return; + dropDown (!isDropped ()); +} +/** +* Clears the current selection. +*
+* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public void clearSelection () { + text.clearSelection (); + list.deselectAll (); +} +void comboEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + if (popup != null && !popup.isDisposed ()) + popup.dispose (); + popup = null; + text = null; + list = null; + arrow = null; + break; + + case SWT.Move: + dropDown(false); + break; + case SWT.Resize: + internalLayout(); + break; + } +} + +public Point computeSize (int wHint, int hHint, boolean changed) { + int width = 0, height = 0; + Point textSize = text.computeSize (wHint, SWT.DEFAULT, changed); + Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); + Point listSize = list.computeSize (wHint, SWT.DEFAULT, changed); + Point barSize = list.getVerticalBar().getSize(); + int borderWidth = getBorderWidth(); + + height = Math.max (hHint, Math.max(textSize.y, arrowSize.y) + 2*borderWidth); + width = Math.max (wHint, Math.max(textSize.x + arrowSize.x + 2*borderWidth, listSize.x + 2) ); + return new Point (width, height); +} +/** +* Deselects an item. +*
+* If the item at an index is selected, it is +* deselected. If the item at an index is not +* selected, it remains deselected. Indices +* that are out of range are ignored. Indexing +* is zero based. +* +* @param index the index of the item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public void deselect (int index) { + list.deselect (index); +} +/** +* Deselects all items. +*
+* +* If an item is selected, it is deselected. +* If an item is not selected, it remains unselected. +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public void deselectAll () { + list.deselectAll (); +} +void dropDown (boolean drop) { + if (drop == isDropped ()) return; + if (!drop) { + popup.setVisible (false); + return; + } + int index = list.getSelectionIndex (); + if (index != -1) list.setTopIndex (index); + Rectangle listRect = list.getBounds (); + int borderWidth = getBorderWidth(); + Point point = toDisplay (new Point (0 - borderWidth, 0 - borderWidth)); + Point comboSize = getSize(); + popup.setBounds (point.x, point.y + comboSize.y, comboSize.x, listRect.height + 2); + popup.setVisible (true); + list.setFocus(); +} +public Control [] getChildren () { + return new Control [0]; +} +boolean getEditable () { + return text.getEditable (); +} +/** +* Gets an item at an index. +*
+* 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 +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_CANNOT_GET_ITEM) +* when the operation fails +*/ +public String getItem (int index) { + return list.getItem (index); +} +/** +* Gets the number of items. +*
+* This operation will fail if the number of +* items could not be queried from the OS. +* +* @return the number of items in the widget +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_CANNOT_GET_COUNT) +* when the operation fails +*/ +public int getItemCount () { + return list.getItemCount (); +} +/** +* Gets the height of one item. +*
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT) +* when the operation fails +*/ +public int getItemHeight () { + return list.getItemHeight (); +} +/** +* Gets the items. +*
+* This operation will fail if the items cannot +* be queried from the OS. +* +* @return the items in the widget +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_CANNOT_GET_ITEM) +* when the operation fails +*/ +public String [] getItems () { + return list.getItems (); +} +/** +* Gets the selection. +*
+* @return a point representing the selection start and end +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public Point getSelection () { + return text.getSelection (); +} +/** +* Gets the index of the selected item. +*
+* Indexing is zero based. +* If no item is selected -1 is returned. +* +* @return the index of the selected item. +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public int getSelectionIndex () { + return list.getSelectionIndex (); +} +/** +* Gets the widget text. +*
+* If the widget has no text, an empty string is returned. +* +* @return the widget text +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public String getText () { + return text.getText (); +} +/** +* Gets the height of the combo's text field. +*
+* The operation will fail if the height cannot +* be queried from the OS. + +* @return the height of the combo's text field. +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_ERROR_CANNOT_GET_ITEM_HEIGHT) +* when the operation fails +*/ +public int getTextHeight () { + return text.getLineHeight(); +} +/** +* Gets the text limit. +*
+* @return the text limit +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public int getTextLimit () { + return text.getTextLimit (); +} +/** +* Gets the index of an item. +*
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when string is null +*/ +public int indexOf (String string) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + return list.indexOf (string); +} +/** +* Gets the index of an item. +*
+* The widget is searched starting at start including +* the end position until an item is found that +* is equal to the search itenm. If no item is +* found, -1 is returned. Indexing is zero based. +* +* @param string the search item +* @param index the starting position +* @return the index of the item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when string is null +*/ +public int indexOf (String string, int start) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + return list.indexOf (string, start); +} +boolean isDropped () { + return popup.getVisible (); +} +void internalLayout () { + Rectangle rect = getClientArea(); + int width = rect.width; + int height = rect.height; + + if (isDropped ()) dropDown (false); + Point arrowSize = arrow.computeSize(SWT.DEFAULT, height); + text.setBounds (0, 0, width - arrowSize.x, height); + arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y); + + Point size = getSize(); + int listHeight = list.getItemHeight () * ITEMS_SHOWING; + Rectangle trim = list.computeTrim (0, 0, size.x - 2, listHeight); + list.setBounds (1, 1, size.x - 2, trim.height); +} +void listEvent (Event event) { + switch (event.type) { + case SWT.MouseUp: { + if (event.button != 1) return; + dropDown (false); + break; + } + case SWT.Selection: { + int index = list.getSelectionIndex (); + if (index == -1) return; + text.setText (list.getItem (index)); + text.selectAll (); + list.setSelection(index); + Event e = new Event(); + e.time = event.time; + e.x = event.x; + e.y = event.y; + e.width = event.width; + e.height = event.height; + e.detail = event.detail; + e.doit = event.doit; + notifyListeners(SWT.Selection, e); + event.doit = e.doit; + break; + } + case SWT.FocusOut: { + Control control = getDisplay ().getFocusControl (); + if (control == text) return; + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.FocusOut, e); + break; + } + case SWT.FocusIn: { + Control control = getDisplay ().getFocusControl (); + if (control == text) return; + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.FocusIn, e); + break; + } + } +} +void popupEvent(Event event) { + switch (event.type) { + case SWT.Paint: + // draw black rectangle around list + Rectangle listRect = list.getBounds(); + Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); + event.gc.setForeground(black); + event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); + break; + case SWT.Close: + event.doit = false; + dropDown (false); + break; + case SWT.Deactivate: + dropDown (false); + break; + } +} +public void redraw (int x, int y, int width, int height, boolean all) { + if (!all) return; + Point location = text.getLocation(); + text.redraw(x - location.x, y - location.y, width, height, all); + location = list.getLocation(); + list.redraw(x - location.x, y - location.y, width, height, all); + if (arrow != null) { + location = arrow.getLocation(); + arrow.redraw(x - location.x, y - location.y, width, height, all); + } +} + +/** +* Removes an item at an index. +*
+* Indexing is zero based. +* +* This operation will fail when the index is out +* of range or an item could not be removed from +* the OS. +* +* @param index the index of the item +* @return the selection state +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_ITEM_NOT_REMOVED) +* when the operation fails +*/ +public void remove (int index) { + list.remove (index); +} +/** +* Removes a range of items. +*
+* Indexing is zero based. The range of items +* is from the start index up to and including +* the end index. +* +* This operation will fail when the index is out +* of range or an item could not be removed from +* the OS. +* +* @param start the start of the range +* @param end the end of the range +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_ITEM_NOT_REMOVED) +* when the operation fails +*/ +public void remove (int start, int end) { + list.remove (start, end); +} +/** +* Removes an item. +*
+* This operation will fail when the item +* could not be removed from the OS. +* +* @param string the search item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when string is null +* @exception SWTError(ERROR_ITEM_NOT_REMOVED) +* when the operation fails +*/ +public void remove (String string) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + list.remove (string); +} +/** +* Removes all items. +*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public void removeAll () { + text.setText (""); + list.removeAll (); +} +/** +* Removes the listener. +*
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void removeModifyListener (ModifyListener listener) { + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + removeListener(SWT.Modify, listener); +} +/** +* Removes the listener. +*
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void removeSelectionListener (SelectionListener listener) { + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + removeListener(SWT.Selection, listener); + removeListener(SWT.DefaultSelection,listener); +} +/** +* Selects an item. +*
+* If the item at an index is not selected, it is +* selected. Indices that are out of +* range are ignored. Indexing is zero based. +* +* @param index the index of the item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public void select (int index) { + if (index == -1) { + list.deselectAll (); + text.setText (""); + return; + } + if (0 <= index && index < list.getItemCount()) { + if (index != getSelectionIndex()) { + text.setText (list.getItem (index)); + text.selectAll (); + list.select (index); + list.showSelection (); + } + } +} +public void setBackground (Color color) { + super.setBackground(color); + if (text != null) text.setBackground(color); + if (list != null) list.setBackground(color); + if (arrow != null) arrow.setBackground(color); +} + + +/** +* Sets the focus. +*/ +public boolean setFocus () { + return text.setFocus (); +} +/** +* Sets the widget font. +*/ +public void setFont (Font font) { + super.setFont (font); + text.setFont (font); + list.setFont (font); + internalLayout (); +} +public void setForeground (Color color) { + super.setForeground(color); + if (text != null) text.setForeground(color); + if (list != null) list.setForeground(color); + if (arrow != null) arrow.setForeground(color); +} +/** +* Sets the text of an item. +*
+* Indexing is zero based. +* +* This operation will fail when the index is out +* of range or an item could not be changed in +* the OS. +* +* @param index the index for the item +* @param string the item +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when items is null +* @exception SWTError(ERROR_ITEM_NOT_MODIFIED) +* when the operation fails +*/ +public void setItem (int index, String string) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + list.setItem (index, string); +} +/** +* Sets all items. +*
+* @param items the array of items +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when items is null +* @exception SWTError(ERROR_ITEM_NOT_ADDED) +* when the operation fails +*/ +public void setItems (String [] items) { + if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int style = getStyle(); + if ((style & SWT.READ_ONLY) != 0) text.setText (""); + list.setItems (items); +} +/** +* Sets the new selection. +*
+* @param selection point representing the start and the end of the new selection +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when selection is null +*/ +public void setSelection (Point selection) { + if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + text.setSelection (selection.x, selection.y); +} + + +/** +* Sets the widget text +*
+* @param string the widget text +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when string is null +*/ +public void setText (String string) { + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int index = list.indexOf (string); + if (index == -1) { + list.deselectAll (); + text.setText (string); + return; + } + text.setText (string); + text.selectAll (); + list.setSelection (index); + list.showSelection (); +} +/** +* Sets the text limit +*
+* @param limit new text limit +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_CANNOT_BE_ZERO) +* when limit is 0 +*/ +public void setTextLimit (int limit) { + text.setTextLimit (limit); +} +void textEvent (Event event) { + switch (event.type) { + case SWT.KeyDown: { + + if (event.character == SWT.ESC) { // escape key cancels popup list + dropDown (false); + return; + } + if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) { + int oldIndex = getSelectionIndex (); + if (event.keyCode == SWT.ARROW_UP) { + select (Math.max (oldIndex - 1, 0)); + } else { + select (Math.min (oldIndex + 1, getItemCount () - 1)); + } + + if (oldIndex != getSelectionIndex ()) { + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.Selection, e); + } + } + + // Further work : Need to add support for incremental search in pop up list as characters typed in text widget + + Event e = new Event(); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners(SWT.KeyDown, e); + break; + } + case SWT.KeyUp: { + Event e = new Event(); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners(SWT.KeyUp, e); + break; + } + case SWT.Modify: { + list.deselectAll (); + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.Modify, e); + break; + } + case SWT.MouseDown: { + if (event.button != 1) return; + if (text.getEditable ()) return; + boolean dropped = isDropped (); + text.selectAll (); + if (!dropped) setFocus (); + dropDown (!dropped); + break; + } + case SWT.MouseUp: { + if (event.button != 1) return; + if (text.getEditable ()) return; + text.selectAll (); + break; + } + case SWT.FocusIn: { + if (getEditable ()) text.selectAll (); + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.FocusIn, e); + break; + } + case SWT.FocusOut: { + Display display = getDisplay (); + Control focusControl = display.getFocusControl (); + if (isDropped ()) { + Control cursorControl = display.getCursorControl (); + if (cursorControl != list) dropDown (false); + if (focusControl != text) dropDown (false); + } + if (focusControl == list) return; + Event e = new Event(); + e.time = event.time; + notifyListeners(SWT.FocusOut, e); + break; + } + case SWT.Traverse: { + if (event.detail == SWT.TRAVERSE_ARROW_PREVIOUS || event.detail == SWT.TRAVERSE_ARROW_NEXT) { + event.doit = false; + } + Event e = new Event(); + e.time = event.time; + e.detail = event.detail; + e.doit = event.doit; + e.keyCode = event.keyCode; + notifyListeners(SWT.Traverse, e); + event.doit = e.doit; + break; + } + } +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java new file mode 100755 index 0000000000..c2c372db5f --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java @@ -0,0 +1,462 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.events.*; + +/** + * A Label which supports aligned text and/or an image and different border styles. + *
+ * If there is not enough space a SmartLabel uses the following strategy to fit the + * information into the available space: + *
+ * 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 + *+ *
+ *
null
.
+ */
+public Image getImage() {
+ return image;
+}
+/**
+ * Compute the minimum size.
+ */
+private Point getTotalSize(Image image, String text) {
+ Point size = new Point(0, 0);
+
+ if (image != null) {
+ Rectangle r = image.getBounds();
+ size.x += r.width;
+ size.y += r.height;
+ }
+
+ GC gc = new GC(this);
+ if (text != null && text.length() > 0) {
+ Point e = gc.textExtent(text);
+ size.x += e.x;
+ size.y = Math.max(size.y, e.y);
+ if (image != null) size.x += GAP;
+ } else {
+ size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
+ }
+ gc.dispose();
+
+ return size;
+}
+public void setToolTipText (String string) {
+ super.setToolTipText (string);
+ appToolTipText = super.getToolTipText();
+}
+/**
+ * Return the Label's text.
+ */
+public String getText() {
+ return text;
+}
+public String getToolTipText () {
+ return appToolTipText;
+}
+/**
+ * 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 & SWT.SHADOW_IN) != 0) {
+ c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+ }
+ if ((style & SWT.SHADOW_OUT) != 0) {
+ c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+ c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ }
+
+ if (c1 != null && c2 != null) {
+ gc.setLineWidth(1);
+ drawBevelRect(gc, r.x, r.y, r.width-1, r.height-1, c1, c2);
+ }
+}
+private void onDispose(DisposeEvent event) {
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ }
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+}
+/*
+ * Process the paint event
+ */
+private void onPaint(PaintEvent event) {
+ Rectangle rect = getClientArea();
+ if (rect.width == 0 || rect.height == 0) return;
+
+ boolean shortenText = false;
+ String t = text;
+ Image i = image;
+ int availableWidth = rect.width - 2*hIndent;
+ Point extent = getTotalSize(i, t);
+ if (extent.x > availableWidth) {
+ i = null;
+ extent = getTotalSize(i, t);
+ if (extent.x > availableWidth) {
+ shortenText = true;
+ }
+ }
+
+ GC gc = event.gc;
+
+ // shorten the text
+ if (shortenText) {
+ t = shortenText(gc, text, availableWidth);
+ extent = getTotalSize(i, t);
+ if (appToolTipText == null) {
+ super.setToolTipText(text);
+ }
+ } else {
+ super.setToolTipText(appToolTipText);
+ }
+
+ // determine horizontal position
+ int x = rect.x + hIndent;
+ if (align == SWT.CENTER) {
+ x = (rect.width-extent.x)/2;
+ }
+ if (align == SWT.RIGHT) {
+ x = rect.width-extent.x - hIndent;
+ }
+
+ // draw a background image behind the text
+ if (backgroundImage != null) {
+ Rectangle imageRect = backgroundImage.getBounds();
+ gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ 0, 0, rect.width, rect.height);
+ } else {
+ gc.setBackground(getBackground());
+ gc.fillRectangle(rect);
+ }
+ // draw border
+ int style = getStyle();
+ if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {
+ paintBorder(gc, rect);
+ }
+ // draw the image
+ if (i != null) {
+ Rectangle imageRect = i.getBounds();
+ gc.drawImage(i, 0, 0, imageRect.width, imageRect.height,
+ x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
+ x += imageRect.width + GAP;
+ }
+ // draw the text
+ if (t != null) {
+ int textHeight = gc.getFontMetrics().getHeight();
+ gc.setForeground(getForeground());
+ gc.drawText(t, x, rect.y + (rect.height-textHeight)/2, true);
+ }
+}
+/**
+ * Set the alignment of the CLabel.
+ * Use the values LEFT, CENTER and RIGHT to align image and text within the available space.
+ */
+public void setAlignment(int align) {
+ if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.align != align) {
+ this.align = align;
+ redraw();
+ }
+}
+/**
+ * Specify a gradiant of colours to be draw in the background of the CLabel.
+ * For example to draw a gradiant that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * + * clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), + * display.getSystemColor(SWT.COLOR_BLUE), + * display.getSystemColor(SWT.COLOR_WHITE), + * display.getSystemColor(SWT.COLOR_WHITE)}, + * new int[] {25, 50, 100}); + *+ * + * @param colors an array of Color that specifies the colors to appear in the gradiant + * in order of appearance left to right. The value
null
clears the
+ * background gradiant. The value null
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.
+ */
+public void setBackground(Color[] colors, int[] percents) {
+ if (colors != null) {
+ if (percents == null || percents.length != colors.length - 1)
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ for (int i = 0; i < percents.length; i++) {
+ if (percents[i] < 0 || percents[i] > 100)
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (i > 0 && percents[i] < percents[i-1])
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+
+ // Are these settings the same as before?
+ if (gradientImage == null && gradientColors == null && colors == null) {
+ if (backgroundImage != null) {
+ backgroundImage = null;
+ redraw();
+ }
+ return;
+ }
+ if (gradientColors != null && colors != null
+ && gradientColors.length == colors.length) {
+ boolean same = false;
+ for (int i = 0; i < gradientColors.length; i++) {
+ same = gradientColors[i].equals(colors[i]);
+ if (!same) break;
+ }
+ if (same) {
+ for (int i = 0; i < gradientPercents.length; i++) {
+ same = gradientPercents[i] == percents[i];
+ if (!same) break;
+ }
+ }
+ if (same) return;
+ }
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ }
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+
+ Display display = getDisplay();
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ if (colors.length == 1) {
+ gc.setBackground(colors[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ int start = 0;
+ int end = 0;
+ for (int j = 0; j < colors.length - 1; j++) {
+ Color startColor = colors[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colors[j+1];
+ if (endColor == null) endColor = getBackground();
+ RGB rgb2 = endColor.getRGB();
+ start = end;
+ end = (width) * percents[j] / 100;
+ int range = Math.max(1, end - start);
+ for (int k = 0; k < (end - start); k++) {
+ int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;
+ r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);
+ int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;
+ g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);
+ int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;
+ b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);
+ Color color = new Color(display, r, g, b);
+ gc.setBackground(color);
+ gc.fillRectangle(start + k,y,1,height);
+ gc.setBackground(getBackground());
+ color.dispose();
+ }
+ }
+ gc.dispose();
+ gradientImage = temp;
+ gradientColors = colors;
+ gradientPercents = percents;
+ backgroundImage = temp;
+ }
+
+ redraw();
+}
+public void setBackground(Image image) {
+ if (image == backgroundImage) return;
+
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ }
+ backgroundImage = image;
+ redraw();
+
+}
+public void setFont(Font font) {
+ super.setFont(font);
+ redraw();
+}
+/**
+ * Set the label's Image.
+ * The value null
clears it.
+ */
+public void setImage(Image image) {
+ if (image != this.image) {
+ this.image = image;
+ redraw();
+ }
+}
+/**
+ * Set the label's text.
+ * The value null
clears it.
+ */
+public void setText(String text) {
+ if (text == null) text = "";
+ if (! text.equals(this.text)) {
+ this.text = text;
+ redraw();
+ }
+}
+/**
+ * Shorten the given text t
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.
+ */
+protected String shortenText(GC gc, String t, int width) {
+ int w = gc.textExtent(ellipsis).x;
+ int l = t.length();
+ int pivot = l/2;
+ int s = pivot;
+ int e = pivot+1;
+ while (s >= 0 && e < l) {
+ String s1 = t.substring(0, s);
+ String s2 = t.substring(e, l);
+ int l1 = gc.textExtent(s1).x;
+ int l2 = gc.textExtent(s2).x;
+ if (l1+w+l2 < width) {
+ t = s1 + ellipsis + s2;
+ break;
+ }
+ s--;
+ e++;
+ }
+ return t;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
new file mode 100755
index 0000000000..4c4f90cbb8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -0,0 +1,1535 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+
+public class CTabFolder extends 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;
+
+ /**
+ * Color of innermost line of drop shadow border.
+ */
+ public static RGB borderInsideRGB = new RGB (132, 130, 132);
+ /**
+ * Color of middle line of drop shadow border.
+ */
+ public static RGB borderMiddleRGB = new RGB (143, 141, 138);
+ /**
+ * Color of outermost line of drop shadow border.
+ */
+ public static RGB borderOutsideRGB = new RGB (171, 168, 165);
+
+ /*
+ * 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.
+ */
+ public static int MIN_TAB_WIDTH = 3;
+
+ /* sizing, positioning */
+ int xClient, yClient;
+ boolean onBottom = false;
+ int fixedTabHeight = -1;
+ int imageHeight = -1;
+
+ /* item management */
+ private CTabItem items[] = new CTabItem[0];
+ private int selectedIndex = -1;
+ int topTabIndex = -1; // index of the left most visible tab.
+
+ /* External Listener management */
+ private CTabFolderListener[] tabListeners = new CTabFolderListener[0];
+
+ /* Color appearance */
+ Image backgroundImage;
+ private Image gradientImage;
+ private Color[] gradientColors;
+ private int[] gradientPercents;
+ Color selectionForeground;
+
+ // internal constants
+ private static final int DEFAULT_WIDTH = 64;
+ private static final int DEFAULT_HEIGHT = 64;
+
+ // scrolling arrows
+ private ToolBar scrollBar;
+ private ToolItem scrollLeft;
+ private ToolItem scrollRight;
+ private Image arrowLeftImage;
+ private Image arrowRightImage;
+ private Image arrowLeftDisabledImage;
+ private Image arrowRightDisabledImage;
+
+ // close button
+ boolean showClose = false;
+ ToolBar closeBar;
+ private ToolItem closeItem;
+ private Image closeImage;
+ private ToolBar inactiveCloseBar;
+ private ToolItem inactiveCloseItem;
+ private Image inactiveCloseImage;
+ private CTabItem inactiveItem;
+
+ private boolean shortenedTabs = false;
+
+ // borders
+ boolean showBorders = false;
+ private int BORDER_BOTTOM = 0;
+ private int BORDER_LEFT = 0;
+ private int BORDER_RIGHT = 0;
+ private int BORDER_TOP = 0;
+ private Color borderColor1;
+ private Color borderColor2;
+ private Color borderColor3;
+
+ // when disposing CTabFolder, don't try to layout the items or
+ // change the selection as each child is destroyed.
+ private boolean inDispose = false;
+
+ // keep track of size changes in order to redraw only affected area
+ // on Resize
+ private Rectangle oldArea;
+
+ // insertion marker
+ int insertionIndex = -2; // Index of insert marker. Marker always shown after index.
+ // -2 means no insert marker
+
+ // tool tip
+ private Shell tip;
+
+/**
+ * Construct a CTabFolder with the specified parent and style.
+ * @param parent org.eclipse.swt.widgets.Composite
+ * @param swtStyle int
+ */
+public CTabFolder(Composite parent, int style) {
+ super(parent, checkStyle (style));
+
+ onBottom = (getStyle() & SWT.BOTTOM) != 0;
+
+ borderColor1 = new Color(getDisplay(), borderInsideRGB);
+ borderColor2 = new Color(getDisplay(), borderMiddleRGB);
+ borderColor3 = new Color(getDisplay(), borderOutsideRGB);
+ Color foreground = getForeground();
+ Color background = getBackground();
+
+ // create scrolling arrow buttons
+ scrollBar = new ToolBar(this, SWT.FLAT);
+ scrollBar.setVisible(false);
+ scrollLeft = new ToolItem(scrollBar, SWT.PUSH);
+ scrollLeft.setEnabled(false);
+ scrollRight = new ToolItem(scrollBar, SWT.PUSH);
+ scrollRight.setEnabled(false);
+ initScrollButtons(foreground, background);
+
+ // create close buttons
+ closeBar = new ToolBar(this, SWT.FLAT);
+ closeBar.setVisible(false);
+ closeItem = new ToolItem(closeBar, SWT.PUSH);
+ initCloseButton(foreground, background);
+
+ inactiveCloseBar = new ToolBar(this, SWT.FLAT);
+ inactiveCloseBar.setVisible(false);
+ inactiveCloseItem = new ToolItem(inactiveCloseBar, SWT.PUSH);
+ initInactiveCloseButton(foreground, background);
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ handleEvents(event);
+ }
+ };
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.MouseUp, listener);
+ addListener(SWT.MouseMove, listener);
+ addListener(SWT.MouseExit, listener);
+ addListener(SWT.Paint, listener);
+ addListener(SWT.Resize, listener);
+ scrollLeft.addListener(SWT.Selection, listener);
+ scrollRight.addListener(SWT.Selection, listener);
+ closeItem.addListener(SWT.Selection, listener);
+ inactiveCloseItem.addListener(SWT.Selection, listener);
+ inactiveCloseBar.addListener (SWT.MouseExit, listener);
+
+ setBorderVisible((style & SWT.BORDER) != 0);
+
+ // tool tip support
+ Display display = getDisplay();
+ tip = new Shell (getShell(), SWT.NONE);
+ tip.setLayout(new FillLayout());
+ Label label = new Label (tip, SWT.NONE);
+ label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
+ addMouseTrackListener (new MouseTrackAdapter () {
+ public void mouseExit(MouseEvent e) {
+ if (tip.isVisible()) tip.setVisible(false);
+ }
+ public void mouseHover(MouseEvent e) {
+ Point pt = new Point (e.x, e.y);
+ CTabItem item = getItem(pt);
+ if (item != null) {
+ String tooltip = item.getToolTipText();
+ if (tooltip != null) {
+ pt.y = (onBottom) ? pt.y - 26 : pt.y + 26;
+ pt = toDisplay(pt);
+ tip.setLocation(pt);
+ Label label = (Label) (tip.getChildren() [0]);
+ label.setText(tooltip);
+ tip.pack();
+ tip.setVisible(true);
+ return;
+ }
+ }
+
+ tip.setVisible(false);
+ }
+ });
+
+}
+private static int checkStyle (int style) {
+ int mask = SWT.TOP | SWT.BOTTOM | SWT.FLAT;
+ style = style & mask;
+ // TOP and BOTTOM are mutually exlusive.
+ // TOP is the default
+ if ((style & SWT.TOP) != 0)
+ style = style & ~(SWT.TOP | SWT.BOTTOM) | SWT.TOP;
+ // reduce the flash by not redrawing the entire area on a Resize event
+ style |= SWT.NO_REDRAW_RESIZE;
+ return style;
+}
+/**
+* Adds the listener to receive events.
+* +* +* @param listener the listener +* +* @exception SWTError
+* +* @param listener the listener +* +* @exception SWTError
+* +* @return the item at a point +* +* @exception SWTError
+ * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), + * display.getSystemColor(SWT.COLOR_BLUE), + * display.getSystemColor(SWT.COLOR_WHITE), + * display.getSystemColor(SWT.COLOR_WHITE)}, + * new int[] {25, 50, 100}); + *+ * + * @param colors an array of Color that specifies the colors to appear in the gradiant + * in order of appearance left to right. The value
null
clears the
+ * background gradiant. The value null
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.
+ */
+
+public void setSelectionBackground(Color[] colors, int[] percents) {
+ if (colors != null) {
+ if (percents == null || percents.length != colors.length - 1) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ for (int i = 0; i < percents.length; i++) {
+ if (percents[i] < 0 || percents[i] > 100) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (i > 0 && percents[i] < percents[i-1]) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+ }
+
+ // Are these settings the same as before?
+ if (gradientImage == null && gradientColors == null && colors == null) {
+ if (backgroundImage != null) {
+ backgroundImage = null;
+ redrawTabArea(selectedIndex);
+ }
+ return;
+ }
+ if (gradientColors != null && colors != null
+ && gradientColors.length == colors.length) {
+ boolean same = false;
+ for (int i = 0; i < gradientColors.length; i++) {
+ same = (gradientColors[i] == colors[i]);
+ if (!same) break;
+ }
+ if (same) {
+ for (int i = 0; i < gradientPercents.length; i++) {
+ same = gradientPercents[i] == percents[i];
+ if (!same) break;
+ }
+ }
+ if (same) return;
+ }
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ }
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+
+ Display display = getDisplay();
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ int start = 0;
+ int end = 0;
+ Color background = getBackground();
+ if (colors.length == 1) {
+ gc.setBackground(colors[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ for (int j = 0; j < colors.length - 1; j++) {
+ Color startColor = colors[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colors[j+1];
+ if (endColor == null) endColor = getBackground();
+ RGB rgb2 = endColor.getRGB();
+ start = end;
+ end = (width) * percents[j] / 100;
+ int range = Math.max(1, end - start);
+ for (int k = 0; k < (end - start); k++) {
+ int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;
+ r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);
+ int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;
+ g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);
+ int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;
+ b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);
+ Color color = new Color(display, r, g, b);
+ gc.setBackground(color);
+ gc.fillRectangle(start + k,y,1,height);
+ gc.setBackground(background);
+ color.dispose();
+ }
+ }
+ gc.dispose();
+ gradientImage = temp;
+ gradientColors = colors;
+ gradientPercents = percents;
+ backgroundImage = temp;
+
+ Color closeBackground = colors[colors.length - 1];
+ if (closeBackground == null){
+ closeBackground = background;
+ }
+ Color closeForeground = getForeground();
+ initCloseButton(closeForeground, closeBackground);
+ } else {
+ Color closeBackground = getBackground();
+ Color closeForeground = getForeground();
+ initCloseButton(closeForeground, closeBackground);
+ }
+ if (selectedIndex > -1) redrawTabArea(selectedIndex);
+}
+public void setSelectionBackground(Image image) {
+ if (image == backgroundImage) return;
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ }
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = image;
+ redrawTabArea(selectedIndex);
+}
+public void setBorderVisible(boolean show) {
+ if (showBorders == show) return;
+
+ showBorders = show;
+ if (showBorders) {
+ if ((getStyle() & SWT.FLAT) != 0) {
+ BORDER_BOTTOM = BORDER_TOP = BORDER_LEFT = BORDER_RIGHT = 1;
+ } else {
+ BORDER_LEFT = BORDER_TOP = 1;
+ BORDER_RIGHT = BORDER_BOTTOM = 3;
+ }
+ } else {
+ BORDER_BOTTOM = BORDER_TOP = BORDER_LEFT = BORDER_RIGHT = 0;
+ }
+ layoutItems();
+ redraw();
+}
+public void setFont(Font font) {
+ if (font != null && font.equals(getFont())) return;
+ super.setFont(font);
+ layoutItems();
+ redrawTabArea(-1);
+}
+public void setForeground (Color color) {
+ super.setForeground(color);
+ color = getForeground();
+ Color background = getBackground();
+
+ initInactiveCloseButton(color, background);
+ initScrollButtons(color, background);
+
+ if (gradientColors != null) {
+ background = gradientColors[gradientColors.length - 1];
+ }
+ initCloseButton(color, background);
+}
+public void setSelectionForeground (Color color) {
+ if (selectionForeground == color) return;
+ if (color == null) color = getForeground();
+ selectionForeground = color;
+ if (selectedIndex > -1) {
+ redrawTabArea(selectedIndex);
+ }
+}
+public void setInsertMark(CTabItem item, boolean after) {
+ int index = -1;
+ if (item != null) {
+ index = indexOf(item);
+ }
+ setInsertMark(index, after);
+}
+public void setInsertMark(int index, boolean after) {
+ if (index < -1 || index >= getItemCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if (index == -1) {
+ index = -2;
+ } else {
+ index = after ? index : --index;
+ }
+
+ if (insertionIndex == index) return;
+ int oldIndex = insertionIndex;
+ insertionIndex = index;
+ if (index > -1) redrawTabArea(index);
+ if (oldIndex > 1) redrawTabArea(oldIndex);
+}
+
+/**
+ * Set the selection to the tab at the specified index.
+ */
+public void setSelection(int index) {
+ if (index < 0 || index >= items.length)
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ if (selectedIndex == index) return;
+
+ if (showClose) {
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+
+ int oldIndex = selectedIndex;
+ selectedIndex = index;
+
+ Control control = items[index].control;
+ if (control != null && !control.isDisposed()) {
+ control.setBounds(getClientArea());
+ control.setVisible(true);
+ }
+
+ if (oldIndex != -1) {
+ control = items[oldIndex].control;
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ }
+ ensureVisible();
+
+ redrawTabArea(-1);
+}
+private void ensureVisible() {
+ // make sure item is visible
+ Rectangle area = super.getClientArea();
+ if (area.width == 0) return;
+ int areaWidth = area.x + area.width - BORDER_RIGHT;
+
+ CTabItem tabItem = items[selectedIndex];
+ if (selectedIndex < topTabIndex) {
+ topTabIndex = selectedIndex;
+ }
+ layoutItems();
+
+ int scrollWidth = scrollBar.getSize().x;
+ int width = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ width -= scrollWidth;
+ }
+ while (tabItem.x + tabItem.width > width && selectedIndex != topTabIndex) {
+ topTabIndex++;
+ layoutItems();
+ width = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ width -= scrollWidth;
+ }
+ }
+}
+/**
+ * Set the selection to the specified item.
+ */
+public void setSelection(CTabItem item) {
+ if (item == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int index = indexOf(item);
+ setSelection(index);
+}
+/**
+ * Set the selection to the tab at the specified index.
+ */
+private void setSelectionNotify(int index) {
+ int oldSelectedIndex = selectedIndex;
+ setSelection(index);
+ if (selectedIndex != oldSelectedIndex && selectedIndex != -1) {
+ Event event = new Event();
+ event.item = getItem(selectedIndex);
+ notifyListeners(SWT.Selection, event);
+ }
+}
+
+private void initCloseButton(Color foreground, Color background) {
+ if (closeImage != null) {
+ closeImage.dispose();
+ closeImage = null;
+ }
+ closeImage = drawCloseImage(foreground, background);
+ closeBar.setBackground(background);
+ closeBar.setForeground(foreground);
+ closeItem.setImage(closeImage);
+}
+private void initInactiveCloseButton(Color foreground, Color background) {
+ if (inactiveCloseImage != null) {
+ inactiveCloseImage.dispose();
+ inactiveCloseImage = null;
+ }
+ inactiveCloseImage = drawCloseImage(foreground, background);
+ inactiveCloseBar.setBackground(background);
+ inactiveCloseBar.setForeground(foreground);
+ inactiveCloseItem.setImage(inactiveCloseImage);
+}
+private Image drawCloseImage(Color foreground, Color background) {
+ Image image = new Image(getDisplay(), 9, 9);
+ GC gc = new GC(image);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 9, 9);
+ gc.setForeground(foreground);
+ for (int i = 0; i < 8; i++) {
+ gc.drawLine(i, i, i + 1, i);
+ gc.drawLine(7 - i, i, 8 - i, i);
+ }
+ gc.dispose();
+ return image;
+}
+private void initScrollButtons(Color foreground, Color background) {
+
+ scrollBar.setBackground(background);
+
+ Display display = getDisplay();
+ Color shadow = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ if (arrowLeftImage != null) {
+ arrowLeftImage.dispose();
+ arrowLeftImage = null;
+ }
+ if (arrowLeftDisabledImage != null) {
+ arrowLeftDisabledImage.dispose();
+ arrowLeftDisabledImage = null;
+ }
+ arrowLeftImage = drawArrowImage(foreground, background, true);
+ arrowLeftDisabledImage = drawArrowImage(shadow, background, true);
+ scrollLeft.setImage(arrowLeftImage);
+ scrollLeft.setDisabledImage(arrowLeftDisabledImage);
+ scrollLeft.setHotImage(arrowLeftImage);
+
+ if (arrowRightImage != null) {
+ arrowRightImage.dispose();
+ arrowRightImage = null;
+ }
+ if (arrowRightDisabledImage != null) {
+ arrowRightDisabledImage.dispose();
+ arrowRightDisabledImage = null;
+ }
+ arrowRightImage = drawArrowImage(foreground, background, false);
+ arrowRightDisabledImage = drawArrowImage(shadow, background, false);
+ scrollRight.setImage(arrowRightImage);
+ scrollRight.setDisabledImage(arrowRightDisabledImage);
+ scrollRight.setHotImage(arrowRightImage);
+}
+
+private Image drawArrowImage (Color foreground, Color background, boolean left) {
+ // create image for left button
+ int arrow[] = new int[6];
+ if (left) {
+ arrow[0] = 4; arrow[1] = 0;
+ arrow[2] = 0; arrow[3] = 4;
+ arrow[4] = 4; arrow[5] = 8;
+ } else {
+ arrow[0] = 0; arrow[1] = 0;
+ arrow[2] = 4; arrow[3] = 4;
+ arrow[4] = 0; arrow[5] = 8;
+ }
+
+ Image image = new Image(getDisplay(), 5, 9);
+ GC gc = new GC(image);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 5, 9);
+ gc.setBackground(foreground);
+ gc.fillPolygon(arrow);
+ gc.setBackground(background);
+ gc.dispose();
+
+ return image;
+}
+/**
+ * A mouse button was pressed down.
+ * If one of the tab scroll buttons was hit, scroll in the appropriate
+ * direction.
+ * If a tab was hit select the tab.
+ */
+private void onMouseUp(Event event) {
+ for (int i=0; i+* @return the control +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +*/ +public Control getControl () { + return control; +} +/** + * Answer the display of the receiver's parent widget. + */ +public Display getDisplay() { + if (parent == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED); + return parent.getDisplay(); +} +public Image getDisabledImage(){ + return disabledImage; +} +/** + * Return the parent of the CTabItem. + */ +public CTabFolder getParent () { + return parent; +} +/** + * Gets the tool tip text. + *
+ * @return the tool tip text. + * + * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) + * when called from the wrong thread + * @exception SWTError(ERROR_WIDGET_DISPOSED) + * when the widget has been disposed + */ +public String getToolTipText () { + return toolTipText; +} +private int imageHeight() { + int imageHeight = 0; + if (parent.getImageHeight() != -1) { + imageHeight = parent.getImageHeight(); + } else { + Image image = getImage(); + if (image != null) { + imageHeight = image.getBounds().height; + } + } + return imageHeight; +} +private int imageWidth() { + int imageWidth = 0; + Image image = getImage(); + if (image != null) { + imageWidth = image.getBounds().width; + } + return imageWidth; +} +/** + * Paint the receiver. + */ +void onPaint(GC gc, boolean isSelected) { + + if (width == 0 || height == 0) return; + + Display display = getDisplay(); + Color highlightShadow = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); + Color normalShadow = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); + + int index = parent.indexOf(this); + + if (isSelected) { + // draw a background image behind the text + if (parent.backgroundImage != null) { + if (index == parent.topTabIndex){ + Rectangle imageRect = parent.backgroundImage.getBounds(); + gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height, + x + 1, y, width - 3, height); + } else { + Rectangle imageRect = parent.backgroundImage.getBounds(); + gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height, + x + 2, y, width - 4, height); + } + } + + // draw tab lines + if (!parent.onBottom) { + gc.setForeground(normalShadow); + if (index != parent.topTabIndex) { + gc.drawLine(x + 1, y, x + 1, y); + gc.drawLine(x, y + 1, x, y + height - 2); + gc.drawLine(x, y + height - 1, x, y + height - 1); + } + gc.drawLine(x + width - 2, y, x + width - 2, y); + gc.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2); + gc.drawLine(x + width - 1, y + height - 1, x + width - 1, y + height - 1); + + gc.setForeground(highlightShadow); + if (index != parent.topTabIndex) { + gc.drawLine(x + 2, y, x + 2, y); + gc.drawLine(x + 1, y + 1, x + 1, y + height - 2); + gc.drawLine(x + 1, y + height - 1, x + 1, y + height - 1); + } else { + gc.drawLine(x, y, x, y + height - 1); + } + + gc.drawLine(x + width - 3, y, x + width - 3, y); + gc.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2); + gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1); + + // light line across top + if (index != parent.topTabIndex) { + gc.drawLine(x + 3, y, x + width - 4, y); + } else { + gc.drawLine(x + 1, y, x + width - 4, y); + } + } else { + gc.setForeground(normalShadow); + if (index != parent.topTabIndex) { + gc.drawLine(x, y, x, y); + gc.drawLine(x, y + 1, x, y + height - 2); + gc.drawLine(x + 1, y + height - 1, x + 1, y + height - 1); + } + gc.drawLine(x + width - 1, y, x + width - 1, y); + gc.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2); + gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1); + + gc.setForeground(highlightShadow); + if (index != parent.topTabIndex) { + gc.drawLine(x + 1, y, x + 1, y); + gc.drawLine(x + 1, y + 1, x + 1, y + height - 2); + gc.drawLine(x + 2, y + height - 1, x + 2, y + height - 1); + } else { + gc.drawLine(x, y, x, y + height - 1); + } + + gc.drawLine(x + width - 2, y, x + width - 2, y); + gc.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2); + gc.drawLine(x + width - 3, y + height - 1, x + width - 3, y + height - 1); + + // light line across top and bottom + if (index != parent.topTabIndex) { + gc.drawLine(x + 1, y, x + width - 2, y); + gc.drawLine(x + 2, y + height - 1, x + width - 4, y + height - 1); + } else { + gc.drawLine(x + 1, y, x + width - 2, y); + gc.drawLine(x + 1, y + height - 1, x + width - 4, y + height - 1); + } + } + } + + // draw Image + int xDraw = x + LEFT_MARGIN; + + Image image = getImage(); + if (!isSelected && image != null) { + Image temp = getDisabledImage(); + if (temp != null){ + image = temp; + } + } + if (image != null) { + Rectangle imageBounds = image.getBounds(); + int imageHeight = imageHeight(); + int imageY = y + (height - parent.getImageHeight()) / 2; + gc.drawImage(image, + imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, + xDraw, imageY, imageBounds.width, imageHeight); + xDraw += imageBounds.width + INTERNAL_SPACING; + } + + // draw Text + int textWidth = x + width - xDraw - RIGHT_MARGIN; + if (isSelected && parent.showClose) { + textWidth = x + width - xDraw - parent.closeBar.getSize().x - RIGHT_MARGIN; + } + String text = shortenText(gc, getText(), textWidth); + + if (isSelected && parent.selectionForeground != null) { + gc.setForeground(parent.selectionForeground); + } else { + gc.setForeground(parent.getForeground()); + } + int textY = y + (height - textHeight(gc)) / 2; + gc.drawString(text, xDraw, textY, true); + + gc.setForeground(parent.getForeground()); +} +private String shortenText(GC gc, String text, int width) { + if (gc.textExtent(text).x <= width) return text; + + int ellipseWidth = gc.textExtent(ellipsis).x; + int length = text.length(); + int end = length - 1; + while (end > 0) { + text = text.substring(0, end); + int l1 = gc.textExtent(text).x; + if (l1 + ellipseWidth <= width) { + return text + ellipsis; + } + end--; + } + return ""; +} +/** + * Answer the preferred height of the receiver for the GC. + */ +int preferredHeight(GC gc) { + return Math.max(textHeight(gc), imageHeight()) + TOP_MARGIN + BOTTOM_MARGIN; +} +/** + * Answer the preferred width of the receiver for the GC. + */ +int preferredWidth(GC gc) { + int tabWidth = LEFT_MARGIN + RIGHT_MARGIN; + Image image = getImage(); + if (image != null) tabWidth += imageWidth() + INTERNAL_SPACING; + tabWidth += textWidth(gc); + if (parent.showClose) tabWidth += parent.closeBar.getSize().x; + return tabWidth; +} +/** + * Sets the control. + *
+ * @param control the new control + * + * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) + * when called from the wrong thread + * @exception SWTError(ERROR_WIDGET_DISPOSED) + * when the widget has been disposed + */ +public void setControl (Control control) { + if (control != null && control.getParent() != parent) { + SWT.error (SWT.ERROR_INVALID_PARENT); + } + if (this.control != null && !this.control.isDisposed()) { + this.control.setVisible(false); + } + + this.control = control; + if (this.control != null) { + int index = parent.indexOf (this); + if (index == parent.getSelectionIndex ()){ + this.control.setBounds(parent.getClientArea ()); + this.control.setVisible(true); + } else { + this.control.setVisible(false); + } + } +} +/** + * Sets the image. + *
+ * @param image the new image (or null) + * + * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) + * when called from the wrong thread + * @exception SWTError(ERROR_WIDGET_DISPOSED) + * when the widget has been disposed + */ +public void setImage (Image image) { + Image oldImage = getImage(); + + super.setImage(image); + if (image == null || !image.equals(oldImage)) { + parent.itemChanged(this); + } +} +public void setDisabledImage (Image image) { + Image oldImage = getDisabledImage(); + + disabledImage = image; + if (disabledImage == null || !disabledImage.equals(oldImage)) { + parent.itemChanged(this); + } +} + +/** + * Set the widget text. + *
+ * This method sets the widget label. The label may include + * the mnemonic characters but must not contain line delimiters. + * + * @param string the new label for the widget + * + */ +public void setText (String string) { + String oldText = getText(); + + super.setText(string); + if (!string.equals(oldText)) { + parent.itemChanged(this); + } +} + +/** + * Sets the tool tip text. + *
+ * @param string the new tool tip text (or null) + * + * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) + * when called from the wrong thread + * @exception SWTError(ERROR_WIDGET_DISPOSED) + * when the widget has been disposed + */ +public void setToolTipText (String string) { + toolTipText = string; +} +/** + * Answer the text height. + */ +private int textHeight(GC gc) { + int textHeight = 0; + + if (isDisposed()) return textHeight; + + String text = getText(); + if (text != null) { + textHeight = gc.stringExtent(text).y; + } + return textHeight; +} +/** + * Answer the text width. + */ +private int textWidth(GC gc) { + int textWidth = 0; + + if (isDisposed()) return 0; + + String text = getText(); + if (text != null) { + textWidth = gc.stringExtent(text).x; + } + return textWidth; +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java new file mode 100755 index 0000000000..eb99ff6e53 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java @@ -0,0 +1,238 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; + +/** +* +* 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. +* +*
Here is an example of using a ControlEditor:
+*
+*
+*/
+public class ControlEditor {
+
+ /**
+ * Specifies how the editor should be aligned relative to the control. Allowed values
+ * are SWT.LEFT, SWT.RIGHT and SWT.CENTER. The default value is SWT.CENTER.
+ */
+ public int horizontalAlignment = SWT.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 boolean 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 minumum 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 SWT.TOP, SWT.BOTTOM and SWT.CENTER. The default value is SWT.CENTER.
+ */
+ public int verticalAlignment = SWT.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 boolean 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 minumum height value. The default value is 0.
+ */
+ public int minimumHeight = 0;
+
+ Composite parent;
+ Control editor;
+ private boolean hadFocus;
+ private Listener internalListener;
+/**
+* Creates a ControlEditor for the specified Composite.
+*
+* @param parent the Composite above which this editor will be displayed
+*
+*/
+public ControlEditor (Composite parent) {
+ this.parent = parent;
+
+ internalListener = new Listener() {
+ public void handleEvent(Event e) {
+ if (e.widget instanceof ScrollBar && e.type == SWT.Selection)
+ scroll (e);
+ else if (e.type == SWT.Resize)
+ resize ();
+ }
+ };
+
+ parent.addListener (SWT.Resize, internalListener);
+
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.addListener (SWT.Selection, internalListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.addListener (SWT.Selection, internalListener);
+}
+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 SWT.RIGHT:
+ editorRect.x += clientArea.width - editorRect.width;
+ break;
+ case SWT.LEFT:
+ // do nothing - clientArea.x is the right answer
+ break;
+ default:
+ // default is CENTER
+ editorRect.x += (clientArea.width - editorRect.width)/2;
+ }
+
+ switch (verticalAlignment) {
+ case SWT.BOTTOM:
+ editorRect.y += clientArea.height - editorRect.height;
+ break;
+ case SWT.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 not disposed.
+ */
+public void dispose () {
+
+ if (!parent.isDisposed()) {
+ parent.removeListener (SWT.Resize, internalListener);
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.removeListener (SWT.Selection, internalListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.removeListener (SWT.Selection, internalListener);
+ }
+
+ parent = null;
+ editor = null;
+ hadFocus = false;
+ internalListener = 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;
+}
+void resize () {
+ if (editor == 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) editor.setFocus ();
+}
+void scroll (Event e) {
+ if (editor == null || editor.isDisposed()) return;
+ if (editor.getVisible ()) {
+ hadFocus = editor.isFocusControl();
+ }
+ boolean visible = e.detail != SWT.DRAG;
+ if (visible) {
+ editor.setBounds (computeBounds ());
+ }
+ editor.setVisible (visible);
+ if (visible && hadFocus) editor.setFocus ();
+}
+/**
+* Specify the Control that is to be displayed.
+*
+*
+* Canvas canvas = new Canvas(shell, SWT.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, SWT.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 != null) {
+* if (color != null) color.dispose();
+* color = new Color(null, rgb);
+* canvas.setBackground(color);
+* }
+*
+* }
+* });
+*
+* editor.horizontalAlignment = SWT.RIGHT;
+* editor.verticalAlignment = SWT.BOTTOM;
+* editor.grabHorizontal = false;
+* editor.grabVertical = false;
+* Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+* editor.minimumWidth = size.x;
+* editor.minimumHeight = size.y;
+* editor.setEditor (button);
+*
Note: The Control provided as the editor must 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 == 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;
+
+ editor.setVisible (false);
+ editor.setBounds (computeBounds ());
+ editor.setVisible (true);
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
new file mode 100755
index 0000000000..0469aa577c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
@@ -0,0 +1,797 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import java.io.*;
+import java.util.*;
+
+class DefaultContent implements 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
+ *
+ * @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 == size) {
+ // expand the lines by powers of 2
+ int[][] newLines = new int[size+(int)Math.pow(2, 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
+ *
+ * @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 == size) {
+ newLines = new int[size+(int)Math.pow(2, replaceExpandExp)][2];
+ replaceExpandExp++;
+ System.arraycopy(linesArray, 0, newLines, 0, size);
+ }
+ int[] range = new int[] {start, length};
+ newLines[count] = range;
+ return newLines;
+}
+/**
+ * Adds
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException
+ *
+ * @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 == gapStart) {
+ // text is being inserted at the gap position
+ int size = (gapEnd - gapStart) - sizeHint;
+ if (lowWatermark <= size && size <= highWatermark)
+ return;
+ } else if ((position + sizeHint == 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
+ *
+ * @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 lineCnt = 0;
+ int i;
+ replaceExpandExp = 1;
+ for (i=start; i
+ *
+ * @param position the position at which to insert the text
+ * @param length the text to insert
+ */
+void insert(int position, String text) {
+ if (text.length() == 0) return;
+
+ int startLine = getLineAtOffset(position);
+ int change = text.length();
+ boolean endInsert = position == 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] == 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
+ *
+ * @param index the index of the line to return
+ * @return the logical line text (i.e., without the gap)
+ * @exception IllegalArgumentException
+ *
+ * @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.
+ *
+ * @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 buf = new StringBuffer();
+ int gapLength = gapEnd - gapStart;
+ buf.append(textStore, start, gapStart - start);
+ buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+ return buf.toString();
+ }
+}
+/**
+ * Returns the physical line at the given index (i.e., with delimiters and the gap).
+ *
+ *
+ * @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.
+ *
+ *
+ * @param charPosition logical character offset (i.e., does not include gap)
+ * @return the line index
+ * @exception IllegalArgumentException
+ *
+ * @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.
+ *
+ *
+ * @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
+ *
+ * @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 SWT error.
+ *
+ *
+ * @param code the error code
+ */
+void error (int code) {
+ SWT.error(code);
+}
+/**
+ * Returns whether or not a gap exists in the text store.
+ *
+ *
+ * @return true if gap exists, false otherwise
+ */
+boolean gapExists() {
+ return gapStart != gapEnd;
+}
+
+/**
+ * Returns a string representing the continous content of
+ * the text store.
+ *
+ *
+ * @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).
+ *
+ *
+ * @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 == null)
+ return "";
+ if (length == 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 text changed listener.
+ *
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException 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.
+ *
starting at position lineCount
is updated to reflect the new entry.
+ * linesArray
. Increases the
+ * size of the array if necessary and returns a new array.
+ * TextChangedEvent
listener. A TextChangedEvent
is sent
+ * when changes to the textStore occur.
+ *
+ *
+ */
+public void addTextChangedListener(TextChangedListener listener) {
+ if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ textListeners.addElement(typedListener);
+}
+/**
+ * Adjusts the gap to accomodate a text change that is occurring.
+ * index
without delimiters.
+ *
+ *
+ */
+public String getLine(int index) {
+ if ((index >= lineCount) || (index < 0)) error(SWT.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.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 StyledTextContent
interface.
+ *
+ *
+ */
+public int getLineAtOffset(int charPosition){
+ int position;
+ if ((charPosition > getCharCount()) || (charPosition < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 == 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.
+ *
+ *
+ */
+public int getOffsetAtLine(int lineIndex) {
+ if (lineIndex == 0) return 0;
+ if ((lineIndex >= lineCount) || (lineIndex < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+ int start = lines[lineIndex][0];
+ if (start > gapEnd) {
+ return start - (gapEnd - gapStart);
+ } else {
+ return start;
+ }
+}
+/**
+ * Increases the line indexes array to accomodate more lines.
+ *
+ *
+ */
+public void removeTextChangedListener(TextChangedListener listener){
+ if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; istart
+ * for a length of replaceLength
. Notifies the appropriate listeners.
+ *
+ *
+ * When sending the TextChangedEvent, numNewLines
is the number of
+ * inserted lines and numReplacedLines
is the number of deleted lines based
+ * on the change that occurs visually. For example:
+ *
+ * @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 == 0) return; + + int startLine = getLineAtOffset(position); + int startLineOffset = getOffsetAtLine(startLine); + int endLine = getLineAtOffset(position + length); + + String endText = ""; + boolean splittingDelimiter = false; + if (position + length < getCharCount()) { + endText = getTextRange(position + length - 1, 2); + if ((endText.charAt(0) == SWT.CR) && (endText.charAt(1) == SWT.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 == gapStart) { + gapStart -= length; + } else { + gapEnd += length; + } + + // figure out the length of the new concatenated line, do so by + // finding the first line delmiter after position + int j = position; + boolean 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 == SWT.CR && (textStore[j+1] == SWT.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); +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java new file mode 100755 index 0000000000..d6eaac6976 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java @@ -0,0 +1,599 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import java.util.*; + +class DefaultLineStyler implements LineStyleListener, LineBackgroundListener { + StyledTextContent content; + StyleRange styles[] = new StyleRange[0]; + int styleCount = 0; // the number of styles + int styleExpandExp = 1; // the expansion exponent, used to increase the styles array exponentially + int lineExpandExp = 1; // the expansion exponent, used to increase the lines array exponentially + int lineCount = 0; + Color lineBackgrounds[]; + +/** + * Creates a new default line styler. + *
+ * + * @param content the text to which the styles apply + */ +public DefaultLineStyler(StyledTextContent content) { + this.content = content; + lineCount = content.getLineCount(); + lineBackgrounds = new Color[lineCount]; +} +/** + * Inserts a style at the given location. + *
+ * + * @param style the new style + * @param index the index at which to insert the style (the new style + * will reside at this index) + * + */ +void insertStyle(StyleRange style, int index) { + int size = styles.length; + if (styleCount == size) { + // expand the styles array by powers of 2 + StyleRange[] newStyles = new StyleRange[size+(int)Math.pow(2, styleExpandExp)]; + System.arraycopy(styles, 0, newStyles, 0, size); + styles = newStyles; + styleExpandExp++; + } + // shift the styles down to make room for the new style + for (int i=styleCount-1; i>=index; i--) { + styles[i+1]=styles[i]; + } + styles[index] = style; + styleCount++; +} +/** + * Inserts a style, merging it with adjacent styles if possible. + *
+ * + * @param style the new style + * @param index the index at which to insert the style (the new style + * will reside at this index) + * @return true if the style was inserted, false if the style was merged with an adjacent + * style + */ +boolean insertMergeStyle(StyleRange style, int index) { + if (mergeStyleBefore(style, index)) return false; + if (mergeStyleAfter(style, index)) return false; + insertStyle(style, index); + return true; +} +/** + * Merges the style with the style before it if possible. + *
+ * + * @param style the new style + * @param index the index at which to attempt the merge. + * @return true if the style was merged, false otherwise + */ +boolean mergeStyleBefore(StyleRange style, int index) { + // see if the style is similar to the style before it and merge the + // styles if possible + if (index > 0) { + StyleRange previous = styles[index-1]; + if (style.similarTo(previous)) { + // the start of style needs to be in the range of the previous style + // and the end of style needs to be < the start of the next style + int previousEnd = previous.start + previous.length; + if ((style.start <= previousEnd) && (style.start >= previous.start)) { + int styleEnd = style.start + style.length; + if ((index == styleCount) || (styleEnd <= styles[index].start)) { + previous.length = style.start + style.length - previous.start; + return true; + } + } + } + } + return false; +} +/** + * Merges the style with the style after it if possible. + *
+ *
+ * @param style the new style
+ * @param index the index at which to attempt the merge.
+ * @return true if the style was merged, false otherwise
+ */
+boolean mergeStyleAfter(StyleRange style, int index) {
+ // see if the style is similar to the style that will be after it and
+ // merge the styles if possible
+ if (index < styleCount) {
+ StyleRange next = styles[index];
+ if (style.similarTo(next)) {
+ // the end of style needs to be in the range of the next style and
+ // the start of style needs to be > the end of the previous style
+ int styleEnd = style.start + style.length;
+ int nextEnd = next.start + next.length;
+ if ((styleEnd <= nextEnd) && (styleEnd >= next.start)) {
+ if ((index == 0) || (style.start >= styles[index-1].start + styles[index-1].length)) {
+ next.length = next.start + next.length - style.start;
+ next.start = style.start;
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+/**
+ * Removes style information that is defined for the range of text in clearStyle
.
+ *
+ *
+ * @param clearStyle the style information to use for clearing
+ */
+void clearStyle(StyleRange clearStyle) {
+ Point pt = getOverlappingStyles(clearStyle.start, clearStyle.length);
+ int clearStyleEnd = clearStyle.start + clearStyle.length - 1;
+
+ // no overlapped styles exist
+ if ((pt == null) || (pt.y == 0)) return;
+
+ // the newStyle overlaps one or more of the existing styles
+ // pt.x is the index of the first overlapped style, pt.y is the number of overlapped
+ // styles
+ int count = 0;
+ for (int i=pt.x; count
+ *
+ * @param numLines the number to increase the array by
+ */
+void expandLinesBy(int numLines) {
+ int size = lineBackgrounds.length;
+ if (size - lineCount >= numLines) {
+ return;
+ }
+ Color[] newLines = new Color[size+Math.max((int)Math.pow(2, lineExpandExp), numLines)];
+ System.arraycopy(lineBackgrounds, 0, newLines, 0, size);
+ lineBackgrounds = newLines;
+ lineExpandExp++;
+}
+/**
+ * Deletes the style at
+ *
+ * @param index the index of the style to be deleted
+ */
+void deleteStyle(int index) {
+ // move the styles up
+ for (int i=index+1; i
+ *
+ * @param event.lineOffset line number (input)
+ * @param event.lineText line text (input)
+ * @param event.background line background color (output)
+ */
+public void lineGetBackground(LineBackgroundEvent event) {
+ event.lineBackground = lineBackgrounds[content.getLineAtOffset(event.lineOffset)];
+}
+/**
+ * Handles the get line style information callback.
+ *
+ *
+ * @param event.lineOffset line number (input)
+ * @param event.lineText line text (input)
+ * @param event.styles array of StyleRanges, need to be in order (output)
+ */
+public void lineGetStyle(LineStyleEvent event) {
+ int lineStart = event.lineOffset;
+ int lineEnd = lineStart + event.lineText.length();
+
+ int high = searchForStyle(lineStart, lineEnd);
+ StyleRange style = null;
+ Vector lineStyles = new Vector();
+
+ // index will represent a style that
+ // -- starts after the line (end processing)
+ // -- ends before the line (continue processing)
+ // -- starts before the line, ends in the line (add range)
+ // -- starts in the line, ends in the line (add range)
+ // -- starts in the line, ends after the line (add range)
+ // -- starts before the line, ends after the line (add range)
+ for (int index = high; index < styleCount; index++) {
+ style = styles[index];
+ if (style.start > lineEnd)
+ // style starts after the line, end looping
+ break;
+ int styleEnd = style.start + style.length - 1;
+ if (styleEnd >= lineStart) lineStyles.add(style);
+ }
+ event.styles = new StyleRange[lineStyles.size()];
+ lineStyles.copyInto(event.styles);
+}
+/**
+ * Searches for the first style in the
+ *
+ * @return the index of the first style that overlaps the input range
+ */
+int searchForStyle(int start, int end) {
+ int high = styleCount;
+ int low = -1;
+ int index = high;
+ // find the index of the first style for the given range, use a binary search
+ while (high - low > 1) {
+ index = (high + low) / 2;
+ StyleRange style = styles[index];
+ int styleEnd = style.start + style.length - 1;
+ if (start <= style.start || end <= styleEnd || (start > style.start && styleEnd >= start && styleEnd < end)) {
+ high = index;
+ }
+ else {
+ low = index;
+ }
+ }
+ return high;
+}
+/**
+ * Updates the line background colors to reflect a new color. Called by StyledText.
+ *
+ *
+ * @param startLine index of the first line to color
+ * @param lineCount number of lines to color starting at startLine
+ * @param background the background color for the lines
+ */
+void setLineBackground(int startLine, int count, Color background) {
+ for (int i=startLine; i
+ *
+ * @param newStyle the new style information.
+ */
+void setStyleRange(StyleRange newStyle) {
+ if (newStyle == null) {
+ styles = new StyleRange[0];
+ styleExpandExp = 1;
+ styleCount = 0;
+ return;
+ }
+ if (newStyle.length ==0) return;
+ if (newStyle.isUnstyled()) {
+ clearStyle(newStyle);
+ return;
+ }
+
+ Point pt = getOverlappingStyles(newStyle.start, newStyle.length);
+ int newStyleEnd = newStyle.start + newStyle.length - 1;
+
+ // no styles exist
+ if (pt == null) {
+ insertStyle(newStyle, 0);
+ return;
+ }
+
+ // newStyle does not overlap any other styles
+ if (pt.y == 0) {
+ insertMergeStyle(newStyle, pt.x);
+ return;
+ }
+
+ // the newStyle overlaps one or more of the existing styles
+ boolean added = false; // indicates whether or not the new style has been added
+ int count = 0;
+ // pt.x is the index of the first overlapped style, pt.y is the number of overlapped
+ // styles
+ for (int i=pt.x; count
+ *
+ * @param event the event with the text change information
+ */
+public void textChanged(TextChangedEvent event) {
+ int startLine = content.getLineAtOffset(event.start);
+ int startLineOffset = content.getOffsetAtLine(startLine);
+
+ textChanged(event.start, -event.replacedCharCount);
+ textChanged(event.start, event.newCharCount);
+
+ if (event.newCharCount == content.getCharCount()) {
+ // all text replaced, clear line backgrounds
+ linesChanged(0, -lineCount);
+ linesChanged(0, content.getLineCount());
+ return;
+ }
+
+ if (event.start != startLineOffset) {
+ startLine = startLine + 1;
+ }
+
+ linesChanged(startLine, -event.replacedLineCount);
+ linesChanged(startLine, event.newLineCount);
+}
+/*
+ * Updates the line backgrounds to reflect a text change.
+ *
+ *
+ * @param start the starting line of the change that took place
+ * @param delta the number of lines in the change, > 0 indicates lines inserted,
+ * < 0 indicates lines deleted
+ */
+void linesChanged(int start, int delta) {
+ if (delta == 0) return;
+ boolean inserting = delta > 0;
+ if (inserting) {
+ // shift the lines down to make room for new lines
+ expandLinesBy(delta);
+ for (int i = lineCount-1; i >= start; i--) {
+ lineBackgrounds[i + delta]=lineBackgrounds[i];
+ }
+ for (int i=start; i
+ *
+ * @return Point where x is the index of the starting overlap style, y is the number of
+ * styles that overlap the range
+ */
+Point getOverlappingStyles(int start, int length) {
+ StyleRange style;
+ if (styleCount == 0) return null;
+ // find the index of the first style for the given offset, use a binary search
+ // to find the index
+ int end = start + length - 1;
+ int high = searchForStyle(start, end);
+ int count = 0;
+ for (int index = high; index < styleCount; index++) {
+ style = styles[index];
+ int styleEnd = style.start + style.length - 1;
+ if (style.start > end) break;
+ if (styleEnd >= start) count++;
+ }
+ return new Point(high, count);
+}
+/**
+ * Returns the background color of a line. Called by StyledText. It is safe to return
+ * the existing Color object since the colors are set and managed by the client.
+ *
+ *
+ * @param index the line index
+ * @return the background color of the line at the given index
+ */
+Color getLineBackground(int index) {
+ return lineBackgrounds[index];
+}
+/**
+ * Returns the style for the character at
+ *
+ * @param offset the character position in the text
+ * @return a cloned StyleRange with start == offset and length == 1 if a style is
+ * specified or null if no style is specified
+ */
+StyleRange getStyleRangeAtOffset(int offset) {
+ if (styleCount == 0) return null;
+ Point pt = getOverlappingStyles(offset, 1);
+ if (pt == null || pt.y == 0) return null;
+ StyleRange newStyle = (StyleRange)styles[pt.x].clone();
+ newStyle.start = offset;
+ newStyle.length = 1;
+ return newStyle;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java
new file mode 100755
index 0000000000..26fd9c9473
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent after a text change occurs.
+ */
+public final class ExtendedModifyEvent extends TypedEvent {
+ public int start; // start offset of the new text
+ public int length; // length of the new text
+ public String replacedText; // replaced text or empty string if no text was replaced
+
+public ExtendedModifyEvent(StyledTextEvent e) {
+ super(e);
+ start = e.start;
+ length = e.end - e.start;
+ replacedText = e.text;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java
new file mode 100755
index 0000000000..5300f6da2d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import java.util.EventListener;
+
+public interface ExtendedModifyListener extends EventListener {
+/**
+ * This method is called after a text change occurs.
+ *
+ *
+ * @param event.start the start offset of the new text (input)
+ * @param event.length the length of the new text (input)
+ * @param event.replacedText the replaced text (input)
+ */
+public void modifyText(ExtendedModifyEvent event);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java
new file mode 100755
index 0000000000..fecd8742eb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineBackgroundEvent extends TypedEvent {
+ public int lineOffset; // line start offset
+ public String lineText; // line text
+ public Color lineBackground; // line background color
+
+public LineBackgroundEvent(StyledTextEvent e) {
+ super(e);
+ lineOffset = e.detail;
+ lineText = e.text;
+}
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java
new file mode 100755
index 0000000000..7ea0deeb24
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+
+/* Imports */
+import java.util.*;
+
+
+public interface LineBackgroundListener extends EventListener {
+
+/**
+ * This method is called when a line is about to be drawn in order to get its
+ * background color.
+ *
+ *
+ * @param event.lineOffset line start offset (input)
+ * @param event.lineText line text (input)
+ * @param event.lineBackground line background color (output)
+ */
+public void lineGetBackground(LineBackgroundEvent event);
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java
new file mode 100755
index 0000000000..0bac2326a3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineStyleEvent extends TypedEvent {
+ public int lineOffset; // line start offset
+ public String lineText; // line text
+ public StyleRange[] styles; // array of StyleRanges
+
+public LineStyleEvent(StyledTextEvent e) {
+ super(e);
+ lineOffset = e.detail;
+ lineText = e.text;
+ styles = e.styles;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java
new file mode 100755
index 0000000000..6ece0586e5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import java.util.*;
+
+public interface LineStyleListener extends EventListener {
+/**
+ * This method is called when a line is about to be drawn in order to get the
+ * line's style information.
+ *
+ *
+ * @param event.lineOffset line start offset (input)
+ * @param event.lineText line text (input)
+ * @param event.styles array of StyleRanges, need to be in order (output)
+ */
+public void lineGetStyle(LineStyleEvent event);
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java
new file mode 100755
index 0000000000..f03c817c1c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java
@@ -0,0 +1,249 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+/**
+* A PopupList is a list of selectable items that appears in its own shell positioned above
+* its parent shell. It it 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 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 {
+ private Shell shell;
+ private List list;
+ private int minimumWidth;
+/**
+* Creates a PopupList above the specified shell.
+*/
+public PopupList(Shell parent) {
+
+ shell = new Shell(parent, 0);
+
+ list = new List(shell, SWT.SINGLE | SWT.V_SCROLL);
+
+ // close dialog if user selects outside of the shell
+ shell.addListener(SWT.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 == '\r'){
+ shell.setVisible (false);
+ }
+ };
+ });
+
+}
+/**
+* Gets the widget font.
+*
+* @return the widget font
+*
+* @exception SWTError
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception SWTError
+* 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 SWTError
+* When new font is null, the font reverts
+* to the default system font for the widget.
+*
+* @param font the new font (or null)
+*
+* @exception SWTError
+* The previous selection is cleared.
+* The previous items are deleted.
+* The new items are added.
+* The top index is set to 0.
+*
+* @param items the array of items
+*
+* This operation will fail when an item is null
+* or could not be added in the OS.
+*
+* @exception SWTError
+ * If the ScrolledComposite can be configured to stretch the content to be as big as the
+ * ScrolledComposite when the composite is resized to a size larger than the minimum width
+ * or minimum height and to provide scrolls when the ScrolledComposite is smaller than the
+ * minimum width and minimum height. Refer to the methods setExpandHorizontal,
+ * setExpandVertical, setMinWidth and setMinHeight.
+ *
+ *
+ *
+ *
+ * @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) {
+ this.start = start;
+ this.length = length;
+ this.foreground = foreground;
+ this.background = background;
+}
+
+/**
+ * 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 SWT.NORMAL or SWT.BOLD
+ */
+public StyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
+ this.start = start;
+ this.length = length;
+ this.foreground = foreground;
+ this.background = background;
+ this.fontStyle = fontStyle;
+}
+
+/**
+ * Compare the specified object to this StyleRange and answer if the two
+ * are equal. The object must be an instance of StyleRange and have the
+ * same field values.
+ *
+ *
+ * @param object the object to compare with this object
+ * @return true if the objects are equal, false otherwise
+ */
+public boolean equals(Object object) {
+ StyleRange style;
+ if (object == this) return true;
+ if (object instanceof StyleRange) style = (StyleRange)object;
+ else return false;
+ if (this.start != style.start) return false;
+ if (this.length != style.length) return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground)) return false;
+ } else if (style.foreground != null) return false;
+ if (this.background != null) {
+ if (!this.background.equals(style.background)) return false;
+ } else if (style.background != null) return false;
+ if (this.fontStyle != style.fontStyle) return false;
+ return true;
+}
+/**
+ * Returns an integer hash code for the receiver. Objects which are
+ * equal answer the same value for this method.
+ *
+ *
+ * @return the receiver's hash
+ */
+public int hashCode() {
+ return start + length + foreground.hashCode() + background.hashCode() + fontStyle;
+}
+/**
+ * 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 boolean isUnstyled() {
+ if (this.foreground != null) return false;
+ if (this.background != null) return false;
+ if (this.fontStyle != SWT.NORMAL) 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 object the object to compare with this object
+ * @return true if the objects are similar, false otherwise
+ */
+public boolean similarTo(StyleRange style) {
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground)) return false;
+ } else if (style.foreground != null) return false;
+ if (this.background != null) {
+ if (!this.background.equals(style.background)) return false;
+ } else if (style.background != null) return false;
+ if (this.fontStyle != style.fontStyle) return false;
+ return true;
+}
+/**
+ * Answers a new StyleRange with the same values as this StyleRange.
+ *
+ *
+ * @return a shallow copy of this StyleRange
+ */
+public Object clone() {
+ StyleRange style = new StyleRange(start, length, foreground, background, fontStyle);
+ return style;
+}
+/**
+ * Answers a string description of the receiver.
+ *
+ *
+ * @return a printable representation for the receiver.
+ */
+public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(start + "," + length + " fg:" + foreground + " bg:" + background + " fStyle:");
+ if (fontStyle == SWT.NORMAL) {
+ buf.append("normal");
+ } else if (fontStyle == SWT.BOLD) {
+ buf.append("bold");
+ }
+ return buf.toString();
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
new file mode 100755
index 0000000000..b6f2c2ecda
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -0,0 +1,5426 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+
+/**
+ * A StyledText is an editable user interface object that displays lines
+ * of text. The following style attributes can be defined for the text:
+ *
+ * In addition to text style attributes, the background color of a line may
+ * be specified.
+ *
+ * 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:
+ *
+ * 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:
+ *
+ * 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.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ * toString() is guaranteed to return a valid RTF string only after
+ * close() has been called.
+ *
+ * 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.
+ *
+ *
+ * @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.addElement(getForeground());
+ colorTable.addElement(getBackground());
+ }
+ /**
+ * Closes the RTF writer. Once closed no more content can be written.
+ * NOTE:
+ *
+ * @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) {
+ int index;
+
+ if (color == null) {
+ index = defaultIndex;
+ }
+ else {
+ index = colorTable.indexOf(color);
+ if (index == -1) {
+ index = colorTable.size();
+ colorTable.addElement(color);
+ }
+ }
+ return index;
+ }
+ /**
+ * 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\\deff0{\\fonttbl{\\f0\\fnil ");
+ header.append(fontData.getName());
+ 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 SWTException
+ *
+ * @param lineDelimiter line delimiter to write as RTF.
+ * @exception SWTException
+ *
+ * @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) {
+ int index;
+
+ for (index = start; index < end; index++) {
+ char c = string.charAt(index);
+ if (c == '}' || c == '{' || c == '\\') {
+ break;
+ }
+ }
+ if (index == end) {
+ write(string.substring(start, end)); // string doesn't contain RTF formatting characters, write as is
+ }
+ else { // string needs to be transformed
+ char[] text = new char[end - start];
+
+ string.getChars(start, end, text, 0);
+ for (index = 0; index < text.length; index++) {
+ switch (text[index]) {
+ case '}':
+ case '{':
+ case '\\':
+ write("\\");
+ default:
+ write(text[index]);
+ }
+ }
+ }
+ }
+ /**
+ * Appends the specified line text to the RTF data.
+ * 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).
+ *
+ *
+ * @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, StyleRange[] styles, Color lineBackground) {
+ int lineLength = line.length();
+ int lineIndex;
+ int copyEnd;
+ int startOffset = getStart();
+ int endOffset = startOffset + super.getCharCount();
+ int writeOffset = startOffset - lineOffset;
+
+ if (writeOffset >= line.length()) {
+ return; // whole line is outside write range
+ }
+ else
+ if (writeOffset > 0) {
+ lineIndex = writeOffset; // line starts before RTF write start
+ }
+ else {
+ lineIndex = 0;
+ }
+ if (lineBackground != null) {
+ write("{\\highlight");
+ write(getColorIndex(lineBackground, DEFAULT_BACKGROUND));
+ write(" ");
+ }
+ for (int i = 0; i < styles.length; i++) {
+ StyleRange style = styles[i];
+ int start = style.start - lineOffset;
+ int end = start + style.length;
+ int colorIndex;
+ // skip over partial first line
+ if (end < writeOffset) {
+ continue;
+ }
+ // break on partial last line
+ if (style.start > endOffset) {
+ break;
+ }
+ // write any unstyled text
+ if (lineIndex < start) {
+ // copy to start of style or end of write range (specified
+ // during object creation) or end of line
+ copyEnd = Math.min(start, endOffset - lineOffset);
+ copyEnd = Math.min(copyEnd, lineLength);
+ write(line, lineIndex, copyEnd);
+ lineIndex = copyEnd;
+ if (copyEnd != start) {
+ break;
+ }
+ }
+ // write styled text
+ colorIndex = getColorIndex(style.background, DEFAULT_BACKGROUND);
+ write("{\\cf");
+ write(getColorIndex(style.foreground, DEFAULT_FOREGROUND));
+ if (colorIndex != DEFAULT_BACKGROUND) {
+ write("\\highlight");
+ write(colorIndex);
+ }
+ if (style.fontStyle == SWT.BOLD) {
+ write("\\b");
+ }
+ write(" ");
+ // copy to end of style or end of write range (specified
+ // during object creation) or end of line
+ copyEnd = Math.min(end, endOffset - lineOffset);
+ copyEnd = Math.min(copyEnd, lineLength);
+ write(line, lineIndex, copyEnd);
+ if (style.fontStyle == SWT.BOLD) {
+ write("\\b0");
+ }
+ write("}");
+ lineIndex = copyEnd;
+ if (copyEnd != end) {
+ break;
+ }
+ }
+ copyEnd = Math.min(lineLength, endOffset - lineOffset);
+ if (lineIndex < copyEnd) {
+ write(line, lineIndex, copyEnd);
+ }
+ if (lineBackground != null) {
+ write("}");
+ }
+ }
+ }
+ /**
+ * The
+ * NOTE:
+ *
+ * @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.
+ * NOTE:
+ *
+ * @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.
+ * Do nothing if "offset" is < 0 or > getCharCount()
+ *
+ *
+ * @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 SWTException
+ *
+ * @param lineDelimiter line delimiter to write
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param key a key code defined in SWT.java or a character.
+ * Optionally ORd with a state mask (one or more of SWT.CTRL, SWT.SHIFT, SWT.ALT)
+ * @param action one of the predefined actions defined in ST.java.
+ * Use SWT.NULL to remove a key binding.
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param listener the listener
+ * @exception SWTException
+ *
+ * @param string the string to be appended
+ * @see #replaceTextRange(int,int,String)
+ * @exception SWTException
+ *
+ * @param startline the first line
+ * @param lineCount number of lines to consider for the calculation
+ * @param skipCalculated true=don't recalculated lines that have already been calculated
+ */
+void calculateContentWidth(int startLine, int lineCount) {
+ String line;
+ GC gc = new GC(this);
+ FontData fontData = gc.getFont().getFontData()[0];
+ int stopLine;
+
+ if (lineCount < 0) {
+ startLine += lineCount;
+ lineCount *= -1;
+ }
+ stopLine = startLine + lineCount;
+ setLineFont(gc, fontData, SWT.BOLD);
+ for (int i = startLine; i < stopLine; i++) {
+ line = content.getLine(i);
+ contentWidth = Math.max(contentWidth(line, i, gc) + CARET_WIDTH, contentWidth);
+ }
+ gc.dispose();
+}
+
+/**
+ * Calculates the line height
+ */
+void calculateLineHeight() {
+ GC gc = new GC(this);
+ lineHeight = gc.getFontMetrics().getHeight();
+ gc.dispose();
+}
+
+/**
+ * Calculates the width in pixel of a tab character
+ */
+void calculateTabWidth() {
+ StringBuffer tabBuffer = new StringBuffer(tabLength);
+ GC gc = new GC(this);
+
+ for (int i = 0; i < tabLength; i++) {
+ tabBuffer.append(' ');
+ }
+ tabWidth = gc.stringExtent(tabBuffer.toString()).x;
+ gc.dispose();
+}
+
+/**
+ * Calculates the scroll bars
+ */
+void calculateScrollBars() {
+ ScrollBar horizontalBar = getHorizontalBar();
+ ScrollBar verticalBar = getVerticalBar();
+
+ setScrollBars();
+ if (verticalBar != null) {
+ verticalBar.setIncrement(getVerticalIncrement());
+ }
+ if (horizontalBar != null) {
+ horizontalBar.setIncrement(getHorizontalIncrement());
+ }
+}
+
+/**
+ * Hides the scroll bars if widget is created in single line mode.
+ */
+static int checkStyle(int style) {
+ if ((style & SWT.SINGLE) != 0) {
+ style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ }
+ return style;
+}
+
+/**
+ * Scrolls down the text to use new space made available by a resize or by
+ * deleted lines.
+ */
+void claimBottomFreeSpace() {
+ int clientAreaItemCount = getLineCountWhole();
+ int topIndex = getTopIndex();
+ int newTopIndex;
+ int lastItemIndex = content.getLineCount() - topIndex;
+
+ if (topIndex > 0 &&
+ lastItemIndex > 0 &&
+ lastItemIndex < clientAreaItemCount) {
+ newTopIndex = Math.max(0, topIndex - (clientAreaItemCount - lastItemIndex));
+ setTopIndex(newTopIndex);
+ }
+}
+
+/**
+ * Scrolls text to the right to use new space made available by a resize.
+ */
+void claimRightFreeSpace() {
+ int newHorizontalOffset = Math.max(0, contentWidth - getClientArea().width);
+
+ 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).
+ scrollHorizontalBar(newHorizontalOffset - horizontalScrollOffset);
+ }
+}
+
+/**
+ * Removes the widget selection.
+ *
+ *
+ * @param sendEvent a Selection event is sent when set to true and when the selection is actually reset.
+ */
+void clearSelection(boolean sendEvent) {
+ int selectionStart = selection.x;
+ int selectionEnd = selection.y;
+ int length = content.getCharCount();
+
+ resetSelection();
+ // redraw old selection, if any
+ if (selectionEnd - selectionStart > 0) {
+ // 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) {
+ redrawRange(redrawStart, redrawEnd - redrawStart, true);
+ }
+ if (sendEvent == true) {
+ sendSelectionEvent();
+ }
+ }
+}
+
+/**
+ * Computes the preferred size.
+ *
+ * @exception SWTException
+ *
+ * @param text text to be measured.
+ * @param lineIndex index of the line.
+ * @param gc GC to use for measuring text
+ * @return width of the text with tabs expanded to tab stops
+ */
+int contentWidth(String text, int lineIndex, GC gc) {
+ int paintX = 0;
+ int textLength = text.length();
+
+ for (int i = 0; i < textLength; i++) {
+ int tabIndex = text.indexOf(TAB, i);
+ // is tab not present or past the rendering range?
+ if (tabIndex == -1 || tabIndex > textLength) {
+ tabIndex = textLength;
+ }
+ if (tabIndex != i) {
+ String tabSegment = text.substring(i, tabIndex);
+ paintX += gc.stringExtent(tabSegment).x;
+ if (tabIndex != textLength && tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ i = tabIndex;
+ }
+ else
+ if (tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ }
+ return paintX;
+}
+/**
+ * Copies the selected text to the clipboard. The text will be put in the
+ * clipboard in plain text format and RTF format.
+ *
+ *
+ * @exception SWTException
+ *
+ * @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 SWT.SINGLE style.
+ */
+String getModelDelimitedText(String text) {
+ StringBuffer convertedText;
+ String delimiter = getLineDelimiter();
+ int length = text.length();
+ int crIndex = 0;
+ int lfIndex = 0;
+ int i = 0;
+
+ if (length == 0) {
+ return text;
+ }
+ convertedText = new StringBuffer(length);
+ while (i < length) {
+ if (crIndex != -1) {
+ crIndex = text.indexOf(SWT.CR, i);
+ }
+ if (lfIndex != -1) {
+ lfIndex = text.indexOf(SWT.LF, i);
+ }
+ if (lfIndex == -1 && crIndex == -1) { // no more line breaks?
+ break;
+ }
+ else // CR occurs before LF or no LF present?
+ if ((crIndex < lfIndex && crIndex != -1) || lfIndex == -1) {
+ convertedText.append(text.substring(i, crIndex));
+ if (lfIndex == 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() == false || convertedText.length() == 0)) {
+ convertedText.append(text.substring(i));
+ }
+ return convertedText.toString();
+}
+
+/**
+ * Creates default key bindings.
+ */
+void createKeyBindings() {
+ // Navigation
+ setKeyBinding(SWT.ARROW_UP, ST.LINE_UP);
+ setKeyBinding(SWT.ARROW_DOWN, ST.LINE_DOWN);
+ setKeyBinding(SWT.HOME, ST.LINE_START);
+ setKeyBinding(SWT.END, ST.LINE_END);
+ setKeyBinding(SWT.ARROW_LEFT, ST.COLUMN_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT, ST.COLUMN_NEXT);
+ setKeyBinding(SWT.PAGE_UP, ST.PAGE_UP);
+ setKeyBinding(SWT.PAGE_DOWN, ST.PAGE_DOWN);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.CTRL, ST.WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.CTRL, ST.WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.CTRL, ST.TEXT_START);
+ setKeyBinding(SWT.END | SWT.CTRL, ST.TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.CTRL, ST.WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL, ST.WINDOW_END);
+
+ // Selection
+ setKeyBinding(SWT.ARROW_UP | SWT.SHIFT, ST.SELECT_LINE_UP);
+ setKeyBinding(SWT.ARROW_DOWN | SWT.SHIFT, ST.SELECT_LINE_DOWN);
+ setKeyBinding(SWT.HOME | SWT.SHIFT, ST.SELECT_LINE_START);
+ setKeyBinding(SWT.END | SWT.SHIFT, ST.SELECT_LINE_END);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.SHIFT, ST.SELECT_COLUMN_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.SHIFT, ST.SELECT_COLUMN_NEXT);
+ setKeyBinding(SWT.PAGE_UP | SWT.SHIFT, ST.SELECT_PAGE_UP);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.SHIFT, ST.SELECT_PAGE_DOWN);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.CTRL | SWT.SHIFT, ST.SELECT_WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.CTRL | SWT.SHIFT, ST.SELECT_WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.CTRL | SWT.SHIFT, ST.SELECT_TEXT_START);
+ setKeyBinding(SWT.END | SWT.CTRL | SWT.SHIFT, ST.SELECT_TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_END);
+
+ // Modification
+ // Cut, Copy, Paste
+ // CUA style
+ setKeyBinding('\u0018' | SWT.CTRL, ST.CUT);
+ setKeyBinding('\u0003' | SWT.CTRL, ST.COPY);
+ setKeyBinding('\u0016' | SWT.CTRL, ST.PASTE);
+ // Wordstar style
+ setKeyBinding(SWT.DEL | SWT.SHIFT, ST.CUT);
+ setKeyBinding(SWT.INSERT | SWT.CTRL, ST.COPY);
+ setKeyBinding(SWT.INSERT | SWT.SHIFT, ST.PASTE);
+
+ setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
+ setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
+
+ // Miscellaneous
+ setKeyBinding(SWT.INSERT, ST.TOGGLE_OVERWRITE);
+}
+/**
+ * Moves the selected text to the clipboard. The text will be put in the
+ * clipboard in plain text format and RTF format.
+ *
+ *
+ * @exception SWTException
+ *
+ * @param direction SWT.UP, SWT.DOWN, SWT.RIGHT, SWT.LEFT
+ */
+void doAutoScroll(int direction) {
+ Runnable timer = null;
+ final int TIMER_INTERVAL = 5;
+
+ // If we're already autoscrolling in the given direction do nothing
+ if (autoScrollDirection == direction) {
+ return;
+ }
+
+ 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 == SWT.UP) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.UP) {
+ doLineUp();
+ doSelection(SWT.LEFT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.DOWN) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.DOWN) {
+ doLineDown();
+ doSelection(SWT.RIGHT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.RIGHT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.RIGHT) {
+ doColumnRight();
+ doSelection(SWT.RIGHT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.LEFT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.LEFT) {
+ doColumnLeft();
+ doSelection(SWT.LEFT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ }
+ if (timer != null) {
+ autoScrollDirection = direction;
+ display.timerExec(TIMER_INTERVAL, timer);
+ }
+}
+
+/**
+ * Deletes the character to the left of the caret. 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 != selection.y) {
+ event.start = selection.x;
+ event.end = selection.y;
+ sendKeyEvent(event);
+ }
+ else
+ if (caretOffset > 0) {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (caretOffset == lineOffset) {
+ lineOffset = content.getOffsetAtLine(line - 1);
+ event.start = lineOffset + content.getLine(line - 1).length();
+ event.end = caretOffset;
+ }
+ else {
+ event.start = caretOffset - 1;
+ event.end = caretOffset;
+ }
+ sendKeyEvent(event);
+ }
+ claimBottomFreeSpace();
+}
+
+/**
+ * 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 #doSelectionCursorLeft
+ */
+void doCursorLeft() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.x;
+ showCaret();
+ }
+ else {
+ doSelectionCursorLeft();
+ }
+}
+
+/**
+ * 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 #doSelectionCursorRight
+ */
+void doCursorRight() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.y;
+ showCaret();
+ }
+ else {
+ doSelectionCursorRight();
+ }
+}
+/**
+ * Moves the caret one character to the left. Do not go to the previous line.
+ */
+void doColumnLeft() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine > 0) {
+ caretOffset--;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret one character to the right. Do not go to the next line.
+ */
+void doColumnRight() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine < content.getLine(line).length()) {
+ caretOffset++;
+ showCaret();
+ }
+}
+
+/**
+ * Replaces the selection with the character or insert the character at the
+ * current caret position if no selection exists.
+ * If a carriage return was typed replace it with the line break character
+ * used by the widget on this platform.
+ *
+ *
+ * @param key the character typed by the user
+ */
+void doContent(char key) {
+ Event event;
+
+ if (textLimit > 0 && content.getCharCount() - (selection.y - selection.x) >= textLimit) {
+ return;
+ }
+ 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 == SWT.CR || key == SWT.LF) {
+ if (isSingleLine() == false) {
+ event.text = getLineDelimiter();
+ }
+ }
+ // no selection and overwrite mode is on and the typed key is not a
+ // tab character (tabs are always inserted without overwriting)?
+ else
+ if (selection.x == selection.y && overwrite == true && key != TAB) {
+ 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 != null) {
+ sendKeyEvent(event);
+ }
+}
+
+/**
+ * Moves the caret after the last character of the widget content.
+ */
+void doContentEnd() {
+ 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();
+ }
+}
+
+/**
+ * Deletes the character to the right of the caret. Delete the selected text if any.
+ */
+void doDelete() {
+ Event event = new Event();
+
+ event.text = "";
+ if (selection.x != 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 == lineOffset + lineLength) {
+ event.start = caretOffset;
+ event.end = content.getOffsetAtLine(line + 1);
+ }
+ else {
+ event.start = caretOffset;
+ event.end = caretOffset + 1;
+ }
+ sendKeyEvent(event);
+ }
+ claimBottomFreeSpace();
+}
+
+/**
+ * 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.
+ * Make the new caret position visible.
+ */
+void doLineDown() {
+ doSelectionLineDown();
+ showCaret();
+}
+
+/**
+ * Moves the caret to the end of the line.
+ */
+void doLineEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ int lineEndOffset = lineOffset + lineLength;
+
+ if (caretOffset < lineEndOffset) {
+ caretOffset = lineEndOffset;
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret to the beginning of the line.
+ */
+void doLineStart() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (caretOffset > lineOffset) {
+ caretOffset = lineOffset;
+ showCaret();
+ }
+ else // move up one line to remove line selection
+ if (line > 0 && selection.x < caretOffset) {
+ line--;
+ caretOffset = content.getOffsetAtLine(line);
+ 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() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (line > 0) {
+ line--;
+ lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ showCaret();
+ }
+}
+
+/**
+ * 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, boolean select) {
+ int line = (y + verticalScrollOffset) / getLineHeight();
+ int lineCount = content.getLineCount();
+
+ if (line > lineCount - 1) {
+ line = lineCount - 1;
+ }
+ if (line >= 0) {
+ String lineText = content.getLine(line);
+ int offsetInLine = -1;
+ int newCaretOffset;
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (select && selection.x == lineOffset && line < lineCount - 1) {
+ GC gc = new GC(this);
+ int lineLength = lineText.length();
+ // represent the line break as one additional white space
+ // if the selection mouse event occurs beyond the line end
+ if (x + horizontalScrollOffset > textWidth(lineText, line, lineLength, gc)) {
+ line++;
+ offsetInLine = 0;
+ lineOffset = content.getOffsetAtLine(line);
+ }
+ gc.dispose();
+ }
+ if (offsetInLine == -1) {
+ offsetInLine = getOffsetAtX(lineText, lineOffset, x);
+ }
+ newCaretOffset = lineOffset + offsetInLine;
+ if (newCaretOffset != caretOffset) {
+ caretOffset = newCaretOffset;
+ if (select) {
+ doMouseSelection();
+ }
+ showCaret();
+ }
+ if (select == false) {
+ clearSelection(true);
+ }
+ }
+}
+
+/**
+ * Updates the selection based on the caret position
+ */
+void doMouseSelection() {
+ if (caretOffset <= selection.x || (caretOffset > selection.x && caretOffset < selection.y && selectionAnchor == selection.x)) {
+ doSelection(SWT.LEFT);
+ }
+ else {
+ doSelection(SWT.RIGHT);
+ }
+}
+
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top 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 end
+ * of the text where a full page scroll is not possible. In this case the
+ * caret is moved after the last character.
+ *
+ *
+ * @param select whether or not to select the page
+ */
+void doPageDown(boolean select) {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineCount = content.getLineCount();
+
+ if (line < lineCount) {
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ int lineLength;
+ int verticalMaximum = content.getLineCount() * getVerticalIncrement();
+ int pageSize = getClientArea().height;
+ int scrollLines = Math.min(lineCount - line - 1, getLineCountWhole() - 1);
+ int scrollOffset;
+
+ line += scrollLines;
+ lineOffset = content.getOffsetAtLine(line);
+ lineLength = content.getLine(line).length();
+ // set cursor to end of line if cursor would be beyond the end
+ // of line or if page down goes to last line
+ if (offsetInLine > lineLength || line == lineCount - 1) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ if (select) {
+ doSelection(SWT.RIGHT);
+ }
+ // scroll one page down or to the bottom
+ scrollOffset = verticalScrollOffset + scrollLines * getVerticalIncrement();
+ if (scrollOffset + pageSize > verticalMaximum) {
+ scrollOffset = verticalMaximum - pageSize;
+ }
+ if (scrollOffset > verticalScrollOffset) {
+ setVerticalScrollOffset(scrollOffset, true);
+ }
+ else {
+ showCaret();
+ }
+ }
+}
+/**
+ * Moves the cursor to the end of the last fully visible line.
+ */
+void doPageEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineCount = content.getLineCount();
+
+ if (line < lineCount) {
+ line = getBottomIndex();
+ caretOffset = content.getOffsetAtLine(line) + content.getLine(line).length();
+ showCaret();
+ }
+}
+/**
+ * Moves the cursor to the beginning of the first fully visible line.
+ */
+void doPageStart() {
+ if (content.getLineAtOffset(caretOffset) > topIndex) {
+ caretOffset = content.getOffsetAtLine(topIndex);
+ 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() {
+ int line = content.getLineAtOffset(caretOffset);
+
+ if (line > 0) {
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ int lineLength;
+ int scrollLines = Math.min(line, getLineCountWhole() - 1);
+ int scrollOffset;
+
+ line -= scrollLines;
+ lineOffset = content.getOffsetAtLine(line);
+ lineLength = content.getLine(line).length();
+ // set cursor to start of line if page up goes to first line
+ if (line == 0) {
+ offsetInLine = 0;
+ }
+ else
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ // scroll one page up or to the top
+ scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
+ if (scrollOffset < verticalScrollOffset) {
+ setVerticalScrollOffset(scrollOffset, true);
+ }
+ else {
+ showCaret();
+ }
+ }
+}
+/**
+ * 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 doSelectionLineDown() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (line < content.getLineCount() - 1) {
+ line++;
+ lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ }
+}
+/**
+ * Updates the selection to extend to the current caret position.
+ */
+void doSelection(int direction) {
+ int redrawStart = -1;
+ int redrawEnd = -1;
+
+ if (selectionAnchor == -1) {
+ selectionAnchor = selection.x;
+ }
+ if (direction == SWT.LEFT) {
+ if (caretOffset < selection.x) {
+ // grow selection
+ redrawEnd = selection.x;
+ redrawStart = selection.x = caretOffset;
+ // check if selection has reversed direction
+ if (selection.y != selectionAnchor) {
+ redrawEnd = selection.y;
+ selection.y = selectionAnchor;
+ }
+ }
+ else // test whether selection actually changed. Fixes 1G71EO1
+ if (selectionAnchor == 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 != selectionAnchor) {
+ redrawStart = selection.x;
+ selection.x = selectionAnchor;
+ }
+ }
+ else // test whether selection actually changed. Fixes 1G71EO1
+ if (selectionAnchor == 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 != -1 && redrawEnd != -1) {
+ redrawRange(redrawStart, redrawEnd - redrawStart, true);
+ sendSelectionEvent();
+ }
+}
+
+/**
+ * Moves the caret one character to the left or to the end of the previous
+ * line if the cursor is at the beginning of a line.
+ */
+void doSelectionCursorLeft() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine > 0) {
+ caretOffset--;
+ showCaret();
+ }
+ else
+ if (line > 0) {
+ line--;
+ lineOffset = content.getOffsetAtLine(line);
+ caretOffset = lineOffset + content.getLine(line).length();
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret one character to the right or to the beginning of the
+ * next line if the cursor is at the end of a line.
+ */
+void doSelectionCursorRight() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine < content.getLine(line).length()) {
+ caretOffset++;
+ showCaret();
+ }
+ else
+ if (line < content.getLineCount() - 1) {
+ line++;
+ caretOffset = content.getOffsetAtLine(line);
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret to the beginning of the next line, selecting to the end
+ * of the line plus one whitespace to represent the line break.
+ * Do the regular line selection, if the selection does not start at the
+ * line start or if the last line is being selected.
+ */
+void doSelectionLineEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (selection.x == lineOffset && line < content.getLineCount() - 1) {
+ line++;
+ caretOffset = content.getOffsetAtLine(line);
+ showCaret();
+ }
+ else {
+ doLineEnd();
+ }
+}
+/**
+ * Moves the caret to the start of the word that is to the left of
+ * the current caret position.
+ * If a selection exists, move the caret to the start of the selection
+ * and remove the selection.
+ */
+void doWordLeft() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.x;
+ showCaret();
+ }
+ else {
+ doSelectionWordLeft();
+ }
+}
+
+/**
+ * Moves the caret to the end of the word that is to the right of
+ * the current caret position.
+ * If a selection exists, move the caret to the end of the selection
+ * and remove the selection.
+ */
+void doWordRight() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.y;
+ showCaret();
+ }
+ else {
+ doSelectionWordRight();
+ }
+}
+
+/**
+ * Moves the caret to the start of the word that is to the left of
+ * the current caret position.
+ */
+void doSelectionWordLeft() {
+ caretOffset = getWordStart(caretOffset);
+ showCaret();
+}
+
+/**
+ * Moves the caret to the end of the word that is to the right of
+ * the current caret position.
+ */
+void doSelectionWordRight() {
+ caretOffset = getWordEnd(caretOffset);
+ showCaret();
+}
+
+/**
+ * Draws the specified rectangle.
+ * Draw directly without invalidating the affected area when a gc is
+ * specified.
+ *
+ *
+ * @param x the x position
+ * @param y the y position
+ * @param width the width
+ * @param height the height
+ * @param gc GC to use for direct drawing. If null the specified area
+ * is invalidated only.
+ * @param clearBackground true=clear the background, false=only draw the foregorund
+ */
+void draw(int x, int y, int width, int height, GC gc, boolean clearBackground) {
+ if (gc == null) {
+ redraw(x, y, width, height, false);
+ }
+ else {
+ int lineHeight = getLineHeight();
+ int startLine = (y + verticalScrollOffset) / lineHeight;
+ int endY = y + height;
+ int paintYFromTopLine = (startLine - topIndex) * lineHeight;
+ int topLineOffset = (topIndex * lineHeight - verticalScrollOffset);
+ int paintY = paintYFromTopLine + topLineOffset; // adjust y position for pixel based scrolling
+ int lineCount = content.getLineCount();
+ Color background = getBackground();
+ Color foreground = getForeground();
+
+ if (isSingleLine()) {
+ lineCount = 1;
+ if (startLine > 1) {
+ startLine = 1;
+ }
+ }
+ for (int i = startLine; paintY < endY && i < lineCount; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+ drawLine(line, i, paintY, gc, background, foreground, clearBackground);
+ }
+ if (clearBackground && paintY < endY) {
+ gc.setBackground(background);
+ gc.setForeground(background);
+ gc.fillRectangle(0, paintY, getClientArea().width, endY - paintY);
+ }
+ }
+}
+/**
+ * Draws a line of text at the specified location.
+ *
+ *
+ * @param line the line to draw
+ * @param lineIndex index of the line to draw
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @param widgetBackground the widget background color. Used as the default rendering color.
+ * @param widgetForeground the widget foreground color. Used as the default rendering color.
+ */
+void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackground, Color widgetForeground, boolean clearBackground) {
+ int lineOffset = content.getOffsetAtLine(lineIndex);
+ int lineLength = line.length();
+ int selectionEndX = 0;
+ int clientAreaWidth = getClientArea().width;
+ int selectionStartOffset;
+ int selectionEndOffset;
+ int selectionLength;
+ boolean lineSelection;
+ StyleRange[] styles = new StyleRange[0];
+ Color lineBackground = null;
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = event.styles;
+ }
+ event = getLineBackgroundData(lineOffset, line);
+ if (event != null) {
+ lineBackground = event.lineBackground;
+ }
+ if (lineBackground == null) {
+ lineBackground = widgetBackground;
+ }
+ // calculate offset of selection start and end relative to the line start
+ selectionStartOffset = Math.max(0, selection.x - lineOffset);
+ selectionEndOffset = selection.y - lineOffset;
+ selectionLength = selectionEndOffset - selectionStartOffset;
+ if (selectionLength == 0 || selectionVisible == false) {
+ selectionStartOffset = 0;
+ selectionEndOffset = 0;
+ }
+ lineSelection = selectionEndOffset > 0 && selectionStartOffset <= lineLength;
+ if (lineSelection == false && clearBackground) {
+ // draw background for completely unselected line
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(0, paintY, clientAreaWidth, lineHeight);
+ }
+ if (selectionStartOffset > 0) {
+ String unselectedLine;
+ if (selectionStartOffset > lineLength) {
+ unselectedLine = line;
+ }
+ else {
+ if (clearBackground) {
+ // draw background for partially unselected line
+ int selectionStartX = textWidth(line, lineOffset, 0, selectionStartOffset, styles, 0, gc);
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(0, paintY, selectionStartX - horizontalScrollOffset, lineHeight);
+ }
+ unselectedLine = line.substring(0, selectionStartOffset);
+ }
+ drawStyledLine(unselectedLine, lineOffset, 0, styles, 0, paintY, gc, lineBackground, widgetForeground);
+ }
+ if (selectionLength > 0 && lineSelection) {
+ // draw selected text
+ selectionEndX = drawLineSelection(line, lineOffset, selectionStartOffset, selectionLength, styles, paintY, gc) - horizontalScrollOffset;
+ if (selectionEndX < clientAreaWidth && clearBackground) {
+ // draw background after selection
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(selectionEndX, paintY, clientAreaWidth - selectionEndX, lineHeight);
+ }
+ selectionEndX += horizontalScrollOffset;
+ }
+ if (selectionEndOffset < lineLength) {
+ selectionEndOffset = Math.max(0, selectionEndOffset);
+ drawStyledLine(line, lineOffset, selectionEndOffset, styles, selectionEndX, paintY, gc, lineBackground, widgetForeground);
+ }
+}
+/**
+ * Draws the selected part of a line at the specified location.
+ * Draws selected text on top of unselected text.
+ *
+ *
+ * @param line the line to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param selectionStartOffset offset of the first selected character.
+ * Relative to the start of the line.
+ * @param selectionLength length, in characters, of the selection.
+ * @param styles line styles
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @return the x location of the selection end relative to first character location in the line
+ */
+int drawLineSelection(String line, int lineOffset, int selectionStartOffset, int selectionLength, StyleRange[] styles, int paintY, GC gc) {
+ int lineLength = line.length();
+ int paintX;
+ int selectionBackgroundWidth;
+
+ styles = filterLineStyles(styles);
+ paintX = textWidth(line, lineOffset, 0, selectionStartOffset, styles, 0, gc);
+ if (selectionStartOffset + selectionLength > lineLength) {
+ selectionLength = lineLength - selectionStartOffset;
+ if ((getStyle() & SWT.FULL_SELECTION) != 0) {
+ // use the greater of the client area width and the content width
+ // fixes 1G8IYRD
+ selectionBackgroundWidth = Math.max(getClientArea().width, contentWidth);
+ }
+ else {
+ // if the selection extends beyond this line, render an
+ // additional whitespace to represent the selected line break
+ selectionBackgroundWidth = textWidth(line + " ", lineOffset, selectionStartOffset, selectionLength + 1, styles, paintX, gc);
+ }
+ }
+ else {
+ selectionBackgroundWidth = textWidth(line, lineOffset, selectionStartOffset, selectionLength, styles, paintX, gc);
+ }
+ gc.setBackground(getSelectionBackground());
+ gc.setForeground(getSelectionForeground());
+ // fill the background first since expanded tabs are not
+ // drawn as spaces. tabs just move the draw position.
+ gc.fillRectangle(paintX - horizontalScrollOffset, paintY, selectionBackgroundWidth, lineHeight);
+ drawText(line, lineOffset, selectionStartOffset, selectionLength, styles, paintX, paintY, gc);
+ return paintX + selectionBackgroundWidth;
+}
+/**
+ * Draws the line at the specified location.
+ *
+ *
+ * @param line the line to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param renderOffset offset of the first character that should be rendered.
+ * Relative to the start of the line.
+ * @param styles the styles to use for rendering line segments. May be empty but not null.
+ * @param paintX x location to draw at
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @param lineBackground line background color, used when no style is specified for a line segment.
+ * @param lineForeground line foreground color, used when no style is specified for a line segment.
+ */
+void drawStyledLine(String line, int lineOffset, int renderOffset, StyleRange[] styles, int paintX, int paintY, GC gc, Color lineBackground, Color lineForeground) {
+ int lineLength = line.length();
+ Color background = gc.getBackground();
+ Color foreground = gc.getForeground();
+ StyleRange style = null;
+ StyleRange[] filteredStyles = filterLineStyles(styles);
+ int renderStopX = getClientArea().width + horizontalScrollOffset;
+
+ for (int i = 0; i < styles.length && paintX < renderStopX; i++) {
+ int styleLineLength;
+ int styleLineStart;
+ style = styles[i];
+ styleLineStart = Math.max(style.start - lineOffset, 0);
+ // render unstyled text between the start of the current
+ // style range and the end of the previously rendered
+ // style range
+ if (styleLineStart > renderOffset) {
+ background = setLineBackground(gc, background, lineBackground);
+ foreground = setLineForeground(gc, foreground, lineForeground);
+ // don't try to render more text than requested
+ styleLineStart = Math.min(lineLength, styleLineStart);
+ paintX = drawText(line, lineOffset, renderOffset, styleLineStart - renderOffset, filteredStyles, paintX, paintY, gc);
+ renderOffset = styleLineStart;
+ }
+ styleLineLength = Math.min(style.start - lineOffset + style.length, lineLength) - renderOffset;
+ if (styleLineLength == 0) {
+ // there are line styles but no text for those styles
+ // possible when called with partial line text
+ break;
+ }
+ else
+ if (styleLineLength < 0) {
+ // style ends before render start offset
+ continue;
+ }
+ // set style background color if specified
+ if (style.background != null) {
+ background = setLineBackground(gc, background, style.background);
+ foreground = setLineForeground(gc, foreground, style.background);
+ int fillWidth = textWidth(line, lineOffset, renderOffset, styleLineLength, filteredStyles, paintX, gc);
+ gc.fillRectangle(paintX - horizontalScrollOffset, paintY, fillWidth, lineHeight);
+ }
+ else {
+ background = setLineBackground(gc, background, lineBackground);
+ }
+ // set style foreground color if specified
+ if (style.foreground != null) {
+ foreground = setLineForeground(gc, foreground, style.foreground);
+ }
+ else {
+ foreground = setLineForeground(gc, foreground, lineForeground);
+ }
+ paintX = drawText(line, lineOffset, renderOffset, styleLineLength, filteredStyles, paintX, paintY, gc);
+ renderOffset += styleLineLength;
+ }
+ // render unstyled text at the end of the line
+ if ((style == null || renderOffset < lineLength) && paintX < renderStopX) {
+ setLineBackground(gc, background, lineBackground);
+ setLineForeground(gc, foreground, lineForeground);
+ drawText(line, lineOffset, renderOffset, lineLength - renderOffset, filteredStyles, paintX, paintY, gc);
+ }
+}
+
+/**
+ * Draws the text at the specified location. Expands tabs to tab stops using
+ * the widget tab width.
+ *
+ *
+ * @param text text to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param startOffset offset of the first character in text to draw
+ * @param length number of characters to draw
+ * @param styles line styles
+ * @param paintX x location to start drawing at
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @return x location where drawing stopped or 0 if the startOffset or
+ * length is outside the specified text.
+ */
+int drawText(String text, int lineOffset, int startOffset, int length, StyleRange[] lineStyles, int paintX, int paintY, GC gc) {
+ int endOffset = startOffset + length;
+ int textLength = text.length();
+ StyleRange[] styles;
+ FontData fontData = gc.getFont().getFontData()[0];
+
+ if (startOffset < 0 || startOffset >= textLength || startOffset + length > textLength) {
+ return paintX;
+ }
+ for (int i = startOffset; i < endOffset; i++) {
+ int tabIndex = text.indexOf(TAB, i);
+ // is tab not present or past the rendering range?
+ if (tabIndex == -1 || tabIndex > endOffset) {
+ tabIndex = endOffset;
+ }
+ if (tabIndex != i) {
+ String tabSegment = text.substring(i, tabIndex);
+ if (lineStyles != null) {
+ paintX = styledTextWidth(tabSegment, lineOffset + i, lineStyles, paintX, paintY, gc, true);
+ }
+ else {
+ fontData = setLineFont(gc, fontData, SWT.NORMAL);
+ gc.drawString(tabSegment, paintX - horizontalScrollOffset, paintY, true);
+ paintX += gc.stringExtent(tabSegment).x;
+ }
+ if (tabIndex != endOffset && tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ i = tabIndex;
+ }
+ else // is tab at current rendering offset?
+ if (tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ }
+ return paintX;
+}
+
+/**
+ * Ends the autoscroll process.
+ */
+void endAutoScroll() {
+ autoScrollDirection = SWT.NULL;
+}
+
+/**
+ * @param styles styles that may contain font styles.
+ * @return null if the styles contain only regular font styles, the
+ * unchanged styles otherwise.
+ */
+StyleRange[] filterLineStyles(StyleRange[] styles) {
+ if (styles != null) {
+ int styleIndex = 0;
+ while (styleIndex < styles.length && styles[styleIndex].fontStyle == SWT.NORMAL) {
+ styleIndex++;
+ }
+ if (styleIndex == styles.length) {
+ styles = null;
+ }
+ }
+ return styles;
+}
+/**
+ * Returns the index of the last fully visible line.
+ *
+ *
+ * @return index of the last fully visible line.
+ */
+int getBottomIndex() {
+ return Math.min(content.getLineCount(), topIndex + getLineCountWhole()) - 1;
+}
+
+
+/**
+ * Returns the caret position relative to the start of the text.
+ *
+ *
+ * @return the caret position relative to the start of the text.
+ * @exception SWTException
+ *
+ * @return content implementation that is used for text storage or null
+ * if no user defined content implementation has been set.
+ * @exception SWTException
+ *
+ * @return true if double clicking a word selects the word, false if double clicks
+ * have the same effect as regular mouse clicks
+ * @exception SWTException
+ *
+ * @return true if content can be edited, false otherwise
+ * @exception SWTException
+ *
+ * @return horizontal scroll increment.
+ */
+int getHorizontalIncrement() {
+ GC gc = new GC(this);
+ int increment = gc.getFontMetrics().getAverageCharWidth();
+
+ gc.dispose();
+ return increment;
+}
+
+/**
+ * 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 SWTException
+ *
+ * @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 SWTException
+ *
+ * @param key a key code defined in SWT.java or a character.
+ * Optionally ORd with a state mask (one or more of SWT.CTRL, SWT.SHIFT, SWT.ALT)
+ * @return one of the predefined actions defined in ST.java or SWT.NULL
+ * if there is no action associated with the key.
+ * @exception SWTException
+ *
+ * @return number of characters in the widget
+ * @exception SWTException
+ *
+ * @return the background color of the line at the given index.
+ * @exception SWTException
+ *
+ * @return the number of lines in the widget
+ * @exception SWTException
+ *
+ * @return number of lines that are at least partially displayed in the widget client area.
+ */
+int getLineCountTruncated() {
+ int lineCount;
+ int lineHeight = getLineHeight();
+
+ if (lineHeight != 0) {
+ lineCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+ }
+ else {
+ lineCount = 1;
+ }
+ return lineCount;
+}
+
+/**
+ * Returns the number of lines that are completely displayed in the widget client area.
+ *
+ *
+ * @return number of lines that are completely displayed in the widget client area.
+ */
+int getLineCountWhole() {
+ int lineCount;
+ int lineHeight = getLineHeight();
+
+ if (lineHeight != 0) {
+ lineCount = getClientArea().height / lineHeight;
+ }
+ else {
+ lineCount = 1;
+ }
+ return lineCount;
+}
+
+/**
+ * Returns the line at the specified offset in the text.
+ * 0 <= offset <= 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 SWTException
+ *
+ * @return line delimiter used for entering new lines by key down
+ * or paste operation.
+ * @exception SWTException
+ *
+ * @return line height in pixel.
+ * @exception SWTException
+ *
+ * @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 SWTException
+ *
+ * @param line text of the line to calculate the offset in
+ * @param lineOffset offset of the first character in the line.
+ * 0 based from the beginning of the document.
+ * @param lineXOffset x location in the line
+ * @return offset of the character at the x location relative to the start of the
+ * line.
+ */
+int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
+ int x = 0;
+ GC gc = new GC(this);
+ int low = -1;
+ int high = line.length();
+ int offset;
+ StyleRange[] styles = null;
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = filterLineStyles(event.styles);
+ }
+ lineXOffset += horizontalScrollOffset;
+ while (high - low > 1) {
+ offset = (high + low) / 2;
+ x = textWidth(line, lineOffset, 0, offset, styles, 0, gc);
+ int charWidth = textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc) - x;
+ if (lineXOffset <= x + charWidth / 2) {
+ high = offset;
+ }
+ else {
+ low = offset;
+ }
+ }
+ offset = high;
+ gc.dispose();
+ return offset;
+}
+/**
+ * Returns the index of the last partially visible line.
+ *
+ * @return index of the last partially visible line.
+ */
+int getPartialBottomIndex() {
+ int partialLineCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+
+ return Math.min(content.getLineCount(), topIndex + partialLineCount) - 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 the selection.
+ *
+ * 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
+ *
+ *
+ * @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
+ * @see getSelectionRange()
+ * @exception SWTException
+ *
+ * @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.
+ * @exception SWTException
+ *
+ * @return background color to be used for rendering selected text
+ */
+Color getSelectionBackground() {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+}
+/**
+ * Gets the number of selected characters.
+ *
+ *
+ * @return the number of selected characters.
+ * @exception SWTException
+ *
+ * @return foreground color to be used for rendering selected text
+ */
+Color getSelectionForeground() {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+}
+
+/**
+ * Returns the selected text.
+ *
+ *
+ * @return selected text, or an empty String if there is no selection.
+ * @exception SWTException
+ *
+ * @return a StyleRange with start == offset and length == 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 SWTException
+ *
+ * @return the styles or null if a LineStyleListener has been set.
+ * @exception SWTException
+ *
+ * @return copy of the widget content
+ * @exception SWTException
+ *
+ * @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 SWTException
+ *
+ * @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 SWTException
+ *
+ * @exception SWTException
+ *
+ * @return the index of the top line
+ * @exception SWTException
+ *
+ * @return pixel position of the top line
+ * @exception SWTException
+ *
+ * @return vertical scroll increment.
+ */
+int getVerticalIncrement() {
+ return getLineHeight();
+}
+
+/**
+ * Returns the offset of the character after the word at the specified
+ * offset.
+ *
+ * There are two classes of words formed by a sequence of characters:
+ *
+ * Space characters ' ' (ASCII 20) are special as they are treated as
+ * part of the word leading up to the space character. Line breaks are
+ * treated as one word.
+ *
+ * There are two classes of words formed by a sequence of characters:
+ *
+ * Spaces are ignored and do not represent a word. Line breaks are treated
+ * as one word.
+ *
+ * index
.
+ * start
- end
range.
+ * offset
. Called by StyledText.
+ * Returns a new style. Does not return the existing style.
+ *
+*
+*/
+public Font getFont () {
+ return list.getFont();
+}
+/**
+* Gets the items.
+*
+*
+*/
+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 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, SWT.DEFAULT);
+ 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 les 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 != 0) result = strings [0];
+ }
+ return result;
+}
+/**
+* Selects an item with text that starts with specified String.
+*
+*
+*/
+public void select(String string) {
+ String[] items = list.getItems();
+
+ // find the first entry in the list that starts with the
+ // specified string
+ if (string != 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.
+*
+*
+*/
+public void setFont (Font font) {
+ list.setFont(font);
+}
+/**
+* Sets all items.
+*
+*
+*/
+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)
+ throw new SWTError(SWT.ERROR_INVALID_ARGUMENT);
+
+ minimumWidth = width;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
new file mode 100755
index 0000000000..533f6f2e82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
@@ -0,0 +1,57 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+
+/**
+ * This class provides access to the public constants provided by StyledText
.
+ */
+public class ST {
+
+ /* StyledText key action constants */
+ /* Navigation */
+ public static final int LINE_UP = SWT.ARROW_UP;
+ public static final int LINE_DOWN = SWT.ARROW_DOWN;
+ public static final int LINE_START = SWT.HOME;
+ public static final int LINE_END = SWT.END;
+ public static final int COLUMN_PREVIOUS = SWT.ARROW_LEFT;
+ public static final int COLUMN_NEXT = SWT.ARROW_RIGHT;
+ public static final int PAGE_UP = SWT.PAGE_UP;
+ public static final int PAGE_DOWN = SWT.PAGE_DOWN;
+ public static final int WORD_PREVIOUS = SWT.ARROW_LEFT | SWT.CTRL;
+ public static final int WORD_NEXT = SWT.ARROW_RIGHT | SWT.CTRL;
+ public static final int TEXT_START = SWT.HOME | SWT.CTRL;
+ public static final int TEXT_END = SWT.END | SWT.CTRL;
+ public static final int WINDOW_START = SWT.PAGE_UP | SWT.CTRL;
+ public static final int WINDOW_END = SWT.PAGE_DOWN | SWT.CTRL;
+
+ /* Selection */
+ public static final int SELECT_LINE_UP = SWT.ARROW_UP | SWT.SHIFT;
+ public static final int SELECT_LINE_DOWN = SWT.ARROW_DOWN | SWT.SHIFT;
+ public static final int SELECT_LINE_START = SWT.HOME | SWT.SHIFT;
+ public static final int SELECT_LINE_END = SWT.END | SWT.SHIFT;
+ public static final int SELECT_COLUMN_PREVIOUS = SWT.ARROW_LEFT | SWT.SHIFT;
+ public static final int SELECT_COLUMN_NEXT = SWT.ARROW_RIGHT | SWT.SHIFT;
+ public static final int SELECT_PAGE_UP = SWT.PAGE_UP | SWT.SHIFT;
+ public static final int SELECT_PAGE_DOWN = SWT.PAGE_DOWN | SWT.SHIFT;
+ public static final int SELECT_WORD_PREVIOUS = SWT.ARROW_LEFT | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_WORD_NEXT = SWT.ARROW_RIGHT | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_TEXT_START = SWT.HOME | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_TEXT_END = SWT.END | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_WINDOW_START = SWT.PAGE_UP | SWT.CTRL| SWT.SHIFT;
+ public static final int SELECT_WINDOW_END = SWT.PAGE_DOWN | SWT.CTRL | SWT.SHIFT;
+
+ /* Modification */
+ public static final int CUT = SWT.DEL | SWT.SHIFT;
+ public static final int COPY = SWT.INSERT | SWT.CTRL;
+ public static final int PASTE = SWT.INSERT | SWT.SHIFT;
+ public static final int DELETE_PREVIOUS = SWT.BS;
+ public static final int DELETE_NEXT = SWT.DEL;
+
+ /* Miscellaneous */
+ public static final int TOGGLE_OVERWRITE = SWT.INSERT;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java
new file mode 100755
index 0000000000..27bc05ae52
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java
@@ -0,0 +1,384 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * The SashForm lays out its children in a Row or Column arrangement (as specified
+ * by the orientation) and places a Sash between the children.
+ * One child may be maximized to occupy the entire size of the SashForm.
+ * The relative sizes of the children may be specfied using weights.
+ *
+ *
+ *
+ */
+public class SashForm extends Composite {
+
+ public int SASH_WIDTH = 3;
+
+ private static final int DRAG_MINIMUM = 20;
+
+ private int orientation = SWT.HORIZONTAL;
+ private Sash[] sashes = new Sash[0];
+ private Control[] controls = new Control[0];
+ private Control maxControl = null;
+ private Listener sashListener;
+
+public SashForm(Composite parent, int style) {
+ super(parent, checkStyle(style));
+ if ((style & SWT.VERTICAL) != 0){
+ orientation = SWT.VERTICAL;
+ }
+
+ this.addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event e) {
+ layout(true);
+ }
+ });
+
+ sashListener = new Listener() {
+ public void handleEvent(Event e) {
+ onDragSash(e);
+ }
+ };
+}
+private static int checkStyle (int style) {
+ int mask = SWT.BORDER;
+ return style & mask;
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+
+ Control[] controls = getControls(true);
+ if (controls.length == 0) return new Point(wHint, hHint);
+
+ int width = 0;
+ int height = 0;
+ boolean vertical = (getStyle() & SWT.VERTICAL) != 0;
+ if (vertical) {
+ width = wHint;
+ height += (controls.length - 1) * SASH_WIDTH;
+ } else {
+ height = hHint;
+ width += controls.length *SASH_WIDTH;
+ }
+ for (int i = 0; i < controls.length; i++) {
+ if (vertical) {
+ Point size = controls[i].computeSize(wHint, SWT.DEFAULT);
+ height += size.y;
+ } else {
+ Point size = controls[i].computeSize(SWT.DEFAULT, hHint);
+ width += size.x;
+ }
+ }
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+
+ return new Point(width, height);
+}
+/**
+ * Answer SWT.HORIZONTAL if the controls in the SashForm are laid out side by side.
+ * Answer SWT.VERTICAL if the controls in the SashForm are laid out top to bottom.
+ */
+public int getOrientation() {
+ return orientation;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm. This value may be null.
+ */
+public Control getMaximizedControl(){
+ 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).
+ */
+
+public int[] getWeights() {
+ Control[] cArray = getControls(false);
+ float[] ratios = new float[cArray.length];
+ for (int i = 0; i < cArray.length; i++) {
+ Float ratio = (Float)cArray[i].getData("layout ratio");
+ if (ratio != null) {
+ ratios[i] = ratio.floatValue();
+ } else {
+ ratios[i] = (float)0.2;
+ }
+ }
+
+ int[] weights = new int[cArray.length];
+ for (int i = 0; i < weights.length; i++) {
+ weights[i] = (int)(ratios[i] * 1000);
+ }
+ return weights;
+}
+private Control[] getControls(boolean onlyVisible) {
+ Control[] children = getChildren();
+ Control[] controls = new Control[0];
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof Sash) continue;
+ if (onlyVisible && !children[i].getVisible()) continue;
+
+ Control[] newControls = new Control[controls.length + 1];
+ System.arraycopy(controls, 0, newControls, 0, controls.length);
+ newControls[controls.length] = children[i];
+ controls = newControls;
+ }
+ return controls;
+}
+public void layout(boolean changed) {
+ Rectangle area = getClientArea();
+ if (area.width == 0 || area.height == 0) return;
+
+ Control[] newControls = getControls(true);
+ if (controls.length == 0 && newControls.length == 0) return;
+ controls = newControls;
+
+ if (maxControl != null && !maxControl.isDisposed()) {
+ for (int i= 0; i < controls.length; i++){
+ if (controls[i] != maxControl) {
+ controls[i].setBounds(-200, -200, 0, 0);
+ } else {
+ controls[i].setBounds(area);
+ }
+ }
+ return;
+ }
+
+ // keep just the right number of sashes
+ if (sashes.length < controls.length - 1) {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashes, 0, newSashes, 0, sashes.length);
+ int sashOrientation = (orientation == SWT.HORIZONTAL) ? SWT.VERTICAL : SWT.HORIZONTAL;
+ for (int i = sashes.length; i < newSashes.length; i++) {
+ newSashes[i] = new Sash(this, sashOrientation);
+ newSashes[i].addListener(SWT.Selection, sashListener);
+ }
+ sashes = newSashes;
+ }
+ if (sashes.length > controls.length - 1) {
+ if (controls.length == 0) {
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].dispose();
+ }
+ sashes = new Sash[0];
+ } else {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashes, 0, newSashes, 0, newSashes.length);
+ for (int i = controls.length - 1; i < sashes.length; i++) {
+ sashes[i].dispose();
+ }
+ sashes = newSashes;
+ }
+ }
+
+ if (controls.length == 0) return;
+
+ // get the ratios
+ float[] ratios = new float[controls.length];
+ float total = 0;
+ for (int i = 0; i < controls.length; i++) {
+ Float ratio = (Float)controls[i].getData("layout ratio");
+ if (ratio != null) {
+ ratios[i] = ratio.floatValue();
+ } else {
+ ratios[i] = (float)0.2;
+ }
+ total += ratios[i];
+ }
+
+ if (orientation == SWT.HORIZONTAL) {
+ total += (float)sashes.length * ((float)SASH_WIDTH / (float)area.width);
+ } else {
+ total += (float)sashes.length * ((float)SASH_WIDTH / (float)area.height);
+ }
+
+ if (orientation == SWT.HORIZONTAL) {
+ int width = (int)((ratios[0] / total) * (float)area.width);
+ 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, SASH_WIDTH, area.height);
+ x += SASH_WIDTH;
+ width = (int)((ratios[i] / total) * (float)area.width);
+ controls[i].setBounds(x, area.y, width, area.height);
+ x += width;
+ }
+ if (controls.length > 1) {
+ sashes[sashes.length - 1].setBounds(x, area.y, SASH_WIDTH, area.height);
+ x += SASH_WIDTH;
+ width = area.width - x;
+ controls[controls.length - 1].setBounds(x, area.y, width, area.height);
+ }
+ } else {
+ int height = (int)((ratios[0] / total) * (float)area.height);
+ 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, SASH_WIDTH);
+ y += SASH_WIDTH;
+ height = (int)((ratios[i] / total) * (float)area.height);
+ 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, SASH_WIDTH);
+ y += SASH_WIDTH;
+ height = area.height - y;
+ controls[controls.length - 1].setBounds(area.x, y, area.width, height);
+ }
+
+ }
+}
+private void onDragSash(Event event) {
+ if (event.detail == SWT.DRAG) {
+ // constrain feedback
+ Rectangle area = getClientArea();
+ if (orientation == SWT.HORIZONTAL) {
+ event.x = Math.min(Math.max(DRAG_MINIMUM, event.x), area.width - DRAG_MINIMUM);
+ } else {
+ event.y = Math.min(Math.max(DRAG_MINIMUM, event.y), area.height - DRAG_MINIMUM);
+ }
+ return;
+ }
+
+ Sash sash = (Sash)event.widget;
+ int sashIndex = -1;
+ for (int i= 0; i < sashes.length; i++) {
+ if (sashes[i] == sash) {
+ sashIndex = i;
+ break;
+ }
+ }
+ if (sashIndex == -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();
+ if (orientation == SWT.HORIZONTAL) {
+ int shift = event.x - sashBounds.x;
+ b1.width += shift;
+ b2.x += shift;
+ b2.width -= shift;
+ if (b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM) {
+ return;
+ }
+ c1.setData("layout ratio", new Float((float)b1.width / (float)area.width));
+ c2.setData("layout ratio", new Float((float)b2.width / (float)area.width));
+ } else {
+ int shift = event.y - sashBounds.y;
+ b1.height += shift;
+ b2.y += shift;
+ b2.height -= shift;
+ if (b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM) {
+ return;
+ }
+ c1.setData("layout ratio", new Float((float)b1.height / (float)area.height));
+ c2.setData("layout ratio", new Float((float)b2.height / (float)area.height));
+ }
+
+ c1.setBounds(b1);
+ sash.setBounds(event.x, event.y, event.width, event.height);
+ c2.setBounds(b2);
+}
+/**
+ * If orientation is SWT.HORIZONTAL, lay the controls in the SashForm out side by side.
+ * If orientation is SWT.VERTICAL, lay the controls in the SashForm out top to bottom.
+ */
+public void setOrientation(int orientation) {
+ if (this.orientation == orientation) return;
+ if (orientation != SWT.HORIZONTAL && orientation != SWT.VERTICAL) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.orientation = orientation;
+
+ int sashOrientation = (orientation == SWT.HORIZONTAL) ? SWT.VERTICAL : SWT.HORIZONTAL;
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].dispose();
+ sashes[i] = new Sash(this, sashOrientation);
+ sashes[i].addListener(SWT.Selection, sashListener);
+ }
+ layout();
+}
+public void setLayout (Layout layout) {
+ // SashForm does not use Layout
+}
+/**
+ * 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.
+ */
+public void setMaximizedControl(Control control){
+ if (control == null) {
+ if (maxControl != null) {
+ this.maxControl = null;
+ layout();
+ 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();
+
+// // walk up
+// w= getParent();
+// if (w instanceof SplitForm)
+// ((SplitForm) w).internalMaximize(this);
+// else
+// layout(true);
+}
+
+/**
+ * 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.
+ */
+public void setWeights(int[] weights) {
+ Control[] cArray = getControls(false);
+ if (weights == null || weights.length != cArray.length) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ int total = 0;
+ for (int i = 0; i < weights.length; i++) {
+ if (weights[i] < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ total += weights[i];
+ }
+ if (total == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ for (int i = 0; i < cArray.length; i++) {
+ cArray[i].setData("layout ratio", new Float((float)weights[i] / (float)total));
+ }
+
+ layout();
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
new file mode 100755
index 0000000000..cd9ac851a2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
@@ -0,0 +1,202 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * A ScrolledComposite provides scrollbars and will scroll its content when the user
+ * uses the scrollbars.
+ *
+ *
+ *
+ */
+public class ScrolledComposite extends Composite {
+
+ private Control content;
+ private Listener contentListener;
+
+ private int minHeight = 0;
+ private int minWidth = 0;
+ private boolean expandHorizontal = false;
+ private boolean expandVertical = false;
+
+public ScrolledComposite(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ ScrollBar hBar = getHorizontalBar ();
+ if (hBar != null) {
+ hBar.addListener (SWT.Selection, new Listener () {
+ public void handleEvent (Event e) {
+ hScroll();
+ }
+ });
+ }
+
+ ScrollBar vBar = getVerticalBar ();
+ if (vBar != null) {
+ vBar.addListener (SWT.Selection, new Listener () {
+ public void handleEvent (Event e) {
+ vScroll();
+ }
+ });
+ }
+
+ addListener (SWT.Resize, new Listener () {
+ public void handleEvent (Event e) {
+ resize();
+ }
+ });
+
+ contentListener = new Listener() {
+ public void handleEvent(Event e) {
+ if (e.type != SWT.Resize) return;
+ resize();
+ }
+ };
+}
+
+private static int checkStyle (int style) {
+ int mask = SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
+ return style & mask;
+}
+/**
+ * Get the content that is being scrolled.
+ */
+public Control getContent() {
+ return content;
+}
+private void hScroll() {
+ if (content == null) return;
+ Point location = content.getLocation ();
+ ScrollBar hBar = getHorizontalBar ();
+ int hSelection = hBar.getSelection ();
+ content.setLocation (-hSelection, location.y);
+}
+private void resize() {
+ if (content == null) return;
+ Rectangle contentRect = content.getBounds();
+ Rectangle hostRect = getClientArea();
+ if (expandHorizontal) {
+ contentRect.width = Math.max(minWidth, hostRect.width);
+ }
+ if (expandVertical) {
+ contentRect.height = Math.max(minHeight, hostRect.height);
+ }
+
+ ScrollBar hBar = getHorizontalBar ();
+ if (hBar != 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;
+ contentRect.x = -hSelection;
+ }
+ }
+
+ ScrollBar vBar = getVerticalBar ();
+ if (vBar != 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;
+ contentRect.y = -vSelection;
+ }
+ }
+
+ content.setBounds (contentRect);
+}
+/**
+ * Set the content that will be scrolled.
+ */
+public void setContent(Control content) {
+ if (this.content != null && !this.content.isDisposed()) {
+ this.content.removeListener(SWT.Resize, contentListener);
+ content.setBounds(new Rectangle(-200, -200, 0, 0));
+ }
+
+ this.content = content;
+ if (this.content != null) {
+ this.content.addListener(SWT.Resize, contentListener);
+ resize();
+ }
+}
+/**
+ * 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 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.
+ */
+public void setExpandHorizontal(boolean expand) {
+ if (expand == expandHorizontal) return;
+ expandHorizontal = expand;
+ resize();
+}
+/**
+ * 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 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.
+ */
+public void setExpandVertical(boolean expand) {
+ if (expand == expandVertical) return;
+ expandVertical = expand;
+ resize();
+}
+public void setLayout (Layout layout) {
+ // do not allow a layout to be set on this class because layout is being handled by the resize listener
+ 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.
+ */
+public void setMinHeight(int height) {
+ if (height == minHeight) return;
+ minHeight = Math.max(0, height);
+ resize();
+}
+/**
+ * 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.
+ */
+
+public void setMinWidth(int width) {
+ if (width == minWidth) return;
+ minWidth = Math.max(0, width);
+ resize();
+}
+
+private void vScroll() {
+ Control[] children = getChildren();
+ if (children.length == 0) return;
+ Control content = children[0];
+ Point location = content.getLocation ();
+ ScrollBar vBar = getVerticalBar ();
+ int vSelection = vBar.getSelection ();
+ content.setLocation (location.x, -vSelection);
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java
new file mode 100755
index 0000000000..a193ad5a24
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java
@@ -0,0 +1,74 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+/**
+ * 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 the call
+ * layout() on the composite which has the StackLayout.
+ */
+
+public class StackLayout 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;
+
+ /**
+ * 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, boolean 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 = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = maxWidth;
+ if (hHint == SWT.DEFAULT) height = maxHeight;
+ return new Point(width + 2 * marginWidth, height + 2 * marginHeight);
+}
+
+protected void layout(Composite composite, boolean 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] == topControl);
+
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java
new file mode 100755
index 0000000000..12623a5b22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java
@@ -0,0 +1,147 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class StyleRange implements Cloneable {
+ public int start; // style start offset. 0 based from the document start
+ public int length; // style length.
+ public Color foreground;
+ public Color background;
+ public int fontStyle = SWT.NORMAL; // may be SWT.NORMAL or SWT.BOLD
+
+public StyleRange() {
+}
+/**
+ * Create a new style range.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class StyledText extends Canvas {
+ static final int CARET_WIDTH = 1; // width of the caret. Used during content width calculation since
+ // Caret.getSize() does not return its width until it is made visible.
+ static final char TAB = '\t';
+
+ private final static String PlatformLineDelimiter = System.getProperty("line.separator");
+
+ StyledTextContent content;
+ TextChangedListener textChangedListener; // listener for TextReplaced and TextSet events from StyledTextContent
+ DefaultLineStyler defaultLineStyler;// used for setStyles API when no LineStyleListener is registered
+ boolean userLineStyle = false; // true=widget is using a user defined line style listener for line styles. false=widget is using the default line styler to store line styles
+ boolean userLineBackground = false;// true=widget is using a user defined line background listener for line backgrounds. false=widget is using the default line styler to store line backgrounds
+ int verticalScrollOffset = 0; // pixel based
+ int horizontalScrollOffset = 0; // pixel based
+ int topIndex = 0; // top visible line
+ int clientAreaHeight = 0; // the client area height. Needed to calculate content width for new
+ // visible lines during Resize callback
+ int contentWidth = 0; // width of widest known (already visible) line
+ int contentWidthIndex = 0; // line up to which the content width has been calculated
+ int lineHeight; // line height=font height
+ int tabLength = 4; // number of characters in a tab
+ int tabWidth; // width of a tab character in the current GC
+ Caret caret; // caret SWT widget
+ Cursor ibeamCursor;
+ int caretOffset = 0;
+ Point selection = new Point(0, 0); // x is character offset, y is length
+ int selectionAnchor; // position of selection anchor. 0 based offset from beginning of text
+ boolean editable = true;
+ boolean doubleClickEnabled = true; // see getDoubleClickEnabled
+ boolean overwrite = false; // insert/overwrite edit mode
+ int textLimit = -1; // limits the number of characters the user can type in the widget. Unlimited by default.
+ boolean selectionVisible = true;
+ Hashtable keyActionMap = new Hashtable();
+ Font boldFont;
+ Font regularFont;
+ Clipboard clipboard;
+
+ boolean mouseDoubleClick = false; // true=a double click ocurred. Don't do mouse swipe selection.
+ int autoScrollDirection = SWT.NULL; // the direction of autoscrolling (up, down, right, left)
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final int ExtendedModify = 3000;
+ static final int LineGetStyle = 3002;
+ static final int LineGetBackground = 3001;
+ static final int TextReplaced = 3003;
+ static final int TextSet = 3004;
+ static final int VerifyKey = 3005;
+ /**
+ * The RTFWriter
class is used to write widget content as
+ * rich text. The implementation complies with the RTF specification
+ * version 1.5.
+ * start
and length
can be set to specify partial
+ * lines.
+ * toString()
does not return a valid RTF string until
+ * close()
has been called.
+ */
+ public void close() {
+ if (isClosed() == false) {
+ writeHeader();
+ write("\n}}\0");
+ super.close();
+ }
+ }
+ /**
+ * Returns the index of the specified color in the RTF color table.
+ *
+ *
+ */
+ public void writeLine(String line, int lineOffset) {
+ StyleRange[] styles = new StyleRange[0];
+ Color lineBackground = null;
+ StyledTextEvent event;
+
+ if (isClosed()) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ event = getLineStyleData(lineOffset, line);
+ if (event != null) {
+ styles = event.styles;
+ }
+ event = getLineBackgroundData(lineOffset, line);
+ if (event != null) {
+ lineBackground = event.lineBackground;
+ }
+ if (lineBackground == null) {
+ lineBackground = getBackground();
+ }
+ writeStyledLine(line, lineOffset, styles, lineBackground);
+ }
+ /**
+ * Appends the specified line delmimiter to the RTF data.
+ *
+ *
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed()) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter, 0, lineDelimiter.length());
+ write("\\par ");
+ }
+ /**
+ * Appends the specified segment of "string" to the RTF data.
+ * Copy from start
up to, but excluding, end
.
+ * TextWriter
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.
+ * toString()
is guaranteed to return a valid string only after close()
+ * has been called.
+ */
+ 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 boolean isClosed = false;
+
+ /**
+ * Creates a writer that writes content starting at offset "start"
+ * in the document. start
and length
can be set to specify partial lines.
+ * toString()
is not guaranteed to return a valid string unless
+ * the writer is closed.
+ */
+ public void close() {
+ if (isClosed == false) {
+ isClosed = true;
+ }
+ }
+ /**
+ * Returns the 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.
+ */
+ public int getStart() {
+ return startOffset;
+ }
+ /**
+ * Returns whether the writer is closed.
+ */
+ public boolean isClosed() {
+ return isClosed;
+ }
+ /**
+ * Returns the string. close()
must be called before toString()
+ * is guaranteed to return a valid string.
+ *
+ *
+ */
+ public void writeLine(String line, int lineOffset) {
+ int lineLength = line.length();
+ int lineIndex;
+ int copyEnd;
+ int writeOffset = startOffset - lineOffset;
+
+ if (isClosed) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ if (writeOffset >= lineLength) {
+ return; // whole line is outside write range
+ }
+ else
+ if (writeOffset > 0) {
+ lineIndex = writeOffset; // line starts before write start
+ }
+ else {
+ lineIndex = 0;
+ }
+ copyEnd = Math.min(lineLength, endOffset - lineOffset);
+ if (lineIndex < copyEnd) {
+ write(line.substring(lineIndex, copyEnd));
+ }
+ }
+ /**
+ * Appends the specified line delmimiter to the data.
+ *
+ *
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter);
+ }
+ }
+
+public StyledText(Composite parent, int style) {
+ // use NO_BACKGROUND style when implemented by SWT.
+ // always need to draw background in drawLine when using NO_BACKGROUND!
+ super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND));
+ Display display = getDisplay();
+
+ if ((style & SWT.READ_ONLY) != 0) {
+ setEditable(false);
+ }
+ clipboard = new Clipboard(display);
+ calculateLineHeight();
+ calculateTabWidth();
+ caret = new Caret(this, SWT.NULL);
+ caret.setBounds(0, 0, CARET_WIDTH, lineHeight);
+ installDefaultContent();
+ calculateScrollBars();
+ createKeyBindings();
+ ibeamCursor = new Cursor(display, SWT.CURSOR_IBEAM);
+ setCursor(ibeamCursor);
+
+ setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ initializeFonts();
+ installListeners();
+ installDefaultLineStyler();
+}
+
+/**
+ * Adds an extended modify listener. An ExtendedModify event is sent by the
+ * widget when the widget text has changed.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+ checkWidget();
+ if (extendedModifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ StyledTextListener typedListener = new StyledTextListener(extendedModifyListener);
+ addListener(ExtendedModify, typedListener);
+}
+
+/**
+ * Maps a key to an action.
+ * One action can be associated with N keys. However, each key can only
+ * have one action (key:action is N:1 relation).
+ *
+ *
+ * @see org.eclipse.swt.SWT
+ * @see org.eclipse.swt.ST
+ */
+public void setKeyBinding(int key, int action) {
+ checkWidget();
+ if (action == SWT.NULL) {
+ keyActionMap.remove(new Integer(key));
+ }
+ else {
+ keyActionMap.put(new Integer(key), new Integer(action));
+ }
+}
+/**
+ * Adds a line background listener. A LineGetBackground event is sent by the
+ * widget to determine the background color for a line.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addLineBackgroundListener(LineBackgroundListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (userLineBackground == false) {
+ removeLineBackgroundListener(defaultLineStyler);
+ defaultLineStyler.setLineBackground(0, content.getLineCount(), null);
+ userLineBackground = true;
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(LineGetBackground, typedListener);
+}
+/**
+ * Adds a line style listener. A LineGetStyle event is sent by the widget to
+ * determine the styles for a line.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addLineStyleListener(LineStyleListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (userLineStyle == false) {
+ removeLineStyleListener(defaultLineStyler);
+ defaultLineStyler.setStyleRange(null);
+ userLineStyle = true;
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(LineGetStyle, typedListener);
+}
+/**
+ * Adds a modify listener. A Modify event is sent by the widget when the widget text
+ * has changed.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addModifyListener(ModifyListener modifyListener) {
+ checkWidget();
+ if (modifyListener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(modifyListener);
+ addListener(SWT.Modify, typedListener);
+}
+
+/**
+ * Adds a selection listener. A Selection event is sent by the widget when the
+ * selection has changed.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+}
+
+/**
+ * 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.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addVerifyKeyListener(VerifyKeyListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(VerifyKey, typedListener);
+}
+
+/**
+ * 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.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void addVerifyListener(VerifyListener verifyListener) {
+ checkWidget();
+ if (verifyListener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(verifyListener);
+ addListener(SWT.Verify, typedListener);
+}
+/**
+ * Appends a string to the text at the end of the widget.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public void append(String string) {
+ checkWidget();
+ if (string == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ int lastChar = Math.max(getCharCount(), 0);
+ replaceTextRange(lastChar, 0, string);
+}
+/**
+ * Calculates the width of the widest visible line.
+ */
+void calculateContentWidth() {
+ if (lineHeight != 0) {
+ int itemCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+ calculateContentWidth(topIndex, Math.min(itemCount, content.getLineCount() - topIndex));
+ }
+}
+
+/**
+ * Calculates the width of the widget text in the specified line range.
+ *
+ *
+ */
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int count, width, height, lineHeight;
+ boolean singleLine = (getStyle() & SWT.SINGLE) != 0;
+ lineHeight = getLineHeight();
+ count = content.getLineCount();
+
+ // If a height or width has been specified (via hHint and wHint),
+ // use those values. Otherwise calculate the size based on the
+ // text that is defined.
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ } else {
+ if (singleLine) count = 1;
+ height = count * lineHeight;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ } else {
+ // Only calculate what can actually be displayed.
+ // Do this because measuring each text line is a
+ // time-consuming process.
+ int visibleCount = Math.min (count, getDisplay().getBounds().width / lineHeight);
+ calculateContentWidth(0, visibleCount);
+ width = contentWidth;
+ }
+
+ // Use default values if no text is defined.
+ if (width == 0) width = DEFAULT_WIDTH;
+ if (height == 0) {
+ if (singleLine) height = getLineHeight();
+ else height = DEFAULT_HEIGHT;
+ }
+
+ // Hardcode the inset margins. Assume text is inset
+ // 1 pixel on each side.
+ width += 2;
+ height += 2;
+
+ Rectangle rect = computeTrim(0,0,width,height);
+ return new Point (rect.width, rect.height);
+}
+/**
+ * Returns the width of the specified text. Expand tabs to tab stops using
+ * the widget tab width.
+ * This is a quick and inaccurate measurement. Text styles are not taken
+ * into consideration. The gc should be setup to reflect the widest
+ * possible font style.
+ *
+ *
+ */
+public void copy(){
+ checkWidget();
+ int length = selection.y - selection.x;
+ if (length > 0) {
+ RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ TextTransfer plainTextTransfer = TextTransfer.getInstance();
+ RTFWriter rtfWriter = new RTFWriter(selection.x, length);
+ TextWriter plainTextWriter = new TextWriter(selection.x, length);
+ String rtfText;
+ String plainText;
+ rtfText = getPlatformDelimitedText(rtfWriter);
+ plainText = getPlatformDelimitedText(plainTextWriter);
+ clipboard.setContents(
+ new String[]{rtfText, plainText},
+ new Transfer[]{rtfTransfer, plainTextTransfer});
+ }
+}
+
+/**
+ * Returns a string that uses only the line delimiter specified by the
+ * StyledTextContent implementation.
+ * Returns only the first line if the widget has the SWT.SINGLE style.
+ *
+ *
+ */
+public void cut(){
+ checkWidget();
+ if (selection.y > selection.x) {
+ copy();
+ 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) {
+ Rectangle area = getClientArea();
+ if (event.y > area.height) doAutoScroll(SWT.DOWN);
+ else if (event.y < 0) doAutoScroll(SWT.UP);
+ else if (event.x < 0) doAutoScroll(SWT.LEFT);
+ else if (event.x > area.width) doAutoScroll(SWT.RIGHT);
+ else endAutoScroll();
+}
+/**
+ * Initiates autoscrolling.
+ *
+ *
+ */
+public int getCaretOffset() {
+ checkWidget();
+
+ return caretOffset;
+}
+
+/**
+ * Returns the content implementation that is used for text storage
+ * or null if no user defined content implementation has been set.
+ *
+ *
+ */
+public StyledTextContent getContent() {
+ checkWidget();
+
+ return content;
+}
+
+/**
+ * Returns whether the widget implements double click mouse behavior.
+ *
+ *
+ */
+public boolean getDoubleClickEnabled() {
+ checkWidget();
+
+ return doubleClickEnabled;
+}
+/**
+ * Returns whether the widget content can be edited.
+ *
+ *
+ */
+public boolean getEditable() {
+ checkWidget();
+
+ return editable;
+}
+
+/**
+ * Returns the horizontal scroll increment.
+ *
+ *
+ */
+public int getHorizontalIndex() {
+ checkWidget();
+
+ return horizontalScrollOffset / getHorizontalIncrement();
+}
+
+/**
+ * Returns the horizontal scroll offset relative to the start of the line.
+ *
+ *
+ */
+public int getHorizontalPixel() {
+ checkWidget();
+
+ return horizontalScrollOffset;
+}
+/**
+ * Returns the action assigned to the key.
+ * Returns SWT.NULL if there is no action associated with the key.
+ *
+ *
+ * @see org.eclipse.swt.SWT
+ * @see org.eclipse.swt.ST
+ */
+public int getKeyBinding(int key) {
+ checkWidget();
+ Integer action = (Integer) keyActionMap.get(new Integer(key));
+ int intAction;
+
+ if (action == null) {
+ intAction = SWT.NULL;
+ }
+ else {
+ intAction = action.intValue();
+ }
+ return intAction;
+}
+
+/**
+ * Gets the number of characters.
+ *
+ *
+ */
+public int getCharCount() {
+ checkWidget();
+
+ return content.getCharCount();
+}
+/**
+ * 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.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public Color getLineBackground(int index) {
+ checkWidget();
+ Color lineBackground = null;
+
+ if (index < 0 || index > content.getLineCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (userLineBackground == false) {
+ lineBackground = defaultLineStyler.getLineBackground(index);
+ }
+ return lineBackground;
+}
+/**
+ * Gets the number of text lines.
+ *
+ *
+ */
+public int getLineCount () {
+ checkWidget();
+ return getLineAtOffset(getCharCount()) + 1;
+}
+/**
+ * Returns the number of lines that are at least partially displayed in the widget client area.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public int getLineAtOffset(int offset) {
+ checkWidget();
+
+ if (offset < 0 || offset > getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return content.getLineAtOffset(offset);
+}
+
+/**
+ * Returns the line delimiter used for entering new lines by key down
+ * or paste operation.
+ *
+ *
+ */
+public String getLineDelimiter() {
+ checkWidget();
+
+ return content.getLineDelimiter();
+}
+/**
+ * Returns the line height.
+ *
+ *
+ */
+public int getLineHeight() {
+ checkWidget();
+
+ if (lineHeight == 0) {
+ calculateLineHeight();
+ }
+ return lineHeight;
+}
+/**
+ * Returns the line style data for the given line or null if there is none.
+ * If there is a LineStyleListener but it does not set any styles, the
+ * StyledTextEvent.styles field will be initialized to an empty array.
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+ if (isListening(LineGetStyle)) {
+ StyledTextEvent event = new StyledTextEvent(content);
+ event.detail = lineOffset;
+ event.text = line;
+ notifyListeners(LineGetStyle, event);
+ if (event.styles == null) {
+ event.styles = new StyleRange[0];
+ }
+ return event;
+ }
+ return null;
+}
+/**
+ * Returns the line background data for the given line or null if there is none.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+ if (isListening(LineGetBackground)) {
+ StyledTextEvent event = new StyledTextEvent(content);
+ event.detail = lineOffset;
+ event.text = line;
+ notifyListeners(LineGetBackground, event);
+ return event;
+ }
+ return null;
+}
+/**
+ * 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.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public Point getLocationAtOffset(int offset) {
+ checkWidget();
+ if (offset < 0 || offset > getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ int line = getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineContent = content.getLine(line);
+ int x = getXAtOffset(lineContent, line, offset - lineOffset);
+ int y = line * lineHeight - verticalScrollOffset;
+
+ return new Point(x, y);
+}
+/**
+ * Returns the offset at the given x location in the line.
+ * Doesn't properly handle ligatures and other context dependent characters or
+ * bidi. Ligatures are handled properly as long as they don't occur at lineXOffset.
+ *
+ *
+ */
+public Point getSelection() {
+ checkWidget();
+ return new Point(selection.x, selection.y);
+}
+/**
+ * Returns the selection.
+ *
+ *
+ */
+public Point getSelectionRange() {
+ checkWidget();
+
+ return new Point(selection.x, selection.y - selection.x);
+}
+
+/**
+ * Returns the background color to be used for rendering selected text.
+ *
+ *
+ */
+public int getSelectionCount() {
+ checkWidget();
+ return getSelectionRange().y;
+}
+/**
+ * Returns the foreground color to be used for rendering selected text.
+ *
+ *
+ */
+public String getSelectionText() {
+ checkWidget();
+
+ return content.getTextRange(selection.x, selection.y - selection.x);
+}
+
+/**
+ * Returns the style range at the given offset.
+ * 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.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public StyleRange getStyleRangeAtOffset(int offset) {
+ checkWidget();
+ if (offset < 0 || offset > getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (userLineStyle == false) {
+ return defaultLineStyler.getStyleRangeAtOffset(offset);
+ }
+ return null;
+}
+/**
+ * Returns the styles.
+ * 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.
+ *
+ *
+ */
+public StyleRange [] getStyleRanges() {
+ checkWidget();
+ StyleRange styles[];
+
+ if (userLineStyle == false) {
+ styles = defaultLineStyler.getStyleRanges();
+ }
+ else {
+ styles = new StyleRange[0];
+ }
+ return styles;
+}
+/**
+ * Returns the tab width measured in characters.
+ *
+ * @return tab width measured in characters
+ * @exception SWTException
+ *
+ */
+public int getTabs() {
+ checkWidget();
+
+ return tabLength;
+}
+/**
+ * Returns a copy of the widget content.
+ *
+ *
+ */
+public String getText() {
+ checkWidget();
+
+ return content.getTextRange(0, getCharCount());
+}
+
+/**
+ * Returns the widget content between the two offsets.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public String getText(int start, int end) {
+ checkWidget();
+ int contentLength = getCharCount();
+
+ if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return content.getTextRange(start, end - start + 1);
+}
+/**
+ * Returns the widget content starting at start for length characters.
+ *
+ *
+ * @exception IllegalArgumentException
+ *
+ */
+public String getTextRange(int start, int length) {
+ checkWidget();
+ int contentLength = getCharCount();
+ int end = start + length;
+
+ if (start < 0 || start > contentLength || end < 0 || end > contentLength || start > end) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return content.getTextRange(start, length);
+}
+
+/**
+ * Gets the text limit. The text limit specifies the amount of text that the user
+ * can type into the widget.
+ *
+ *
+ */
+public int getTextLimit() {
+ checkWidget();
+
+ return textLimit;
+}
+
+/**
+ * Gets the top index. The top index is the index of the fully visible line that
+ * is currently at the top of the widget. The top index changes when the widget
+ * is scrolled. Indexing is zero based.
+ *
+ *
+ */
+public int getTopIndex() {
+ checkWidget();
+
+ return topIndex;
+}
+
+/**
+ * Gets the top pixel. 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.
+ *
+ *
+ */
+public int getTopPixel() {
+ checkWidget();
+
+ return verticalScrollOffset;
+}
+
+/**
+ * Returns the vertical scroll increment.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * Space characters ' ' (ASCII 20) are special as they are treated as + * part of the word leading up to the space character. Line breaks are treated + * as one word. + *
+ */ +int getWordStart(int offset) { + int line = content.getLineAtOffset(offset); + int lineOffset = content.getOffsetAtLine(line); + String lineText = content.getLine(line); + + if (offset <= 0) { + return offset; + } + if (offset == lineOffset) { + line--; + lineText = content.getLine(line); + offset = content.getOffsetAtLine(line) + lineText.length(); + } + else { + char ch; + boolean letterOrDigit; + + offset -= lineOffset; + // skip over trailing whitespace + do { + offset--; + ch = lineText.charAt(offset); + } while (offset > 0 && Character.isSpaceChar(ch)); + letterOrDigit = Character.isLetterOrDigit(ch); + while (offset > 0 && Character.isLetterOrDigit(ch) == letterOrDigit && Character.isSpaceChar(ch) == false) { + offset--; + ch = lineText.charAt(offset); + } + if (offset > 0 || Character.isLetterOrDigit(ch) != letterOrDigit) { + offset++; + } + offset += lineOffset; + } + return offset; +} + +/** + * Returns the x location of the character at the give offset in the line. + * NOTE: Does not return correct values for true italic fonts (vs. slanted fonts). + *+ * + * @return x location of the character at the give offset in the line. + */ +int getXAtOffset(String line, int lineIndex, int lineOffset) { + int x; + + if (lineOffset == 0) { + x = 0; + } + else { + GC gc = new GC(this); + if (lineOffset > line.length()) { + // offset is not on the line. return an x location one character + // after the line to indicate the line delimiter. + line += " "; + lineOffset = line.length(); + } + x = textWidth(line, lineIndex, lineOffset, gc); + gc.dispose(); + } + return x - horizontalScrollOffset; +} +/** + * Inserts a string. The old selection is replaced with the new text. + *
+ * + * @param string the string + * @see #replaceTextRange(int,int,String) + * @exception SWTException
+ * + * @see addLineStyleListener + */ +void installDefaultLineStyler() { + defaultLineStyler = new DefaultLineStyler(content); + StyledTextListener typedListener = new StyledTextListener(defaultLineStyler); + if (userLineStyle == false) { + addListener(LineGetStyle, typedListener); + } + if (userLineBackground == false) { + addListener(LineGetBackground, typedListener); + } +} +/** + * Adds event listeners + */ +void installListeners() { + ScrollBar verticalBar = getVerticalBar(); + ScrollBar horizontalBar = getHorizontalBar(); + + addListener(SWT.Dispose, new Listener() { + public void handleEvent(Event event) { + handleDispose(); + } + }); + addListener(SWT.KeyDown, new Listener() { + public void handleEvent(Event event) { + handleKeyDown(event); + } + }); + addListener(SWT.MouseDown, new Listener() { + public void handleEvent(Event event) { + handleMouseDown(event); + } + }); + addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + handleMouseUp(event); + } + }); + addListener(SWT.MouseDoubleClick, new Listener() { + public void handleEvent(Event event) { + handleMouseDoubleClick(event); + } + }); + addListener(SWT.MouseMove, new Listener() { + public void handleEvent(Event event) { + handleMouseMove(event); + } + }); + addListener(SWT.Paint, new Listener() { + public void handleEvent(Event event) { + handlePaint(event); + } + }); + addListener(SWT.Resize, new Listener() { + public void handleEvent(Event event) { + handleResize(event); + } + }); + addListener(SWT.Traverse, new Listener() { + public void handleEvent(Event event) { + // do nothing + // hooked to disable automatic tab traversal on tab key press + } + }); + if (verticalBar != null) { + verticalBar.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + handleVerticalScroll(event); + } + }); + } + if (horizontalBar != null) { + horizontalBar.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + handleHorizontalScroll(event); + } + }); + } +} +/** + * Returns the widget text with style information encoded using RTF format + * specification version 1.5. + * + * @exception SWTException
+ * + * @exception SWTException
+ * + * @exception SWTException
+ * + * @param event keyboard event + */ +void handleKeyDown(Event event) { + 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 == true) { + handleKey(event); + } +} + +/** + * 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; + + if (event.keyCode != 0) { + action = getKeyBinding(event.keyCode | event.stateMask); + } + else { + action = getKeyBinding(event.character | event.stateMask); + } + if (action == SWT.NULL) { + // ignore anything below SPACE and ignore DEL + if (event.character > 31 && event.character != SWT.DEL || + event.character == SWT.CR || event.character == SWT.LF || + event.character == TAB) { + doContent(event.character); + } + } + else { + invokeAction(action); + } +} +/** + * Renders the invalidated area specified in the paint event. + *
+ * + * @param event paint event + */ +void handlePaint(Event event) { + draw(event.x, event.y, event.width, event.height, event.gc, true); +} +/** + * Recalculates the scroll bars. + *
+ * + * @param event resize event + */ +void handleResize(Event event) { + ScrollBar verticalBar = getVerticalBar(); + int oldHeight = clientAreaHeight; + + clientAreaHeight = getClientArea().height; + if (clientAreaHeight > oldHeight) { + int lineCount = content.getLineCount(); + int oldBottomIndex = topIndex + oldHeight / lineHeight; + int newItemCount = (int) Math.ceil((float) (clientAreaHeight - oldHeight) / lineHeight); + oldBottomIndex = Math.min(oldBottomIndex, lineCount); + newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex); + calculateContentWidth(oldBottomIndex, newItemCount); + } + setScrollBars(); + claimBottomFreeSpace(); + claimRightFreeSpace(); +} + +/** + * Updates the caret position and selection to reflect the content change. + * Redraws the changed area. + *
+ * + * @param event.start the start offset of the change + * @param event.replacedCharCount the length of the replaced text + * @param event.newCharCount the length of the new text + * @param event.replacedLineCount number of replaced lines. + * @param event.newLineCount number of new lines. + */ +void handleTextChanged(TextChangedEvent event) { + int firstLine; + int firstLineOffset; + int offsetInLine; + String firstLineText; + int stopLine; + boolean isMultiLineChange = event.replacedLineCount > 0 || event.newLineCount > 0; + int textChangeX = -1; + int textChangeY; + int oldTabX = 0; + int textChangeStopX = -1; + int visibleItemCount = (int) Math.ceil((float) getClientArea().height / lineHeight); + + if (event.replacedCharCount < 0) { + event.start += event.replacedCharCount; + event.replacedCharCount *= -1; + } + firstLine = content.getLineAtOffset(event.start); + firstLineText = content.getLine(firstLine); + firstLineOffset = content.getOffsetAtLine(firstLine); + offsetInLine = event.start - firstLineOffset; + if (isMultiLineChange == false) { + // get location of nearest tab and replace stop offset in old text + int oldTabIndex; + String oldLine; + StringBuffer oldLineText = new StringBuffer(firstLineText); + oldLineText.delete(offsetInLine, offsetInLine + event.newCharCount); + if (event.replacedText != null && event.replacedText.length() > 0) { + oldLineText.insert(offsetInLine, event.replacedText); + } + oldLine = oldLineText.toString(); + oldTabIndex = oldLine.indexOf(TAB, offsetInLine + event.replacedCharCount); + oldTabX = getXAtOffset(oldLine, firstLine, oldTabIndex + 1); + if (event.newCharCount == 0) { + // characters were deleted. find out where the last deleted + // character stopped drawing + textChangeStopX = getXAtOffset( + oldLine, + firstLine, + offsetInLine + event.replacedCharCount); + } + else + if (event.replacedCharCount == 0) { + // characters were added. find out where before the styles are + // updated to reflect the text change + textChangeX = getXAtOffset(oldLine, firstLine, offsetInLine); + } + } + // notify default line styler about text change + if (defaultLineStyler != null) { + defaultLineStyler.textChanged(event); + } + // calculate width of visible changed lines + stopLine = firstLine + event.newLineCount + 1; + if (stopLine > topIndex && firstLine < topIndex + visibleItemCount) { + int startLine = Math.max(firstLine, topIndex); + calculateContentWidth(startLine, Math.min(stopLine, topIndex + visibleItemCount) - startLine); + } + setScrollBars(); + textChangeY = firstLine * lineHeight - verticalScrollOffset; + if (textChangeX == -1) { + textChangeX = getXAtOffset(firstLineText, firstLine, offsetInLine); + } + if (isMultiLineChange) { + redrawMultiLineChange(textChangeX, textChangeY, event.newLineCount, event.replacedLineCount); + } + else { + int newTabIndex = firstLineText.indexOf(TAB, offsetInLine + event.newCharCount); + if (newTabIndex != -1) { + // there is at least one tab after the text change + int newTabX = getXAtOffset(firstLineText, firstLine, newTabIndex + 1); + redrawSingleLineTabChange(textChangeX, textChangeY, newTabX, oldTabX); + } + else { + if (textChangeStopX == -1) { + textChangeStopX = getXAtOffset( + firstLineText, + firstLine, + offsetInLine + event.newCharCount); + } + redrawSingleLineChange( + textChangeX, + textChangeY, + event.newCharCount, + event.replacedCharCount, + textChangeStopX); + } + } + // 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. + // fixes 1GB93QT + updateSelection(event.start, event.replacedCharCount, event.newCharCount); +} +/** + * Called when the widget content is set programatically, 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(); +} +/** + * Scrolls the widget vertically. + */ +void handleVerticalScroll(Event event) { + setVerticalScrollOffset(getVerticalBar().getSelection(), false); +} +/** + * Initializes the fonts used to render font styles. + * Presently only regular and bold fonts are supported. + */ +void initializeFonts() { + FontData fontData; + + regularFont = getFont(); + fontData = regularFont.getFontData()[0]; + fontData.setStyle(fontData.getStyle() | SWT.BOLD); + boldFont = new Font(getDisplay(), fontData); +} +/** + * Executes the action. + *
+ * + * @param action one of the actions defined in ST.java + * @see ST.java + */ +public void invokeAction(int action) { + switch (action) { + // Navigation + case ST.LINE_UP: + doLineUp(); + clearSelection(true); + break; + case ST.LINE_DOWN: + doLineDown(); + clearSelection(true); + break; + case ST.LINE_START: + doLineStart(); + clearSelection(true); + break; + case ST.LINE_END: + doLineEnd(); + clearSelection(true); + break; + case ST.COLUMN_PREVIOUS: + doCursorLeft(); + clearSelection(true); + break; + case ST.COLUMN_NEXT: + doCursorRight(); + clearSelection(true); + break; + case ST.PAGE_UP: + doPageUp(); + clearSelection(true); + break; + case ST.PAGE_DOWN: + doPageDown(false); + clearSelection(true); + break; + case ST.WORD_PREVIOUS: + doWordLeft(); + clearSelection(true); + break; + case ST.WORD_NEXT: + doWordRight(); + 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: + doLineUp(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_LINE_DOWN: + doSelectionLineDown(); + doSelection(SWT.RIGHT); + showCaret(); + break; + case ST.SELECT_LINE_START: + doLineStart(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_LINE_END: + doSelectionLineEnd(); + doSelection(SWT.RIGHT); + break; + case ST.SELECT_COLUMN_PREVIOUS: + doSelectionCursorLeft(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_COLUMN_NEXT: + doSelectionCursorRight(); + doSelection(SWT.RIGHT); + break; + case ST.SELECT_PAGE_UP: + doPageUp(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_PAGE_DOWN: + doPageDown(true); + break; + case ST.SELECT_WORD_PREVIOUS: + doSelectionWordLeft(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_WORD_NEXT: + doSelectionWordRight(); + doSelection(SWT.RIGHT); + break; + case ST.SELECT_TEXT_START: + doContentStart(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_TEXT_END: + doContentEnd(); + doSelection(SWT.RIGHT); + break; + case ST.SELECT_WINDOW_START: + doPageStart(); + doSelection(SWT.LEFT); + break; + case ST.SELECT_WINDOW_END: + doPageEnd(); + doSelection(SWT.RIGHT); + break; + // Modification + case ST.CUT: + cut(); + break; + case ST.COPY: + copy(); + break; + case ST.PASTE: + paste(); + break; + case ST.DELETE_PREVIOUS: + doBackspace(); + clearSelection(true); + break; + case ST.DELETE_NEXT: + doDelete(); + clearSelection(true); + break; + // Miscellaneous + case ST.TOGGLE_OVERWRITE: + overwrite = !overwrite; // toggle insert/overwrite mode + break; + } +} +/** + * Returns whether the font style in the given style range is changing + * from SWT.NORMAL to SWT.BOLD or vice versa. + *
+ * + * @param range StyleRange to compare current font style with. + * @param start offset of the first font style to compare + * @param end offset behind the last font style to compare + * @return true if the font style is changing in the given style range, + * false if the font style is not changing in the given style range. + * @exception SWTException
+ * + * @param event the text change event. + *
+ * + * @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 area will be cleared before anything + * is redrawn. 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 + * area have changed, clearBackground should be set to true. If only foreground colors + * have changed for the redraw area, clearBackground can be set to false. + */ +public void redrawRange(int start, int length, boolean clearBackground) { + Rectangle clientArea = getClientArea(); + int lineHeight = getLineHeight(); + int end = start + length; + int firstLine = content.getLineAtOffset(start); + int lastLine = content.getLineAtOffset(end); + int lineCount = lastLine - firstLine + 1; + int redrawX; + int redrawStopX; + int redrawY; + int firstLineOffset; + int offsetInFirstLine; + int partialBottomIndex = getPartialBottomIndex(); + int partialTopIndex = verticalScrollOffset / lineHeight; + String line; + GC gc = null; + + // do nothing if redraw range is completely invisible + if (firstLine > partialBottomIndex || lastLine < partialTopIndex) { + return; + } + if (clearBackground == false) { + gc = new GC(this); + } + // only redraw visible lines + if (partialTopIndex > firstLine) { + firstLine = partialTopIndex; + firstLineOffset = start = content.getOffsetAtLine(firstLine); + offsetInFirstLine = 0; + } + else { + firstLineOffset = content.getOffsetAtLine(firstLine); + offsetInFirstLine = start - firstLineOffset; + } + if (partialBottomIndex + 1 < lastLine) { + lastLine = partialBottomIndex + 1; // + 1 to redraw whole bottom line, including line break + end = content.getOffsetAtLine(lastLine); + } + // redraw first line + line = content.getLine(firstLine); + // calculate redraw start location + redrawX = getXAtOffset(line, firstLine, offsetInFirstLine); + redrawY = firstLine * lineHeight - verticalScrollOffset; + // calculate redraw stop location + if ((getStyle() & SWT.FULL_SELECTION) != 0 && lastLine > firstLine) { + redrawStopX = clientArea.width; + } + else { + redrawStopX = getXAtOffset(line, firstLine, end - firstLineOffset); + } + draw(redrawX, redrawY, redrawStopX - redrawX, lineHeight, gc, clearBackground); + firstLine++; // first line has been redrawn. + + // redraw last line if more than line needs redrawing + if (lineCount > 1) { + int offsetInLastLine = end - content.getOffsetAtLine(lastLine); + // no redraw necessary if redraw offset is 0 + if (offsetInLastLine > 0) { + line = content.getLine(lastLine); + redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine); + redrawY = lastLine * lineHeight - verticalScrollOffset; + draw(0, redrawY, redrawStopX, lineHeight, gc, clearBackground); + } + lastLine--; // last line has been redrawn. + } + // redraw entire center lines if redraw range includes more than two lines + if (lastLine >= firstLine) { + int redrawStopY = (lastLine + 1) * lineHeight - verticalScrollOffset; + redrawY = firstLine * lineHeight - verticalScrollOffset; + draw(0, redrawY, clientArea.width, redrawStopY - redrawY, gc, clearBackground); + } + if (gc != null) { + gc.dispose(); + } +} +/** + * Fixes the widget to display a text change. + * Bit blitting and redrawing is done as necessary. + *
+ * + * @param x x location of the text change + * @param y y location of the text change + * @param newLineCount number of new lines. + * @param replacedLineCount number of replaced lines. + */ +void redrawMultiLineChange(int x, int y, int newLineCount, int replacedLineCount) { + Rectangle clientArea = getClientArea(); + int lineHeight = getLineHeight(); + int lineCount = newLineCount - replacedLineCount; + int sourceY; + int destinationY; + + if (lineCount > 0) { + sourceY = y + lineHeight; + destinationY = y + lineCount * lineHeight + lineHeight; + } + else { + sourceY = y - lineCount * lineHeight + lineHeight; + destinationY = y + lineHeight; + } + scroll( + 0, destinationY, // destination x, y + 0, sourceY, // source x, y + clientArea.width, clientArea.height, true); + // Always redrawing causes the bottom line to flash when a line is + // deleted. This is because SWT merges the paint area of the scroll + // with the paint area of the redraw call below. + // To prevent this we could call update after the scroll. However, + // adding update can cause even more flash if the client does other + // redraw/update calls (ie. for syntax highlighting). + // We could also redraw only when a line has been added or when + // contents has been added to a line. This would require getting + // line index info from the content and is not worth the trouble + // (the flash is only on the bottom line and minor). + // Specifying the NO_MERGE_PAINTS style bit prevents the merged + // redraw but could cause flash/slowness elsewhere. + redraw(x, y, clientArea.width, lineHeight, true); + if (newLineCount > 0) { + redraw(0, y + lineHeight, clientArea.width, newLineCount * lineHeight, true); + } +} +/** + * Fixes the widget after a text change local to one line ocurred. + * Bit blitting and/or redrawing is done as necessary. + *
+ * + * @param textChangeX x location of the text change + * @param textChangeY y location of the text change + * @param newCharCount number of new characters + * @param replacedCharCount number of replaced characters + * @param textChangeStopX the x location of the character after last + * changed character + */ +void redrawSingleLineChange(int textChangeX, int textChangeY, int newCharCount, int replacedCharCount, int textChangeStopX) { + Rectangle clientArea = getClientArea(); + int lineHeight = getLineHeight(); + + if (newCharCount == 0) { + // characters were deleted + scroll( + textChangeX, textChangeY, // destination x, y + textChangeStopX, textChangeY, // source x, y + clientArea.width, lineHeight, true); + } + else + if (replacedCharCount == 0) { + // characters were added + scroll( + textChangeStopX, textChangeY, // destination x, y + textChangeX, textChangeY, // source x, y + clientArea.width, lineHeight, true); + } + else { + // simple redraw if text has been replaced with other text + redraw(textChangeX, textChangeY, clientArea.width, lineHeight, true); + } +} +/** + * Fixes the widget after a text change local to one line ocurred. + * The line has a tab after the text change offset. Bit blitting + * and/or redrawing is done as necessary. + *
+ * + * @param textChangeX x location of the text change + * @param textChangeY y location of the text change + * @param newTabX the x location of the tab closest to the insert + * location as measured with the text change. + * @param oldTabX the x location of the tab closest to the insert + * location as measured without the text change. + */ +void redrawSingleLineTabChange(int textChangeX, int textChangeY, int newTabX, int oldTabX) { + Rectangle clientArea = getClientArea(); + int lineHeight = getLineHeight(); + + if (newTabX > oldTabX) { + scroll( + newTabX, textChangeY, // destination x, y + oldTabX, textChangeY, // source x, y + clientArea.width, lineHeight, true); + redraw(textChangeX, textChangeY, oldTabX - textChangeX, lineHeight, true); + } + else + if (newTabX < oldTabX) { + scroll( + newTabX, textChangeY, // destination x, y + oldTabX, textChangeY, // source x, y + clientArea.width, lineHeight, true); + redraw(textChangeX, textChangeY, newTabX - textChangeX, lineHeight, true); + } + else { + // tab location unchanged. redraw text between change offset and tab + redraw(textChangeX, textChangeY, newTabX - textChangeX, lineHeight, true); + } +} +/** + * Removes the specified extended modify listener. + *
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * + * @param listener the listener + * @exception SWTException
+ * NOTE: During the replace operation the current selection is changed + * as follows: + *
+ * + * @param pixels number of pixels to scroll, > 0 = scroll left, < 0 scroll right + */ +void scrollHorizontal(int pixels) { + Rectangle clientArea; + + if (pixels == 0) { + return; + } + clientArea = getClientArea(); + scroll( + pixels * -1, 0, // destination x, y + 0, 0, // source x, y + clientArea.width, clientArea.height, true); + horizontalScrollOffset += pixels; + setCaretLocation(); +} + +/** + * Scrolls the widget horizontally and adjust the horizontal scroll bar to + * reflect the new horizontal offset.. + *
+ * + * @param pixels number of pixels to scroll, > 0 = scroll left, < 0 scroll right + */ +void scrollHorizontalBar(int pixels) { + if (pixels == 0) { + return; + } + ScrollBar horizontalBar = getHorizontalBar(); + if (horizontalBar != null) { + horizontalBar.setSelection(horizontalScrollOffset + pixels); + } + scrollHorizontal(pixels); +} +/** + * Selects all the text. + *
+ * + * @exception SWTException
+ * + * @param event the text change event. + *
+ * NOTE: If offset is greater than the number of characters of text in the + * widget, the value will be ignored. + *
+ * + * @param offset caret offset, relative to the first character in the text. + * @exception SWTException+ * + * @param content StyledTextContent implementation to use for text storage. + * @exception SWTException
+ * NOTE: Italic fonts are not supported unless they have no overhang + * and the same baseline as regular fonts. + *
+ * + * @param font new font + * @exception SWTException+ * NOTE: The horizontal index is reset to 0 when new text is set in the + * widget. + *
+ * + * @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 SWTException+ * During text changes, when entire lines are inserted or removed, the line + * background colors that are associated with the lines after the change + * will "move" with their respective text. For all other text changes, + * line background colors will remain unchanged. + *
+ * + * @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 SWTException+ * + * @param start new caret position + * @see #setSelection(int,int) + * @exception SWTException
+ * 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 + *
+ * + * @param point x=selection start offset, y=selection end offset + * @see #setSelection(int,int) + * @exception SWTException+ * 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 + *
+ * + * @param start selection start offset + * @param end selection end offset + * @see #setSelectionRange(int,int) + * @exception SWTException+ * + * @param start offset of the first selected character, start >= 0 must be true. + * @param length number of characters to select, start <= start + length <= getCharCount() + * must be true. + * @exception SWTException
+ * + * @param start offset of the first selected character, start >= 0 must be true. + * @param length number of characters to select, start <= start + length + * <= getCharCount() must be true. + */ +void internalSetSelection(int start, int length) { + int end = start + length; + + if (selection.x != start || selection.y != end) { + clearSelection(false); + selectionAnchor = selection.x = start; + caretOffset = selection.y = end; + if (length > 0) { + redrawRange(selection.x, selection.y - selection.x, true); + } + } +} +/** + * Adds the specified style. 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. + *
+ * Should not be called if a LineStyleListener has been set since the + * listener maintains the styles. + *
+ * + * @param range StyleRange object containing the style information. + * Overwrites the old style in the given range. May be null to delete + * all styles. + * @exception SWTException+ * Should not be called if a LineStyleListener has been set since the + * listener maintains the styles. + *
+ * + * @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. + * @exception SWTException+ * + * @param tabs tab width measured in characters. + * @exception SWTException
+ * Note: Only a single line of text should be set when the SWT.SINGLE + * style is used. + *
+ * + * @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 SWTException+ * The text limit specifies the amount of text that + * the user can type into the widget. + *
+ * + * @param limit the new text limit. + * @exception SWTException+ * 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. + *
+ * + * @param index new top index. Must be between 0 and getLineCount() - + * visible lines per page. An out of range index will be adjusted accordingly. + * @exception SWTException+ * + * @param pixels number of pixels to scroll. > 0 = scroll up, < 0 scroll down + */ +void setVerticalScrollOffset(int pixelOffset, boolean adjustScrollBar) { + Rectangle clientArea; + ScrollBar verticalBar = getVerticalBar(); + int verticalIncrement = getVerticalIncrement(); + + if (pixelOffset == verticalScrollOffset) { + return; + } + if (verticalBar != null && adjustScrollBar) { + verticalBar.setSelection(pixelOffset); + } + clientArea = getClientArea(); + scroll( + 0, 0, // destination x, y + 0, pixelOffset - verticalScrollOffset, // source x, y + clientArea.width, clientArea.height, true); + if (verticalIncrement != 0) { + int oldTopIndex = topIndex; + + topIndex = (int) Math.ceil((float) pixelOffset / verticalIncrement); + if (topIndex != oldTopIndex) { + int lineCount = content.getLineCount(); + int visibleItemCount = (int) Math.ceil((float) clientArea.height / verticalIncrement); + int oldBottomIndex = Math.min(oldTopIndex + visibleItemCount, lineCount); + int newItemCount = topIndex - oldTopIndex; + + if (Math.abs(newItemCount) > visibleItemCount) { + calculateContentWidth(); + } + else { + if (newItemCount > 0) { + newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex); + calculateContentWidth(oldBottomIndex, newItemCount); + } + else + if (newItemCount < 0) { + // make sure calculation range does not exceed number of lines + // fixes 1GBKCLF + calculateContentWidth(topIndex, Math.min(newItemCount * -1, lineCount - topIndex)); + } + } + setScrollBars(); + } + } + verticalScrollOffset = pixelOffset; + setCaretLocation(); +} +/** + * Sets the caret location and scrolls the caret offset into view. + */ +void showCaret() { + int line = content.getLineAtOffset(caretOffset); + int lineOffset = content.getOffsetAtLine(line); + int offsetInLine = caretOffset - lineOffset; + String lineText = content.getLine(line); + int xAtOffset = getXAtOffset(lineText, line, offsetInLine); + int clientAreaWidth = getClientArea().width; + int verticalIncrement = getVerticalIncrement(); + int horizontalIncrement = clientAreaWidth / 4; + boolean scrolled = false; + + if (xAtOffset < 0) { + // always make 1/4 of a page visible + xAtOffset = Math.max(horizontalScrollOffset * -1, xAtOffset - horizontalIncrement); + scrollHorizontalBar(xAtOffset); + scrolled = true; + } + else + if (xAtOffset > clientAreaWidth) { + // always make 1/4 of a page visible + xAtOffset = Math.min(contentWidth - horizontalScrollOffset, xAtOffset + horizontalIncrement); + scrollHorizontalBar(xAtOffset - clientAreaWidth); + scrolled = true; + } + if (line < topIndex) { + setVerticalScrollOffset(line * verticalIncrement, true); + scrolled = true; + } + else + if (line > getBottomIndex()) { + setVerticalScrollOffset((line - getBottomIndex()) * verticalIncrement + verticalScrollOffset, true); + scrolled = true; + } + if (scrolled == false) { + caret.setLocation(xAtOffset, line * getLineHeight() - verticalScrollOffset); + } +} +/** + * Scrolls the specified offset into view. + *
+ * + * @param offset offset that should be scolled into view + */ +void showOffset(int offset) { + int line = content.getLineAtOffset(offset); + int lineOffset = content.getOffsetAtLine(line); + int offsetInLine = offset - lineOffset; + String lineText = content.getLine(line); + int xAtOffset = getXAtOffset(lineText, line, offsetInLine); + int clientAreaWidth = getClientArea().width; + int verticalIncrement = getVerticalIncrement(); + int horizontalIncrement = clientAreaWidth / 4; + + if (xAtOffset < 0) { + // always make 1/4 of a page visible + xAtOffset = Math.max(horizontalScrollOffset * -1, xAtOffset - horizontalIncrement); + scrollHorizontalBar(xAtOffset); + } + else + if (xAtOffset > clientAreaWidth) { + // always make 1/4 of a page visible + xAtOffset = Math.min(contentWidth - horizontalScrollOffset, xAtOffset + horizontalIncrement); + scrollHorizontalBar(xAtOffset - clientAreaWidth); + } + if (line < topIndex) { + setVerticalScrollOffset(line * verticalIncrement, true); + } + else + if (line > getBottomIndex()) { + setVerticalScrollOffset((line - getBottomIndex()) * verticalIncrement + verticalScrollOffset, true); + } +} + +/** + * Scrolls the selection into view. + *
+ * + * @exception SWTException
+ * + * @param line line to be measured. + * @param lineIndex index of the line relative to the first kine of the + * document + * @param length number of characters to measure. Tabs are counted + * as one character in this parameter. + * @param gc GC to use for measuring text + * @return width of the text with tabs expanded to tab stops or 0 if the + * length is beyond the text length. + */ +int textWidth(String line, int lineIndex, int length, GC gc) { + StyleRange[] styles = null; + int lineOffset = content.getOffsetAtLine(lineIndex); + StyledTextEvent event = getLineStyleData(lineOffset, line); + + if (event != null) { + styles = filterLineStyles(event.styles); + } + return textWidth(line, lineOffset, 0, length, styles, 0, gc); +} + +/** + * Returns the width of the specified text. Expand tabs to tab stops using + * the widget tab width. + *
+ * + * @param text text to be measured. + * @param lineOffset offset of the first character in the line. + * @param startOffset offset of the character to start measuring and + * expand tabs. + * @param length number of characters to measure. Tabs are counted + * as one character in this parameter. + * @param styles line styles + * @param startXOffset x position of "startOffset" in "text". Used for + * calculating tab stops + * @param gc GC to use for measuring text + * @return width of the text with tabs expanded to tab stops or 0 if the + * startOffset or length is outside the specified text. + */ +int textWidth(String text, int lineOffset, int startOffset, int length, StyleRange[] lineStyles, int startXOffset, GC gc) { + int paintX = 0; + int endOffset = startOffset + length; + int textLength = text.length(); + FontData fontData = gc.getFont().getFontData()[0]; + + if (startOffset < 0 || startOffset >= textLength || startOffset + length > textLength) { + return paintX; + } + for (int i = startOffset; i < endOffset; i++) { + int tabIndex = text.indexOf(TAB, i); + // is tab not present or past the rendering range? + if (tabIndex == -1 || tabIndex > endOffset) { + tabIndex = endOffset; + } + if (tabIndex != i) { + String tabSegment = text.substring(i, tabIndex); + if (lineStyles != null) { + paintX = styledTextWidth(tabSegment, lineOffset + i, lineStyles, paintX, 0, gc, false); + } + else { + fontData = setLineFont(gc, fontData, SWT.NORMAL); + paintX += gc.stringExtent(tabSegment).x; + } + if (tabIndex != endOffset && tabWidth > 0) { + paintX += tabWidth; + paintX -= (startXOffset + paintX) % tabWidth; + } + i = tabIndex; + } + else + if (tabWidth > 0) { + paintX += tabWidth; + paintX -= (startXOffset + paintX) % tabWidth; + } + } + return paintX; +} + +/** + * Measures the text as rendered at the specified location. Expand tabs to tab stops using + * the widget tab width. + *
+ * + * @param text text to draw + * @param textStartOffset offset of the first character in text relative + * to the first character in the document + * @param lineStyles styles of the line + * @param paintX x location to start drawing at + * @param paintY y location to draw at + * @param gc GC to draw on + * @param drawText true=measure and draw text, false=measure text only + * @return x location where drawing stopped or 0 if the startOffset or + * length is outside the specified text. + */ +int styledTextWidth(String text, int textStartOffset, StyleRange[] lineStyles, int paintX, int paintY, GC gc, boolean drawText) { + FontData fontData = gc.getFont().getFontData()[0]; + String textSegment; + int textLength = text.length(); + int textIndex = 0; + + for (int styleIndex = 0; styleIndex < lineStyles.length; styleIndex++) { + StyleRange style = lineStyles[styleIndex]; + int styleSegmentStart = style.start - textStartOffset; + int textEnd; + if (styleSegmentStart + style.length < 0) { + continue; + } + if (styleSegmentStart >= textLength) { + break; + } + // is there a style for the current string position? + if (textIndex < styleSegmentStart) { + fontData = setLineFont(gc, fontData, SWT.NORMAL); + textSegment = text.substring(textIndex, styleSegmentStart); + if (drawText) { + gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true); + } + paintX += gc.stringExtent(textSegment).x; + textIndex = styleSegmentStart; + } + textEnd = Math.min(textLength, styleSegmentStart + style.length); + fontData = setLineFont(gc, fontData, style.fontStyle); + textSegment = text.substring(textIndex, textEnd); + if (drawText) { + gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true); + } + paintX += gc.stringExtent(textSegment).x; + textIndex = textEnd; + } + // is there unmeasured and unstyled text? + if (textIndex < textLength) { + fontData = setLineFont(gc, fontData, SWT.NORMAL); + textSegment = text.substring(textIndex, textLength); + if (drawText) { + gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true); + } + paintX += gc.stringExtent(textSegment).x; + } + return paintX; +} + +/** + * Updates the selection and caret position depending on the text change. + * 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. + *
+ * + * @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 + redrawRange(selection.x, startOffset - selection.x, true); + } + if (selection.y > startOffset + replacedLength) { + // clear selection fragment after text change + int netNewLength = newLength - replacedLength; + int redrawStart = startOffset + newLength; + redrawRange(redrawStart, selection.y + netNewLength - redrawStart, true); + } + if (selection.y > startOffset && selection.x < startOffset + replacedLength) { + // selection intersects replaced text. set caret behind text change + caretOffset = selection.x = selection.y = startOffset + newLength; + // always update the caret location. fixes 1G8FODP + setCaretLocation(); + } + else { + // move selection to keep same text selected + internalSetSelection(selection.x + newLength - replacedLength, selection.y - selection.x); + // always update the caret location. fixes 1G8FODP + setCaretLocation(); + } +} +/** + * 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 + */ +boolean isSingleLine() { + return (getStyle() & SWT.SINGLE) != 0; +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java new file mode 100755 index 0000000000..839366cbf2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java @@ -0,0 +1,177 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import org.eclipse.swt.events.*; + +public interface StyledTextContent { + +/** + * Called by StyledText to add itself as an Observer to content changes. + * Implementors should send a TextChangedEvent when changes to the content + * occur. The widget only updates the screen when it receives a TextChangedEvent. + *
+ * + * @param listener the listener + * @exception IllegalArgumentException
+ * + * @return the number of characters in the content. + */ +public int getCharCount(); + +/** + * Return the line at the given character offset without delimiters. + *
+ * + * @param offset offset of the line to return. Does not include delimiters + * of preceeding lines. Offset 0 is the first character of the document. + * @return the line text without delimiters + */ +public String getLine(int offset); + +/** + * Return the line index at the given character offset. + *
+ * + * @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: + *
+ * + * @return the number of lines. For example: + *
+ * + * @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. + *
+ * NOTE: When there is no text (i.e., no lines), getOffsetAtLine(0) + * is a valid call that should return 0. + *
+ * + * @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: + *+ * + * @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. + *
+ * + * @param listener the listener + * @exception IllegalArgumentException
+ * Implementors have to notify TextChanged listeners after the content has + * been updated. The TextChangedEvent should be set as follows: + *
+ * + * @param text the new text + */ +public void setText (String text); +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java new file mode 100755 index 0000000000..52c6ca7c8d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java @@ -0,0 +1,31 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; + +/** + * + */ +class StyledTextEvent extends Event { + // used by LineStyleEvent + StyleRange[] styles; + // used by LineBackgroundEvent + Color lineBackground; + // used by TextChangedEvent + int replacedCharCount; + int newCharCount; + int replacedLineCount; + int newLineCount; + +StyledTextEvent (StyledTextContent content) { + super(); + data = content; +} +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java new file mode 100755 index 0000000000..7514f0bb44 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java @@ -0,0 +1,62 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import org.eclipse.swt.events.*; +import org.eclipse.swt.widgets.*; +import java.util.*; + +class StyledTextListener extends TypedListener { +/** + */ +StyledTextListener(EventListener listener) { + super(listener); +} +/** + * Process StyledText events by invoking the event's handler. + */ +public void handleEvent(Event e) { + TextChangedEvent textChangedEvent; + + switch (e.type) { + case StyledText.ExtendedModify: + ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e); + ((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent); + break; + + case StyledText.LineGetStyle: + LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e); + ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent); + ((StyledTextEvent) e).styles = lineStyleEvent.styles; + break; + + case StyledText.LineGetBackground: + LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e); + ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent); + ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground; + break; + + case StyledText.VerifyKey: + VerifyEvent verifyEvent = new VerifyEvent(e); + ((VerifyKeyListener) eventListener).verifyKey(verifyEvent); + e.doit = verifyEvent.doit; + break; + + + case StyledText.TextReplaced: + textChangedEvent = new TextChangedEvent((StyledTextContent)e.data, (StyledTextEvent) e); + ((TextChangedListener) eventListener).textReplaced(textChangedEvent); + break; + + case StyledText.TextSet: + textChangedEvent = new TextChangedEvent((StyledTextContent)e.data, (StyledTextEvent) e); + ((TextChangedListener) eventListener).textSet(textChangedEvent); + break; + } +} +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java new file mode 100755 index 0000000000..f9e18e66ef --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java @@ -0,0 +1,344 @@ +package org.eclipse.swt.custom; + +import java.io.*; +import java.util.*; +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.layout.*; +import org.eclipse.swt.custom.*; +import org.eclipse.swt.printing.*; + +class StyledTextPrinter { + class RTFState { + int fontStyle; + int foreground; + int background; + } + Vector savedState = new Vector(); + + StyledText styledText; + Printer printer; + GC gc; + + String rtf; + int index, end; + StringBuffer wordBuffer; + + /* We can optimize for fonts because we know styledText only has one font. + * As soon as we know the font name and point size, we will create and store + * Fonts for the following styles: normal, bold, italic, and bold italic. + */ + Font fontTable[][] = new Font[1][4]; + boolean creatingFontTable = false; + String fontName; + int fontSize; + int currentFontStyle = SWT.NORMAL; + int currentFont = -1; + int defaultFont = -1; + + Vector colorTable = new Vector(); + boolean creatingColorTable = false; + int red, green, blue; + int currentForeground = -1; + int currentBackground = -1; + + String tabs = ""; + int lineHeight = 0; + int tabWidth = 0; + int leftMargin, rightMargin, topMargin, bottomMargin; + int x, y; + + public StyledTextPrinter(StyledText styledText) { + this.styledText = styledText; + } + + public void print() { + printer = new Printer(); + if (printer.startJob("StyledText")) { + Rectangle clientArea = printer.getClientArea(); + Rectangle trim = printer.computeTrim(0, 0, 0, 0); + Point dpi = printer.getDPI(); + leftMargin = dpi.x + trim.x; // one inch from left side of paper + rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one inch from right side of paper + topMargin = dpi.y + trim.y; // one inch from top edge of paper + bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one inch from bottom edge of paper + + /* Create a buffer for computing tab width. */ + int tabSize = styledText.getTabs(); + StringBuffer tabBuffer = new StringBuffer(tabSize); + for (int i = 0; i < tabSize; i++) tabBuffer.append(' '); + tabs = tabBuffer.toString(); + + /* Get RTF from the StyledText, determine what fonts and colors we need, and print. */ + gc = new GC(printer); + x = leftMargin; + y = topMargin; + printStyledTextRTF(); + printer.endJob(); + + /* Cleanup */ + gc.dispose(); + for (int i = 0; i < 4; i++) { + fontTable[currentFont][i].dispose(); + } + for (int i = 0; i < colorTable.size(); i++) { + ((Color)colorTable.elementAt(i)).dispose(); + } + } + printer.dispose(); + } + + void printStyledTextRTF() { + rtf = styledText.getRtf(); + end = rtf.length(); + index = 0; + wordBuffer = new StringBuffer(); + while (index < end) { + char c = rtf.charAt(index); + index++; + switch (c) { + case '\\': + printWordBuffer(); + parseControlWord(); + break; + case '{': + printWordBuffer(); + saveState(); + break; + case '}': + printWordBuffer(); + restoreState(); + break; + case 0x0a: + case 0x0d: + printWordBuffer(); + break; + default: + parseChar(c); + } + } + } + + void parseControlWord() { + if (index >= end) return; + char c = rtf.charAt(index); + index++; + if (!Character.isLetter(c)) { + handleControlSymbol(c); + return; + } + StringBuffer controlWord = new StringBuffer(); + controlWord.append(c); + while (index < end) { + c = rtf.charAt(index); + index++; + if (!Character.isLetter(c)) break; + controlWord.append(c); + } + boolean isNegative = false; + if (c == '-') { + isNegative = true; + c = rtf.charAt(index); + index++; + } + boolean hasParameter = false; + StringBuffer paramBuffer = new StringBuffer(); + int parameter = 0; + if (Character.isDigit(c)) { + hasParameter = true; + paramBuffer.append(c); + while (index < end) { + c = rtf.charAt(index); + index++; + if (!Character.isDigit(c)) break; + paramBuffer.append(c); + } + try { + parameter = Integer.valueOf(paramBuffer.toString()).intValue(); + } catch (NumberFormatException e) {} + if (isNegative) parameter = -parameter; + } + if (c != ' ') index--; + if (hasParameter) { + handleControlWord(controlWord.toString(), parameter); + } else { + handleControlWord(controlWord.toString()); + } + } + + void parseChar(char c) { + if (c == 0) return; + if (c == ';') { + if (creatingFontTable) { + fontName = wordBuffer.toString(); + wordBuffer = new StringBuffer(); + creatingFontTable = false; + return; + } + if (creatingColorTable) { + colorTable.addElement(new Color(printer, red, green, blue)); + red = green = blue = 0; + return; + } + } + if (c != '\t') { + wordBuffer.append(c); + } + if (!Character.isLetterOrDigit(c) && !creatingFontTable) { + printWordBuffer(); + if (c == '\t') { + x += tabWidth; + } + } + } + + void printWordBuffer() { + if (wordBuffer.length() > 0) { + String word = wordBuffer.toString(); + int wordWidth = gc.stringExtent(word).x; + if (x + wordWidth > rightMargin) { + /* word doesn't fit on current line, so wrap */ + newline(); + } + gc.drawString(word, x, y, true); + x += wordWidth; + wordBuffer = new StringBuffer(); + } + } + + void handleControlSymbol(char c) { + switch (c) { + case '\\': + case '{': + case '}': + parseChar(c); + } + } + + void handleControlWord(String controlWord) { + if (controlWord.equals("par")) newline(); + else if (controlWord.equals("b")) setFontStyle(currentFontStyle | SWT.BOLD); + else if (controlWord.equals("i")) setFontStyle(currentFontStyle | SWT.ITALIC); + else if (controlWord.equals("fnil")) setFont(defaultFont); + else if (controlWord.equals("fonttbl")) createFontTable(); + else if (controlWord.equals("colortbl")) createColorTable(); + } + + void handleControlWord(String controlWord, int parameter) { + if (controlWord.equals("highlight")) setBackground(parameter); + else if (controlWord.equals("cf")) setForeground(parameter); + else if (controlWord.equals("b")) setFontStyle(currentFontStyle & ~SWT.BOLD); + else if (controlWord.equals("i")) setFontStyle(currentFontStyle & ~SWT.ITALIC); + else if (controlWord.equals("f")) setFont(parameter); + else if (controlWord.equals("fs")) setFontSize(parameter); + else if (controlWord.equals("red")) red = parameter; + else if (controlWord.equals("green")) green = parameter; + else if (controlWord.equals("blue")) blue = parameter; + else if (controlWord.equals("deff")) setDefaultFont(parameter); + } + + void setDefaultFont(int number) { + defaultFont = number; + } + + void setFont(int number) { + currentFont = number; + } + + void createFontTable() { + creatingFontTable = true; + currentFont = 0; + } + + void setFontSize(int size) { + fontSize = size / 2; + createFonts(); + } + + void createFonts() { + if (fontName != null && fontSize != -1) { + // currentFont must already be set + fontTable[currentFont][0] = new Font(printer, fontName, fontSize, SWT.NORMAL); + fontTable[currentFont][1] = new Font(printer, fontName, fontSize, SWT.BOLD); + fontTable[currentFont][2] = new Font(printer, fontName, fontSize, SWT.ITALIC); + fontTable[currentFont][3] = new Font(printer, fontName, fontSize, SWT.BOLD | SWT.ITALIC); + setFontStyle(SWT.NORMAL); + } + } + + void setFontStyle(int style) { + // currentFont must already be set + Font font; + if ((style & SWT.BOLD) != 0) { + if ((style & SWT.ITALIC) != 0) { + font = fontTable[currentFont][3]; + } else { + font = fontTable[currentFont][1]; + } + } else if ((style & SWT.ITALIC) != 0) { + font = fontTable[currentFont][2]; + } else { + font = fontTable[currentFont][0]; + } + gc.setFont(font); + tabWidth = gc.stringExtent(tabs).x; + lineHeight = gc.getFontMetrics().getHeight(); + currentFontStyle = style; + } + + void createColorTable() { + creatingColorTable = true; + red = green = blue = 0; + } + + void setForeground(int color) { + if (color != currentForeground) { + // colors must already be in table + gc.setForeground((Color)colorTable.elementAt(color)); + currentForeground = color; + } + } + + void setBackground(int color) { + if (color != currentBackground) { + // colors must already be in table + gc.setBackground((Color)colorTable.elementAt(color)); + currentBackground = color; + } + } + + void newline() { + x = leftMargin; + y += lineHeight; + if (y + lineHeight > bottomMargin) { + printer.endPage(); + if (index + 1 < end) { + y = topMargin; + printer.startPage(); + } + } + } + + void saveState() { + RTFState state = new RTFState(); + state.fontStyle = currentFontStyle; + state.foreground = currentForeground; + state.background = currentBackground; + savedState.addElement(state); + } + + void restoreState() { + if (savedState.isEmpty()) return; + if (creatingColorTable) { + setForeground(0); + setBackground(1); + creatingColorTable = false; + } + RTFState state = (RTFState)savedState.remove(savedState.size() - 1); + setFontStyle(state.fontStyle); + if (state.foreground != -1) setForeground(state.foreground); + if (state.background != -1) setBackground(state.background); + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java new file mode 100755 index 0000000000..a17caf48d7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java @@ -0,0 +1,179 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.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. +* +*
Here is an example of using a TableEditor:
+*
+*/
+public class TableEditor extends ControlEditor {
+
+ Table table;
+ TableItem item;
+ int column = -1;
+ Listener columnListener;
+/**
+* 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 Listener() {
+ public void handleEvent(Event e) {
+ resize ();
+ }
+ };
+
+}
+Rectangle computeBounds () {
+ if (item == null || column == -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+
+ Rectangle cell = item.getBounds(column);
+ Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, cell.height);
+ Rectangle area = table.getClientArea();
+ if (cell.x < area.x + area.width) {
+ if (cell.x + cell.width > area.x + area.width) {
+ cell.width = area.width - cell.x;
+ }
+ }
+
+ if (grabHorizontal){
+ editorRect.width = Math.max(cell.width, minimumWidth);
+ }
+
+ if (horizontalAlignment == SWT.RIGHT) {
+ editorRect.x += cell.width - editorRect.width;
+ } else if (horizontalAlignment == SWT.LEFT) {
+ // do nothing - cell.x is the right answer
+ } else { // default is CENTER
+ editorRect.x += (cell.width - editorRect.width)/2;
+ }
+
+ return editorRect;
+}
+/**
+ * Removes all associations between the TableEditor and the cell in the table. The
+ * Table and the editor Control are not disposed.
+ */
+public void dispose () {
+
+ if (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeListener(SWT.Resize, columnListener);
+ tableColumn.removeListener(SWT.Move, columnListener);
+ }
+
+ table = 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;
+}
+public void setColumn(int column) {
+
+ if (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeListener(SWT.Resize, columnListener);
+ tableColumn.removeListener(SWT.Move, columnListener);
+ this.column = -1;
+ }
+
+ if (column < 0 || column >= table.getColumnCount()) return;
+
+ this.column = column;
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.addListener(SWT.Resize, columnListener);
+ tableColumn.addListener(SWT.Move, columnListener);
+}
+/**
+* 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;
+}
+public void setItem (TableItem item) {
+ this.item = item;
+}
+public void setEditor (Control editor) {
+ TableItem item = null;
+ if (table.getItemCount() > 0) {
+ item = table.getItem(0);
+ }
+ this.setEditor(editor, item, 0);
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+*
+* Table table = new Table(parent, SWT.FULL_SELECTION);
+* TableEditor editor = new TableEditor (table);
+* table.addSelectionListener (new SelectionAdapter() {
+* public void widgetSelected(SelectionEvent e) {
+*
+* // Clean up any previous editor control
+* Control oldEditor = editor.getEditor();
+* if (oldEditor != null)
+* oldEditor.dispose();
+*
+* // Identify the selected row
+* int index = table.getSelectionIndex ();
+* if (index == -1) return;
+* TableItem item = table.getItem (index);
+*
+* // The control that will be the editor must be a child of the Table
+* Text text = new Text(table, SWT.NONE);
+*
+* //The text editor must have the same size as the cell and must
+* //not be any smaller than 50 pixels.
+* editor.horizontalAlignment = SWT.LEFT;
+* editor.grabHorizontal = true;
+* editor.minimumWidth = 50;
+*
+* // Open the text editor in the second column of the selected row.
+* editor.setEditor (text, item, 1);
+*
+* // Assign focus to the text control
+* text.setFocus ();
+* }
+* });
+*
Note: The Control provided as the editor must 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); + super.setEditor(editor); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java new file mode 100755 index 0000000000..8ab256b7e1 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java @@ -0,0 +1,701 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import java.util.Enumeration; +import java.util.Vector; +import org.eclipse.swt.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.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. + * + *
+ * + * @param listener the selection listener + * + * @exception SWTError
+ * + * @param listener the tree listener + * + * @exception SWTError
+ * Calculate the preferred size of the widget based + * on the current contents. The hint arguments allow + * a specific client area width and/or height to be + * requested. The hints may be honored depending on + * the platform and the layout. + * + * @param wHint the width hint (can be SWT.DEFAULT) + * @param hHint the height hint (can be SWT.DEFAULT) + * @return a point containing the preferred size of the widget including trim + * + * @exception SWTError
+ * Trim is widget specific and may include scroll + * bars and menu bar in addition to other trimmings + * that are outside of the widget's client area. + * + * @param x the x location of the client area + * @param y the y location of the client area + * @param width the width of the client area + * @param height the height of the client area + * @return a rectangle containing the trim of the widget. + * + * @exception SWTError
+ * If an item is selected, it is deselected. + * If an item is not selected, it remains unselected. + * + * @exception SWTError
+ * @return the number of items in the widget + */ +public int getItemCount () { + return items.length; +} + +/** + * Gets the height of one item. + *
+ * 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 SWTError
+ * @return the items in the widget + * + */ +public TableTreeItem [] getItems () { + TableTreeItem[] newItems = new TableTreeItem[items.length]; + System.arraycopy(items, 0, newItems, 0, items.length); + return newItems; +} + +/** + * Gets the selected items. + *
+ * This operation will fail if the selected + * items cannot be queried from the OS. + * + * @return the selected items in the widget + * + * @exception SWTError
+ * 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 SWTError
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) { + for (int i = 0; i < items.length; i++) { + if (item == items[i]) return i; + } + return -1; +} + +void onDispose() { + inDispose = true; + for (int i = 0; i < items.length; i++) { + items[i].dispose(); + } + inDispose = false; + if (plusImage != null) plusImage.dispose(); + if (minusImage != null) minusImage.dispose(); + if (sizeImage != null) sizeImage.dispose(); + plusImage = minusImage = sizeImage = null; +} + +void onResize () { + Rectangle area = getClientArea(); + table.setBounds(0, 0, area.width, area.height); +} + +void onSelection (Event e) { + Event event = new Event(); + TableItem tableItem = (TableItem)e.item; + TableTreeItem item = getItem(tableItem); + event.item = item; + + if (e.type == SWT.Selection + && e.detail == SWT.CHECK + && item != null) { + event.detail = SWT.CHECK; + item.checked = tableItem.getChecked(); + } + notifyListeners(e.type, event); +} +public TableTreeItem getItem(Point point) { + TableItem item = table.getItem(point); + if (item == null) return null; + return getItem(item); + +} +TableTreeItem getItem(TableItem tableItem) { + if (tableItem == null) return null; + for (int i = 0; i < items.length; i++) { + TableTreeItem item = items[i].getItem(tableItem); + if (item != null) return item; + } + return null; +} +void onFocusIn () { + table.setFocus(); +} + +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(); + event = new Event(); + event.item = item; + item.setExpanded(!item.getExpanded()); + if (item.getExpanded()) { + notifyListeners(SWT.Expand, event); + } else { + notifyListeners(SWT.Collapse, event); + } + return; + } + } +} + +/** + * Removes all items. + *
+ * This operation will fail when an item + * could not be removed in the OS. + * + * @exception SWTError
+ * + * @param listener the listener + * + * @exception SWTError
+ * If an item is not selected, it is selected. + * If an item is selected, it remains selected. + * + * @exception SWTError
+ * When new color is null, the background reverts + * to the default system color for the widget. + * + * @param color the new color (or null) + * + * @exception SWTError
+ * A disabled widget is typically not selectable from + * the user interface and draws with an inactive or + * grayed look. + * + * @param enabled the new enabled state + * + * @exception SWTError
+ * When new font is null, the font reverts + * to the default system font for the widget. + * + * @param font the new font (or null) + * + * @exception SWTError
+ * @return the widget foreground color + * + * @exception SWTError
+ * Every control has an optional pop up menu that is + * displayed when the user requests a popup menu for + * the control. The sequence of key strokes/button + * presses/button releases that is used to request + * a pop up menu is platform specific. + * + * @param menu the new pop up menu + * + * @exception SWTError
+ * @param items new selection + * + * @exception SWTError
+ * @param string the new tool tip text (or null) + * + * @exception SWTError
+ * @param item the item to be shown + * + * @exception SWTError
+ * 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 SWTError
The TableTreeEditor performs the same functions as the TableEditor except that the cell is in +* a TableTree. Refer to TableEditor for additional information. The significant differnce is that +* the Control provided as the editor must be created with its parent being the Table +* control that is underneath the TableTree specified in the TableTreeEditor constructor. +* The Table can be obtained from the TableTree using tableTree.getTable(). +* +*/ +public class TableTreeEditor { + + public int horizontalAlignment = SWT.CENTER; + public boolean grabHorizontal = false; + public int minimumWidth = 0; + + TableTreeItem item; + TableEditor editor; +/** +* Creates a TableTreeEditor for the specified TableTree. +* +* @param tableTree the TableTree Control above which this editor will be displayed +* +*/ +public TableTreeEditor (TableTree tableTree) { + editor = new TableEditor (tableTree.getTable ()); +} +/** + * Removes all associations between the TableTreeEditor and the cell in the TableTree. The + * TableTree and the editor Control are not disposed. + */ +public void dispose () { + + editor.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 editor.getColumn (); +} +/** +* Returns the Control that is displayed above the cell being edited. +* +* @return the Control that is displayed above the cell being edited +*/ +public Control getEditor () { + return editor.getEditor (); +} +/** +* 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; +} +/** +* Specify the Control that is to be displayed and the cell in the TableTree that it is to be +* positioned above. +* +*
Note: The Control provided as the editor must be created with its parent being the Table +* control that is underneath the TableTree specified in the TableTreeEditor constructor. +* The Table can be obtained from the TableTree using tableTree.getTable(). +* +* @param editor the Control that is displayed above the cell being edited +* @param item the TableTreeItem 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 control, TableTreeItem item, int column) { + if (control == null) { + editor.setEditor (null, null, -1); + return; + } + + this.item = item; + TableItem tableItem = item.tableItem; + editor.horizontalAlignment = horizontalAlignment; + editor.grabHorizontal = grabHorizontal; + editor.minimumWidth = minimumWidth; + + editor.setEditor (control, tableItem, column); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java new file mode 100755 index 0000000000..a73f8f6433 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java @@ -0,0 +1,561 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; + +/** + * A TableTreeItem is a selectable user interface object + * that represents an item in a heirarchy of items in a + * TableTree. + */ +public class TableTreeItem extends Item { + TableItem tableItem; + TableTree parent; + TableTreeItem parentItem; + TableTreeItem [] items = TableTree.EMPTY_ITEMS; + String[] texts = TableTree.EMPTY_TEXTS; + Image[] images = TableTree.EMPTY_IMAGES; + boolean expanded; + boolean checked; + +/** + * Create a new instance of a root item. + * + * @param parent the TableTree that contains this root item + * @param style the bitwise OR'ing of widget styles + */ +public TableTreeItem(TableTree parent, int style) { + this (parent, style, parent.getItemCount()); +} + +/** + * Create a new instance of a root item in the position + * indicated by the specified index. + * + * @param parent the TableTree that contains this root item + * @param style the bitwise OR'ing of widget styles + * @param index specifies the position of this item in the TableTree + * relative to other root items + */ +public TableTreeItem(TableTree parent, int style, int index) { + this (parent, null, style, index); +} + +/** + * Create a new instance of a sub item. + * + * @param parent this item's parent in the hierarchy of TableTree items + * @param style the bitwise OR'ing of widget styles + */ +public TableTreeItem(TableTreeItem parent, int style) { + this (parent, style, parent.getItemCount()); +} + +/** + * Create a new instance of a sub item in the position + * indicated by the specified index. + * + * @param parent this item's parent in the hierarchy of TableTree items + * @param style the bitwise OR'ing of widget styles + * @param index specifies the position of this item in the TableTree + * relative to other children of the same parent + */ +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 == null) { + + /* Root items are visible immediately */ + int tableIndex = parent.addItem(this, index); + tableItem = new TableItem(parent.getTable(), style, tableIndex); + tableItem.setData(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 == null) { + int itemHeight = parent.getItemHeight(); + parent.sizeImage = new Image(null, 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); + } + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + TableTreeItem.this.widgetDisposed(e); + } + }); +} +void addCheck() { + Table table = parent.getTable(); + if ((table.getStyle() & SWT.CHECK) == 0) return; + tableItem.setChecked(checked); +} +void addItem(TableTreeItem item, int index) { + if (item == null) throw new SWTError(SWT.ERROR_NULL_ARGUMENT); + if (index < 0 || index > items.length) throw new SWTError(SWT.ERROR_INVALID_ARGUMENT); + + /* Now that item has a sub-node it must indicate that it can be expanded */ + if (items.length == 0 && index == 0) { + if (tableItem != 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); +} + +/** + * Gets the widget bounds at the specified index. + *
+ * @return the widget bounds at the specified index + * + * @exception SWTError
+* @return the item checked state. +* +* @exception SWTError
+ * This method gets the Display that is associated + * with the widget. + * + * @return the widget data + * + * @exception SWTError
+ * @return a boolean that is the expanded state of the widget + */ +public boolean getExpanded () { + return expanded; +} + +/** + * Gets the first image. + *
+ * 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 + */ +public Image getImage () { + return getImage(0); +} + +/** + * Gets the image at the specified index. + *
+ * 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) { + if (0 < index && index < images.length) return images[index]; + return null; +} + +int getIndent() { + if (parentItem == null) return 0; + return parentItem.getIndent() + 1; +} + +/** + * Gets the number of sub items. + *
+ * @return the number of sub items + */ +public int getItemCount () { + return items.length; +} + +/** + * Gets the sub items. + *
+ * @return the sub items + */ +public TableTreeItem[] getItems () { + TableTreeItem[] newItems = new TableTreeItem[items.length]; + System.arraycopy(items, 0, newItems, 0, items.length); + return newItems; +} + +TableTreeItem getItem(TableItem tableItem) { + if (tableItem == null) return null; + if (this.tableItem == tableItem) return this; + for (int i = 0; i < items.length; i++) { + TableTreeItem item = items[i].getItem(tableItem); + if (item != null) return item; + } + return null; +} + +/** + * Gets the parent. + *
+ * @return the parent + */ +public TableTree getParent () { + return parent; +} + +/** + * Gets the parent item. + *
+ * @return the parent item. + */ +public TableTreeItem getParentItem () { + return parentItem; +} + +/** + * Gets the first item text. + *
+ * @return the item text at index 0, which can be null + * + * @exception SWTError
+ * 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) { + if (0 <= index && index < texts.length) return texts[index]; + return null; +} + +boolean getVisible () { + return tableItem != null; +} + +/** + * Gets the index of the specified item. + * + *
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) { + for (int i = 0; i < items.length; i++) { + if (items[i] == item) return i; + } + return -1; +} + +int expandedIndexOf (TableTreeItem item) { + int index = 0; + for (int i = 0; i < items.length; i++) { + if (items[i] == 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; +} + +void widgetDisposed(DisposeEvent e) { + for (int i = items.length - 1; i >= 0; i--) { + items[i].dispose(); + } + if (!parent.inDispose) { + if (parentItem != null) { + parentItem.removeItem(this); + } else { + parent.removeItem(this); + } + if (tableItem != null) tableItem.dispose(); + } + items = null; + parentItem = null; + parent = null; + images = null; + texts = null; + tableItem = null; +} + +void removeItem(TableTreeItem item) { + int index = 0; + while (index < items.length && items[index] != item) index++; + if (index == 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 == 0) { + if (tableItem != null) tableItem.setImage(0, null); + } +} + +/** +* Sets the checked state. +*
+* @param checked the new checked state. +* +* @exception SWTError
+ * @param expanded the new expanded state. + * + * @exception SWTError
+ * 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 SWTError
+ * 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 + */ +public void setImage (Image image) { + setImage(0, image); +} + +/** + * Sets the widget text. + *
+ * + * 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 SWTError
+ * + * 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 SWTError
+ * + * @param source the object that will be sending the TextChangedEvent, cannot be null + */ +public TextChangedEvent(StyledTextContent source) { + super(source); +} +TextChangedEvent(StyledTextContent source, StyledTextEvent e) { + super(source); + start = e.start; + replacedCharCount = e.replacedCharCount; + newCharCount = e.newCharCount; + replacedLineCount = e.replacedLineCount; + newLineCount = e.newLineCount; + replacedText = e.text; +} + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java new file mode 100755 index 0000000000..3a523f1e2c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java @@ -0,0 +1,41 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import java.util.*; + +/** + * The StyledText widget implements this listener to receive + * notification when changes to the model occur. + * It is not intended for use by users of the StyledText widget + * or implementors of StyledTextContent. Users should listen to + * the ModifyEvent or ExtendedModifyEvent that is sent by the StyledText + * widget to receive text change notifications. + */ + +public interface TextChangedListener extends EventListener { +/** + * @param event.start replace start offset (input) + * @param event.replacedText text being replaced (input) + * @param event.replacedCharCount length of text being replaced (input) + * @param event.newCharCount length of new text (input) + * @param event.replacedLineCount number of lines replaced (input) + * @param event.newLineCount number of new lines (input) + */ +public void textReplaced(TextChangedEvent event); + +/** + * @param event.start replace start offset (input) + * @param event.replacedText text being replaced (input) + * @param event.replacedCharCount length of text being replaced (input) + * @param event.newCharCount length of new text (input) + * @param event.replacedLineCount number of lines replaced (input) + * @param event.newLineCount number of new lines (input) + */ +public void textSet(TextChangedEvent event); +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java new file mode 100755 index 0000000000..b00e3d77ff --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java @@ -0,0 +1,163 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.events.*; + +/** +* +* 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. +* +*
Here is an example of using a TreeEditor:
+*
+*/
+public class TreeEditor extends ControlEditor {
+ Tree tree;
+ TreeItem item;
+ TreeListener treeListener;
+/**
+* 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;
+ treeListener = new TreeAdapter () {
+ final Runnable runnable = new Runnable() {
+ public void run() {
+ if (TreeEditor.this.tree.isDisposed() || editor == null) return;
+ resize();
+ editor.setVisible(true);
+ }
+ };
+ public void treeCollapsed(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TreeEditor.this.tree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ public void treeExpanded(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TreeEditor.this.tree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ };
+ tree.addTreeListener(treeListener);
+}
+Rectangle computeBounds () {
+ if (item == null || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+
+ Rectangle cell = item.getBounds();
+ 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, cell.height);
+
+ if (grabHorizontal) {
+ editorRect.width = Math.max(area.x + area.width - cell.x, minimumWidth);
+ }
+
+ if (horizontalAlignment == SWT.RIGHT) {
+ editorRect.x = Math.max(cell.x, cell.x + cell.width - editorRect.width);
+ } else if (horizontalAlignment == SWT.LEFT) {
+ // do nothing - cell.x is the right answer
+ } else { // default is CENTER
+ editorRect.x = Math.max(cell.x, cell.x + (cell.width - editorRect.width)/2);
+ }
+
+ return editorRect;
+}
+/**
+ * Removes all associations between the TreeEditor and the cell in the tree. The
+ * tree and the editor Control are not disposed.
+ */
+public void dispose () {
+ if (treeListener != null)
+ tree.removeTreeListener(treeListener);
+ treeListener = null;
+ tree = null;
+ item = null;
+ super.dispose();
+}
+/**
+* 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;
+}
+public void setItem (TreeItem item) {
+ this.item = item;
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+*
+* Tree tree = new Tree(parent, SWT.FULL_SELECTION);
+* TreeEditor editor = new TreeEditor (tree);
+* tree.addSelectionListener (new SelectionAdapter() {
+* public void widgetSelected(SelectionEvent e) {}
+*
+* // Clean up any previous editor control
+* Control oldEditor = editor.getEditor();
+* if (oldEditor != null)
+* oldEditor.dispose();
+*
+* // Identify the selected row
+* int index = tree.getSelectionIndex ();
+* if (index == -1) return;
+* TreeItem item = tree.getItem (index);
+*
+* // The control that will be the editor must be a child of the Tree
+* Text text = new Text(tree, SWT.NONE);
+*
+* //The text editor must have the same size as the cell and must
+* //not be any smaller than 50 pixels.
+* editor.horizontalAlignment = SWT.LEFT;
+* editor.grabHorizontal = true;
+* editor.minimumWidth = 50;
+*
+* // Open the text editor on the selected row.
+* editor.setEditor (text, item);
+*
+* // Assign focus to the text control
+* text.setFocus ();
+* }
+* });
+*
Note: The Control provided as the editor must 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 +*/ +public void setEditor (Control editor, TreeItem item) { + setItem (item); + super.setEditor (editor); +} +public void setEditor (Control editor) { + TreeItem item = null; + if (tree.getItemCount() != 0) { + item = tree.getItems()[0]; + } + this.setEditor(editor, item); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java new file mode 100755 index 0000000000..a5766fc2d8 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java @@ -0,0 +1,19 @@ +package org.eclipse.swt.custom; +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp 2000, 2001 + */ + +/* Imports */ +import org.eclipse.swt.events.*; +import java.util.*; + +public interface VerifyKeyListener extends EventListener { +/** + * @param event.character the character that was typed (input) + * @param event.keyCode the key code that was typed (input) + * @param event.stateMask the state of the keyboard (input) + * @param event.doit processed or not (output) + */ +public void verifyKey (VerifyEvent event); +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java new file mode 100755 index 0000000000..aafe3891fa --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java @@ -0,0 +1,477 @@ +package org.eclipse.swt.custom; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.*; +import org.eclipse.swt.events.*; + +public class ViewForm extends 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; + + /** + * Color of innermost line of drop shadow border. + */ + public static RGB borderInsideRGB = new RGB (132, 130, 132); + /** + * Color of middle line of drop shadow border. + */ + public static RGB borderMiddleRGB = new RGB (143, 141, 138); + /** + * Color of outermost line of drop shadow border. + */ + public static RGB borderOutsideRGB = new RGB (171, 168, 165); + + // SWT widgets + private Control topLeft; + private Control topCenter; + private Control topRight; + private Control content; + + // Configuration and state info + private boolean separateTopCenter = false; + private int drawLine1 = -1; + private int drawLine2 = -1; + + private boolean showBorder = false; + + private int BORDER_TOP = 0; + private int BORDER_BOTTOM = 0; + private int BORDER_LEFT = 0; + private int BORDER_RIGHT = 0; + + private Color borderColor1; + private Color borderColor2; + private Color borderColor3; + + private Rectangle oldArea; +/** +* Creates a ViewForm. +*
+* This method creates a child widget using style bits +* to select a particular look or set of properties. +* +* @param parent a composite widget (cannot be null) +* @param style the bitwise OR'ing of widget styles +* +* @exception SWTError
dragStart : When a drag operation is about to being, the following fields apply: + *
dragSetData : When requesting data from the DragSource, the following fields apply: + *
dragFinished : When a drag operation has been completed, the following fields apply: + *
DragSourceListener
class provides event notification to the application for DragSource events.
+ *
+ * When the user drops data on a DropTarget
, the application which defines the DragSource
+ * must provide the dropped data by implementing dragSetData
.
After the drop has completed successfully or has been aborted, the application which defines the
+ * DragSource
is required to take the appropriate cleanup action. In the case of a successful
+ * move operation, the application must remove the data that was transferred.
The following fields in the DragSourceEvent apply: + *
The following fields in the DragSourceEvent apply: + *
The following fields in the DragSourceEvent apply: + *
When in dragEnter(), dragOver(), dragLeave(), dragOperationChanged(), dropAccept(), + * the following fields apply: + *
Control
+ * Control
+ * detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes list
.
+ *
+ * When in drop(), the following fields apply: + *
Control
+ * Control
+ * data
field
+ * DropTargetListener
class provides event notification to the application for DropTarget events.
+ *
+ * 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, change the operation + * that will be performed or stop any drop from happening on the current target.
+ * + *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.
+ * + */ +public interface DropTargetListener extends EventListener { +/** + * The cursor has entered the drop target boundaries. + * + *The following fields in the DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * DragSource
can support
+ * DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
)
+ * The application can change the operation that will be performed by modifying the detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes
list.
The following fields in the DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * DragSource
can support
+ * DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
)
+ * The application can change the operation that will be performed by modifying the detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes
list.
The following fields in the DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * DragSource
can support
+ * DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
)
+ * The application can change the operation that will be performed by modifying the detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes
list.
The following fields in the DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * DragSource
can support
+ * DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
)
+ * The application can change the operation that will be performed by modifying the detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes
list.
The following fields in DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * The application can refuse to perform the drop operation by setting the detail field to DND.DROP_NONE.
+ * + * @param event the information associated with the drop event + * + */ + +public void drop(DropTargetEvent event); +/** + * The drop target is given the chance to change the nature of the drop. It can veto the drop by setting the + *event.detail
field to DND.DROP_NONE
, it can change the data of data that will be
+ * dropped by setting the event.currentDataType
field to a different value or it can change the
+ * operation that will be performed by changing the event.detail
field.
+ *
+ * The following fields in the DropTargetEvent apply: + *
DropTarget Control
+ * DropTarget Control
+ * DragSource
can support
+ * DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
)
+ * The application can change the operation that will be performed by modifying the detail
field
+ * but the choice must be one of the values in the operations
field.
+ * The application can also change the type of data being requested by modifying the currentDataTypes
+ * field but the value must be one of the values in the dataTypes
list.
DragSource
defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ * This class defines the following items:
Control
that the user clicks on to intiate a drag;
+ * 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 + * but it can also be dropped on another application such as an external Text editor.
+ * + *The application supplies the content of the data being transferred by implementing the interface
+ * DragSourceListener
which uses the class DragSourceEvent
.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.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() == 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 == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ *
+ *
+ *
+ * +* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addDragListener(DragSourceListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragStart, typedListener); + addListener (DND.DragSetData, typedListener); + addListener (DND.DragEnd, typedListener); +} +static int checkStyle (int style) { + if (style == SWT.NONE) return DND.DROP_MOVE; + return style; +} +private int convertProcCallback(int widget, int pSelection, int pTarget, int pType_return, int ppValue_return, int pLength_return, int pFormat_return, int max_length, int client_data, int request_id) { + /* + pSelection - atom specifying which property is being used to transfer the selection (only support _MOTIF_DROP) + pTarget - atom specifying the type in which the requestor wants the information + pType_return - [out] type atom that data has been converted to (usually the same as pTarget) + ppValue_return - [out] set to a pointer to a block of memory + pLength_return - [out] number of elements in the array + pFormat_return - [out] size in bits of each element in the array + + */ + + if (pSelection == 0 ) + return 0; + + // is this a drop? + int[] selection = new int[1]; + OS.memmove(selection, pSelection, 4); + int motifDropAtom = Transfer.registerType("_MOTIF_DROP\0"); + if (selection[0] != motifDropAtom) return 0; + + // get the target value from pTarget + int[] target = new int[1]; + OS.memmove(target, pTarget, 4); + + // handle the "Move" case + if (target[0] == Transfer.registerType("DELETE\0")) { // DELETE corresponds to a Move request + OS.memmove(pType_return,new int[]{Transfer.registerType("NULL\0")}, 4); + OS.memmove(ppValue_return, new int[]{0}, 4); + OS.memmove(pLength_return, new int[]{0}, 4); + OS.memmove(pFormat_return, new int[]{8}, 4); + return 1; + } + + // do we support the requested data type? + boolean dataMatch = true; + TransferData transferData = new TransferData(); + transferData.type = target[0]; + for (int i = 0; i < transferAgents.length; i++){ + if (transferAgents[i].isSupportedType(transferData)){ + dataMatch = true; + break; + } + } + if (!dataMatch) return 0; + + DNDEvent event = new DNDEvent(); + event.widget = control; + //event.time = ??; + event.dataType = transferData; + try { + notifyListeners(DND.DragSetData,event); + } catch (Throwable err) { + return 0; + } + + if (event.data == null) return 0; + + Transfer transferAgent = null; + for (int i = 0; i < transferAgents.length; i++){ + if (transferAgents[i].isSupportedType(transferData)){ + transferAgent = transferAgents[i]; + break; + } + } + if (transferAgent == null) return 0; + + transferAgent.javaToNative(event.data, transferData); + if (transferData.result == 1){ + OS.memmove(ppValue_return, new int[]{transferData.pValue}, 4); + OS.memmove(pType_return, new int[]{transferData.type}, 4); + OS.memmove(pLength_return, new int[]{transferData.length}, 4); + OS.memmove(pFormat_return, new int[]{transferData.format}, 4); + return 1; + } else { + OS.memmove(ppValue_return, new int[]{0}, 4); + OS.memmove(pLength_return, new int[]{0}, 4); + OS.memmove(pFormat_return, new int[]{8}, 4); + return 0; + } +} +private void drag() { + if (transferAgents == null) + return; + + // Current event must be a Button Press event + Display display = control.getDisplay (); + if (display.xEvent.type != OS.ButtonPress) return; + + DNDEvent event = new DNDEvent(); + event.widget = this; + event.time = display.xEvent.pad2; + event.doit = true; + + try { + notifyListeners(DND.DragStart, event); + } catch (Throwable e) { + event.doit = false; + } + + if (!event.doit) { + int time = display.xEvent.pad2; // corresponds to time field in XButtonEvent + int[] args = new int[]{ OS.XmNdragOperations, OS.XmDROP_NOOP}; + int dc = OS.XmGetDragContext(control.handle, time); + if (dc != 0){ + OS.XtSetValues(dc, args, args.length /2); + } else { + dc = OS.XmDragStart(this.control.handle, display.xEvent, args, args.length/2); + } + return; + } + + // set the protocol (optional) + // not implemented + + // create pixmaps for icons (optional) + // not implemented + + // Copy targets to global memory + TransferData[] transferData = new TransferData[0]; + for (int i = 0; i < transferAgents.length; i++){ + TransferData[] data = transferAgents[i].getSupportedTypes(); + TransferData[] newTransferData = new TransferData[transferData.length + data.length]; + System.arraycopy(transferData, 0, newTransferData, 0, transferData.length); + System.arraycopy(data, 0, newTransferData, transferData.length, data.length); + transferData = newTransferData; + } + int[] dataTypes = new int[transferData.length]; + for (int i = 0; i < transferData.length; i++){ + dataTypes[i] = transferData[i].type; + } + int pExportTargets = OS.XtMalloc(dataTypes.length * 4); + OS.memmove(pExportTargets, dataTypes, dataTypes.length * 4); + + if (convertProc == null) + convertProc = new Callback(this, "convertProcCallback", 10); + if (convertProc == null) return; + + int[] args = new int[]{ + OS.XmNexportTargets, pExportTargets, + OS.XmNnumExportTargets, dataTypes.length, + OS.XmNdragOperations, opToOsOp(getStyle()), + OS.XmNconvertProc, convertProc.getAddress(), + OS.XmNoperationCursorIcon, 0, + OS.XmNsourceCursorIcon, 0, + OS.XmNstateCursorIcon, 0, + OS.XmNclientData, 0, + OS.XmNblendModel, OS.XmBLEND_ALL + }; + + // look for existing drag contexts + int time = display.xEvent.pad2; // corresponds to time field in XButtonEvent + dragContext = OS.XmGetDragContext(control.handle, time); + if (dragContext != 0){ + OS.XtSetValues(dragContext, args, args.length /2); + } else { + dragContext = OS.XmDragStart(this.control.handle, display.xEvent, args, args.length / 2); + myDrag = true; + } + OS.XtFree(pExportTargets); + if (dragContext == 0) return; + + // register a call back to clean up when drop is done (optional) + if (dragDropFinish == null) + dragDropFinish = new Callback(this, "dragDropFinishCallback", 3); + OS.XtAddCallback(dragContext, OS.XmNdragDropFinishCallback, dragDropFinish.getAddress(), 0); + + // register a call back to tell user what happened (optional) + if (dropFinish == null) + dropFinish = new Callback(this, "dropFinishCallback", 3); + OS.XtAddCallback(dragContext, OS.XmNdropFinishCallback, dropFinish.getAddress(), 0); + return; +} + +private int dragDropFinishCallback(int widget, int client_data, int call_data) { + + // uncomment the following code when we allow users to specify their own source icons + // release the pre set source icon + //int pSourceIcon = OS.XtMalloc(4); + //int[] args = new int[]{OS.XmNsourceCursorIcon, pSourceIcon}; + //OS.XtGetValues(control.handle, args, args.length / 2); + //int[] sourceIcon = new int[1]; + //OS.memmove(sourceIcon, pSourceIcon, 4); + //if (sourceIcon[0] != 0) + //OS.XtDestroyWidget(sourceIcon[0]); + //OS.XtFree(pSourceIcon); + + dragContext = 0; + + if (convertProc != null) + convertProc.dispose(); + convertProc = null; + + if (dragDropFinish != null) + dragDropFinish.dispose(); + dragDropFinish = null; + + if (dropFinish != null) + dropFinish.dispose(); + dropFinish = null; + + return 0; +} +private int dropFinishCallback(int widget, int client_data, int call_data) { + + XmDropFinishCallback data = new XmDropFinishCallback(); + OS.memmove(data, call_data, XmDropFinishCallback.sizeof); + + if (data.dropAction != OS.XmDROP || data.dropSiteStatus != OS.XmDROP_SITE_VALID) return 0; + + DNDEvent event = new DNDEvent(); + event.widget = this.control; + event.time = data.timeStamp; + event.detail = osOpToOp(data.operation); + event.doit = (data.completionStatus != 0); + + try { + notifyListeners(DND.DragEnd,event); + } catch (Throwable err) { + } + + return 0; +} +public Control getControl () { + return control; +} +/** +* Gets the Display. +*/ +public Display getDisplay () { + + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); +} +public Transfer[] getTransfer(){ + return transferAgents; +} +private void onDispose() { + + // Check if there is a drag in progress and cancel it + //if (dragContext != 0 && myDrag) + // OS.XmDragCancel(dragContext); + + if (convertProc != null) + convertProc.dispose(); + convertProc = null; + + if (dragDropFinish != null) + dragDropFinish.dispose(); + dragDropFinish = null; + + if (dropFinish != null) + dropFinish.dispose(); + dropFinish = null; + + if (control != null && controlListener != null) { + control.removeListener(SWT.Dispose, controlListener); + control.removeListener(SWT.DragDetect, controlListener); + } + control = null; + controlListener = null; + transferAgents = null; +} +private byte opToOsOp(int operation){ + byte osOperation = OS.XmDROP_NOOP; + + if ((operation & DND.DROP_COPY) == DND.DROP_COPY) + osOperation |= OS.XmDROP_COPY; + if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE) + osOperation |= OS.XmDROP_MOVE; + if ((operation & DND.DROP_LINK) == DND.DROP_LINK) + osOperation |= OS.XmDROP_LINK; + + return osOperation; +} +private int osOpToOp(byte osOperation){ + int operation = DND.DROP_NONE; + + if ((osOperation & OS.XmDROP_COPY) == OS.XmDROP_COPY) + operation |= DND.DROP_COPY; + if ((osOperation & OS.XmDROP_MOVE) == OS.XmDROP_MOVE) + operation |= DND.DROP_MOVE; + if ((osOperation & OS.XmDROP_LINK) == OS.XmDROP_LINK) + operation |= DND.DROP_LINK; + + return operation; +} +/** +* Removes the listener. +*
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragSetData, listener);
+ removeListener (DND.DragEnd, listener);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..cdef0449d4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,540 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * Class DropTarget
defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ *
This class identifies the Control
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 Control
and a DropTarget
.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).
+ * 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);
+ *
+ *
+ * The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface DropTargetListener
which uses the class
+ * DropTargetEvent
. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the event.detail
field or the
+ * event.currentDataType
field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ *
+ *
+ *
+ * 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 == 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
+ * }
+ * });
+ *
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addDropListener(DropTargetListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragEnter, typedListener); + addListener (DND.DragLeave, typedListener); + addListener (DND.DragOver, typedListener); + addListener (DND.DragOperationChanged, typedListener); + addListener (DND.Drop, typedListener); + addListener (DND.DropAccept, typedListener); + +} +static int checkStyle (int style) { + if (style == SWT.NONE) return DND.DROP_MOVE; + return style; +} +private int dragProcCallback(int widget, int client_data, int call_data) { + + XmDragProcCallback callbackData = new XmDragProcCallback(); + OS.memmove(callbackData, call_data, XmDragProcCallback.sizeof); + + if (callbackData.reason == OS.XmCR_DROP_SITE_ENTER_MESSAGE){ + releaseDropInfo(); + + // get the export targets + int ppExportTargets = OS.XtMalloc(4); + int pNumExportTargets = OS.XtMalloc(4); + int[] args = new int[]{ + OS.XmNexportTargets, ppExportTargets, + OS.XmNnumExportTargets, pNumExportTargets + }; + + OS.XtGetValues(callbackData.dragContext, args, args.length / 2); + int[] numExportTargets = new int[1]; + OS.memmove(numExportTargets, pNumExportTargets, 4); + OS.XtFree(pNumExportTargets); + int[] pExportTargets = new int[1]; + OS.memmove(pExportTargets, ppExportTargets, 4); + OS.XtFree(ppExportTargets); + int[] exportTargets = new int[numExportTargets[0]]; + OS.memmove(exportTargets, pExportTargets[0], 4*numExportTargets[0]); + //?OS.XtFree(pExportTargets[0]); + + for (int i = 0, length = exportTargets.length; i < length; i++){ + for (int j = 0, length2 = transferAgents.length; j < length2; j++){ + TransferData transferData = new TransferData(); + transferData.type = exportTargets[i]; + if (transferAgents[j].isSupportedType(transferData)) { + TransferData[] newDataTypes = new TransferData[dataTypes.length + 1]; + System.arraycopy(dataTypes, 0, newDataTypes, 0, dataTypes.length); + newDataTypes[dataTypes.length] = transferData; + dataTypes = newDataTypes; + break; + } + } + } + } + + DNDEvent event = new DNDEvent(); + event.widget = this.control; + event.time = callbackData.timeStamp; + short [] root_x = new short [1]; + short [] root_y = new short [1]; + OS.XtTranslateCoords (this.control.handle, (short) callbackData.x, (short) callbackData.y, root_x, root_y); + event.x = root_x[0]; + event.y = root_y[0]; + event.dataTypes = dataTypes; + event.feedback = DND.FEEDBACK_SELECT; + event.operations = osOpToOp(callbackData.operations); + event.dataType = selectedDataType; + event.detail = osOpToOp(callbackData.operation); + + try { + switch (callbackData.reason) { + case OS.XmCR_DROP_SITE_ENTER_MESSAGE : + if (dataTypes.length > 0) { + event.dataType = dataTypes[0]; + } + notifyListeners(DND.DragEnter, event); + effect.show(event.feedback, event.x, event.y); + break; + + case OS.XmCR_DROP_SITE_MOTION_MESSAGE : + notifyListeners(DND.DragOver, event); + effect.show(event.feedback, event.x, event.y); + break; + case OS.XmCR_OPERATION_CHANGED : + notifyListeners(DND.DragOperationChanged, event); + effect.show(event.feedback, event.x, event.y); + break; + case OS.XmCR_DROP_SITE_LEAVE_MESSAGE : + event.detail = DND.DROP_NONE; + notifyListeners(DND.DragLeave, event); + effect.show(DND.FEEDBACK_NONE, 0, 0); + return 0; + } + } catch (Throwable err) { + callbackData.dropSiteStatus = OS.XmDROP_SITE_INVALID; + callbackData.operation = opToOsOp(DND.DROP_NONE); + OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof); + return 0; + } + + selectedDataType = null; + for (int i = 0; i < dataTypes.length; i++) { + if (dataTypes[i].equals(event.dataType)) { + selectedDataType = event.dataType; + break; + } + } + int lastOperation = DND.DROP_NONE; + if (selectedDataType != null && ((event.detail & osOpToOp(callbackData.operations)) == event.detail)) { + lastOperation = event.detail; + } + + callbackData.dropSiteStatus = OS.XmDROP_SITE_VALID; + callbackData.operation = opToOsOp(lastOperation); + OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof); + + return 0; +} +private int dropProcCallback(int widget, int client_data, int call_data) { + + effect.show(DND.FEEDBACK_NONE, 0, 0); + + droppedEventData = new XmDropProcCallback(); + OS.memmove(droppedEventData, call_data, XmDropProcCallback.sizeof); + + DNDEvent event = new DNDEvent(); + event.widget = this.control; + event.time = droppedEventData.timeStamp; + short [] root_x = new short [1]; + short [] root_y = new short [1]; + OS.XtTranslateCoords (this.control.handle, (short) droppedEventData.x, (short) droppedEventData.y, root_x, root_y); + event.x = root_x[0]; + event.y = root_y[0]; + event.dataTypes = dataTypes; + event.operations = osOpToOp(droppedEventData.operations); + event.dataType = selectedDataType; + event.detail = osOpToOp(droppedEventData.operation); + + try { + notifyListeners(DND.DropAccept,event); + } catch (Throwable err) { + event.detail = DND.DROP_NONE; + event.dataType = null; + } + + selectedDataType = null; + for (int i = 0; i < dataTypes.length; i++) { + if (dataTypes[i].equals(event.dataType)) { + selectedDataType = event.dataType; + break; + } + } + int lastOperation = DND.DROP_NONE; + if (selectedDataType != null && ((event.detail & osOpToOp(droppedEventData.operations)) == event.detail)) { + lastOperation = event.detail; + } + + if (lastOperation == DND.DROP_NONE) { + // this was not a successful drop + int[] args = new int[] {OS.XmNtransferStatus, OS.XmTRANSFER_FAILURE, + OS.XmNnumDropTransfers, 0}; + dropTransferObject = OS.XmDropTransferStart(droppedEventData.dragContext, args, args.length / 2); + return 0; + } + + // ask drag source for dropped data + int[] transferEntries = new int[2]; + transferEntries[0] = 0; + transferEntries[1] = selectedDataType.type; + + int pTransferEntries = OS.XtMalloc(transferEntries.length * 4); + OS.memmove(pTransferEntries, transferEntries, transferEntries.length * 4); + if (transferProc == null) + transferProc = new Callback(this, "transferProcCallback", 7); + + if (transferProc != null){ + int[] args = new int[] {OS.XmNdropTransfers, pTransferEntries, + OS.XmNnumDropTransfers, transferEntries.length / 2, + OS.XmNtransferProc, transferProc.getAddress()}; + + dropTransferObject = OS.XmDropTransferStart(droppedEventData.dragContext, args, args.length / 2); + OS.XtFree(pTransferEntries); + } + + return 0; +} +/** + * 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; +} +public Display getDisplay () { + + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); +} +/** + * Returns the list of data types that can be transferred to this DropTarget. + * + * @return the list of data types that can be transferred to this DropTarget + * + */ +public Transfer[] getTransfer(){ + return transferAgents; +} +public void notifyListeners (int eventType, Event event) { + Point coordinates = new Point(event.x, event.y); + coordinates = control.toControl(coordinates); + if (this.control instanceof Tree) { + event.item = ((Tree)control).getItem(coordinates); + } + if (this.control instanceof Table) { + event.item = ((Table)control).getItem(coordinates); + } + super.notifyListeners(eventType, event); +} +private void onDispose() { + + if (dropProc != null) + dropProc.dispose(); + dropProc = null; + + if (transferProc != null) + transferProc.dispose(); + transferProc = null; + + if (dragProc != null) + dragProc.dispose(); + dragProc = null; + //if (control != null && !control.isDisposed()){ + // OS.XmDropSiteUnregister(control.handle); + //} + if (controlListener != null) { + control.removeListener(SWT.Dispose, controlListener); + } + controlListener = null; + control = null; + transferAgents = null; +} +private byte opToOsOp(int operation){ + byte osOperation = OS.XmDROP_NOOP; + + if ((operation & DND.DROP_COPY) == DND.DROP_COPY) + osOperation |= OS.XmDROP_COPY; + if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE) + osOperation |= OS.XmDROP_MOVE; + if ((operation & DND.DROP_LINK) == DND.DROP_LINK) + osOperation |= OS.XmDROP_LINK; + + return osOperation; +} +private int osOpToOp(byte osOperation){ + int operation = DND.DROP_NONE; + + if ((osOperation & OS.XmDROP_COPY) == OS.XmDROP_COPY) + operation |= DND.DROP_COPY; + if ((osOperation & OS.XmDROP_MOVE) == OS.XmDROP_MOVE) + operation |= DND.DROP_MOVE; + if ((osOperation & OS.XmDROP_LINK) == OS.XmDROP_LINK) + operation |= DND.DROP_LINK; + + return operation; +} +private void releaseDropInfo(){ + selectedDataType = null; + dataTypes = new TransferData[0]; + droppedEventData = null; + dropTransferObject = 0; +} +/** +* Adds the listener to receive events. +*
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.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);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+
+ // register data types
+ TransferData[] transferData = new TransferData[0];
+ for (int i = 0, length = transferAgents.length; i < length; i++){
+ TransferData[] data = transferAgents[i].getSupportedTypes();
+ TransferData[] newTransferData = new TransferData[transferData.length + data.length];
+ System.arraycopy(transferData, 0, newTransferData, 0, transferData.length);
+ System.arraycopy(data, 0, newTransferData, transferData.length, data.length);
+ transferData = newTransferData;
+ }
+
+ int[] atoms = new int[transferData.length];
+ for (int i = 0, length = transferData.length; i < length; i++){
+ atoms[i] = transferData[i].type;
+ }
+
+ // Copy import targets to global memory
+ int pImportTargets = OS.XtMalloc(atoms.length * 4);
+ OS.memmove(pImportTargets, atoms, atoms.length * 4);
+
+ int[] args = new int[]{
+ OS.XmNimportTargets, pImportTargets,
+ OS.XmNnumImportTargets, atoms.length
+ };
+
+ OS.XmDropSiteUpdate(control.handle, args, args.length / 2);
+
+ OS.XtFree(pImportTargets);
+
+}
+private int transferProcCallback(int widget, int client_data, int pSelection, int pType, int pValue, int pLength, int pFormat) {
+
+ int[] type = new int[1];
+ OS.memmove(type, pType, 4);
+
+ // get dropped data object
+ Transfer transferAgent = null;
+ TransferData transferData = new TransferData();
+ transferData.type = type[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ transferAgent = transferAgents[i];
+ break;
+ }
+ }
+ if (transferAgent != null) {
+ transferData.pValue = pValue;
+ int[] length = new int[1];
+ OS.memmove(length, pLength, 4);
+ transferData.length = length[0];
+ int[] format = new int[1];
+ OS.memmove(format, pFormat, 4);
+ transferData.format = format[0];
+ Object data = transferAgent.nativeToJava(transferData);
+
+ OS.XtFree(transferData.pValue); //?? Should we be freeing this, and what about the other memory?
+
+ // notify listeners of drop
+ DNDEvent event = new DNDEvent();
+ event.widget = this.control;
+ event.time = droppedEventData.timeStamp;
+ short [] root_x = new short [1];
+ short [] root_y = new short [1];
+ OS.XtTranslateCoords (this.control.handle, (short) droppedEventData.x, (short) droppedEventData.y, root_x, root_y);
+ event.x = root_x[0];
+ event.y = root_y[0];
+ event.dataTypes = dataTypes;
+ event.operations = osOpToOp(droppedEventData.operations);
+ event.dataType = transferData;
+ event.detail = osOpToOp(droppedEventData.operation);
+ event.data = data;
+
+ try {
+ notifyListeners(DND.Drop,event);
+ } catch (Throwable err) {
+ event.detail = DND.DROP_NONE;
+ }
+
+ if ((event.detail & DND.DROP_MOVE) == DND.DROP_MOVE) {
+ OS.XmDropTransferAdd(dropTransferObject, new int[]{0, Transfer.registerType("DELETE\0")}, 1);
+ }
+ }
+
+ return 0;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..8b70854312
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list\0";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+public static FileTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative(Object object, TransferData transferData) {
+
+ if (object == null || !(object instanceof String[])) return;
+
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "file:";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += files[i]+"\r";
+ }
+ nativeFormat += "\0";
+ // pass byte array on to super to convert to native
+ super.javaToNative(nativeFormat.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ String string = new String(data);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length()) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+
+ String fileName = string.substring(start, end);
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..af09aac900
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..231db14dc3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..12afd23a9d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private TextTransfer() {
+}
+public static TextTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..98f63bd8bc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.motif.OS;
+import org.eclipse.swt.widgets.Display;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class Transfer {
+abstract public TransferData[] getSupportedTypes();
+abstract public boolean isSupportedType(TransferData transferData);
+abstract protected String[] getTypeNames();
+abstract protected int[] getTypeIds();
+abstract protected void javaToNative (Object object, TransferData transferData);
+abstract protected Object nativeToJava(TransferData transferData);
+public static int registerType(String formatName){
+
+ int xDisplay = Display.getDefault().xDisplay; // using default because we don't have a particular widget
+ byte[] bName = Converter.wcsToMbcs (null, formatName, false);
+ int atom = OS.XmInternAtom (xDisplay, bName, false);
+ return atom;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..a73cc97090
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TransferData {
+ public int type;
+
+ // attributes specific to set/get
+ int length;
+ int format;
+ int pValue;
+
+ int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..e0babbfe6f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,100 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ tree.setInsertMark(item, effect == DND.FEEDBACK_INSERT_BEFORE);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..ec66fefb22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class ByteArrayTransfer extends 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 boolean isSupportedType(TransferData transferData){
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+protected void javaToNative (Object object, TransferData transferData){
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = 0;
+ return;
+ }
+ byte[] buffer = (byte[])object;
+// transferData.pValue = OS.XtMalloc(buffer.length + 1);
+// OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+protected Object nativeToJava(TransferData transferData){
+
+ if (transferData.pValue == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.format * transferData.length / 8;
+ byte[] buffer = new byte[size];
+// OS.memmove(buffer, transferData.pValue, size);
+ return buffer;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
new file mode 100755
index 0000000000..a51be325c3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/*
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ */
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+ private int shellHandle;
+
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+
+// int widgetClass = OS.TopLevelShellWidgetClass ();
+// shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
+// OS.XtSetMappedWhenManaged (shellHandle, false);
+// OS.XtRealizeWidget (shellHandle);
+}
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+public void dispose () {
+// if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+// shellHandle = 0;
+ display = null;
+}
+public Object getContents(Transfer transfer) {
+ if (display.isDisposed() ) return null;
+ return null;
+}
+public void setContents(Object[] data, Transfer[] transferAgents){
+}
+/*
+ * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
+ * NOT be used within an application because it provides platform specfic
+ * information.
+ */
+public String[] getAvailableTypeNames() {
+ int[] count = new int[1];
+ int[] max_length = new int[1];
+// int xDisplay = OS.XtDisplay (shellHandle);
+// if (xDisplay == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// int xWindow = OS.XtWindow (shellHandle);
+// if (xWindow == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+ String[] types = new String[count[0]];
+// for (int i = 0; i < count[0]; i++) {
+// byte[] buffer = new byte[max_length[0]];
+// int[] copied_length = new int[1];
+// int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);
+// if (rc == OS.XmClipboardNoData){
+// types[i] = "";
+// continue;
+// }
+// if (rc != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// byte[] buffer2 = new byte[copied_length[0]];
+// System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);
+// types[i] = new String(buffer2);
+// }
+ return types;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
new file mode 100755
index 0000000000..ace4bd062c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,196 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * Class DragSource
defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ *
This class defines the following items:
Control
that the user clicks on to intiate a drag;
+ * 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 + * but it can also be dropped on another application such as an external Text editor.
+ * + *The application supplies the content of the data being transferred by implementing the interface
+ * DragSourceListener
which uses the class DragSourceEvent
.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.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() == 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 == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ *
+ *
+ *
+ * +* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addDragListener(DragSourceListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragStart, typedListener); + addListener (DND.DragSetData, typedListener); + addListener (DND.DragEnd, typedListener); +} +static int checkStyle (int style) { + if (style == SWT.NONE) return DND.DROP_MOVE; + return style; +} + + + + + +public Control getControl () { + return control; +} +/** +* Gets the Display. +*/ +public Display getDisplay () { + + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); +} +public Transfer[] getTransfer(){ + return transferAgents; +} + + + +/** +* Removes the listener. +*
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragSetData, listener);
+ removeListener (DND.DragEnd, listener);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..f5184be09b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,214 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * Class DropTarget
defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ *
This class identifies the Control
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 Control
and a DropTarget
.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).
+ * 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);
+ *
+ *
+ * The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface DropTargetListener
which uses the class
+ * DropTargetEvent
. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the event.detail
field or the
+ * event.currentDataType
field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ *
+ *
+ *
+ * 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 == 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
+ * }
+ * });
+ *
+* +* @param listener the listener +* +* @exception SWTError(ERROR_THREAD_INVALID_ACCESS) +* when called from the wrong thread +* @exception SWTError(ERROR_WIDGET_DISPOSED) +* when the widget has been disposed +* @exception SWTError(ERROR_NULL_ARGUMENT) +* when listener is null +*/ +public void addDropListener(DropTargetListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragEnter, typedListener); + addListener (DND.DragLeave, typedListener); + addListener (DND.DragOver, typedListener); + addListener (DND.DragOperationChanged, typedListener); + addListener (DND.Drop, typedListener); + addListener (DND.DropAccept, typedListener); + +} +static int checkStyle (int style) { + if (style == SWT.NONE) return DND.DROP_MOVE; + return style; +} + + +/** + * 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; +} +public Display getDisplay () { + + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); +} +/** + * Returns the list of data types that can be transferred to this DropTarget. + * + * @return the list of data types that can be transferred to this DropTarget + * + */ +public Transfer[] getTransfer(){ + return transferAgents; +} +public void notifyListeners (int eventType, Event event) { + Point coordinates = new Point(event.x, event.y); + coordinates = control.toControl(coordinates); + if (this.control instanceof Tree) { + event.item = ((Tree)control).getItem(coordinates); + } + if (this.control instanceof Table) { + event.item = ((Table)control).getItem(coordinates); + } + super.notifyListeners(eventType, event); +} + + + + +/** +* Adds the listener to receive events. +*
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.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);
+}
+public void setTransfer(Transfer[] transferAgents){
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..8b70854312
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list\0";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+public static FileTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative(Object object, TransferData transferData) {
+
+ if (object == null || !(object instanceof String[])) return;
+
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "file:";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += files[i]+"\r";
+ }
+ nativeFormat += "\0";
+ // pass byte array on to super to convert to native
+ super.javaToNative(nativeFormat.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ String string = new String(data);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length()) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+
+ String fileName = string.substring(start, end);
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..af09aac900
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..231db14dc3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..12afd23a9d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private TextTransfer() {
+}
+public static TextTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..be1aee9ab1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class Transfer {
+abstract public TransferData[] getSupportedTypes();
+abstract public boolean isSupportedType(TransferData transferData);
+abstract protected String[] getTypeNames();
+abstract protected int[] getTypeIds();
+abstract protected void javaToNative (Object object, TransferData transferData);
+abstract protected Object nativeToJava(TransferData transferData);
+public static int registerType(String formatName){
+ return 0;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..a73cc97090
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TransferData {
+ public int type;
+
+ // attributes specific to set/get
+ int length;
+ int format;
+ int pValue;
+
+ int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..f78887e054
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,102 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setInsertMark(item, effect == DND.FEEDBACK_INSERT_AFTER);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+private void setInsertMark (TreeItem item, boolean after) {
+ // not currently implemented
+}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..8f819f1abe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,130 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * The class ByteArrayTransfer
provides a platform specific mechanism for transforming
+ * a Java array of bytes into a format that can be passed around in a Drag and Drop operation and vice
+ * versa.
+ *
+ *
This abstract class can be subclassed to provided utilities for transforming Java data types + * into the byte array based platform specific drag and drop data types. See TextTransfer and + * FileTransfer for examples. If the data you are transferring does not map to a byte array, + * you should sub-class Transfer directly and do your own mapping to the platform data types.
+ * + */ +public abstract class ByteArrayTransfer extends 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]; + data[i].formatetc = new FORMATETC(); + data[i].formatetc.cfFormat = types[i]; + data[i].formatetc.dwAspect = COM.DVASPECT_CONTENT; + data[i].formatetc.lindex = -1; + data[i].formatetc.tymed = COM.TYMED_HGLOBAL; + } + + return data; +} +public boolean isSupportedType(TransferData transferData){ + + int[] types = getTypeIds(); + for (int i = 0; i < types.length; i++) { + FORMATETC format = transferData.formatetc; + if (format.cfFormat == types[i] && + (format.dwAspect & COM.DVASPECT_CONTENT) == COM.DVASPECT_CONTENT && + (format.tymed & COM.TYMED_HGLOBAL) == COM.TYMED_HGLOBAL ) + return true; + } + return false; +} +/** + * + * Converts a Java byte array to a platform specific representation of the byte array. + * + *On a successful conversion, the transferData.result field will be set to COM.S_OK. + * If this transfer agent is unable to perform the conversion, the transferData.result field + * will be set to the failure value of COM.DV_E_TYMED.
+ * + * @param object a Java byte array containing the data to be transferred + * + * @param transferData an empty TransferData object; this object will be filled in on return + * + */ +protected void javaToNative (Object object, TransferData transferData){ + if (object == null || !(object instanceof byte[])) { + transferData.result = COM.E_FAIL; + return; + } + + byte[] data = (byte[])object; + + if (isSupportedType(transferData)) { + // Allocate the memory because the caller (DropTarget) has not handed it in + // The caller of this method must release the data when it is done with it. + int size = data.length; + int newPtr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, size); + OS.MoveMemory(newPtr, data, size); + + transferData.stgmedium = new STGMEDIUM(); + transferData.stgmedium.tymed = COM.TYMED_HGLOBAL; + transferData.stgmedium.unionField = newPtr; + transferData.stgmedium.pUnkForRelease = 0; + transferData.result = COM.S_OK; + return; + } + + // did not match the TYMED + transferData.stgmedium = new STGMEDIUM(); + transferData.result = COM.DV_E_TYMED; +} +/** + * + * Converts a platform specific representation of a byte array to a Java byte array. + * + * @param transferData the platform specific representation of the data that has been transferred + * + * @return a Java byte array containing the transferred data if the conversion was successful; otherwise null + * + */ +protected Object nativeToJava(TransferData transferData){ + + if (!isSupportedType(transferData) || transferData.pIDataObject == 0) { + transferData.result = COM.E_FAIL; + return null; + } + + IDataObject data = new IDataObject(transferData.pIDataObject); + data.AddRef(); + + FORMATETC formatetc = transferData.formatetc; + + STGMEDIUM stgmedium = new STGMEDIUM(); + stgmedium.tymed = COM.TYMED_HGLOBAL; + transferData.result = data.GetData(formatetc, stgmedium); + data.Release(); + + if (transferData.result != COM.S_OK) { + return null; + } + + int size = OS.GlobalSize(stgmedium.unionField); + byte[] buffer = new byte[size]; + int ptr = OS.GlobalLock(stgmedium.unionField); + OS.MoveMemory(buffer, ptr, size); + OS.GlobalUnlock(ptr); + OS.GlobalFree(stgmedium.unionField); + + return buffer; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java new file mode 100755 index 0000000000..98310a4ba1 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java @@ -0,0 +1,357 @@ +package org.eclipse.swt.dnd; + +import org.eclipse.swt.*; +import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.internal.ole.win32.*; +import org.eclipse.swt.widgets.*; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +/* + * + * IMPORTANT: This class is not intended to be subclassed. + * + */ +public class Clipboard { + + // ole interfaces + private COMObject iUnknown; + private COMObject iDataObject; + private int refCount; + + private final int MAX_RETRIES = 10; + private Transfer[] transferAgents = new Transfer[0]; + private Object[] data = new Object[0]; + +public Clipboard(Display display) { + checkSubclass (); + if (display == null) { + display = Display.getCurrent(); + if (display == null) { + display = Display.getDefault(); + } + } + if (display.getThread() != Thread.currentThread()) { + SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS); + } + + createCOMInterfaces(); + this.AddRef(); +} +protected void checkSubclass () { + String name = getClass().getName (); + String validName = Clipboard.class.getName(); + if (!validName.equals(name)) { + DND.error (SWT.ERROR_INVALID_SUBCLASS); + } +} +public void dispose () { + this.Release(); +} +public Object getContents(Transfer transfer) { + int[] ppv = new int[1]; + int retrys = 0; + while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retrys < MAX_RETRIES) { + retrys++; + } + if (retrys == MAX_RETRIES) return null; + + IDataObject dataObject = new IDataObject(ppv[0]); + + TransferData[] allowed = transfer.getSupportedTypes(); + TransferData match = null; + for (int i = 0; i < allowed.length; i++) { + if (dataObject.QueryGetData(allowed[i].formatetc) == COM.S_OK) { + match = allowed[i]; + break; + } + } + if (match == null) return null; + + match.pIDataObject = ppv[0]; + return transfer.nativeToJava(match); +} +public void setContents(Object[] data, Transfer[] dataTypes){ + + boolean current = (COM.OleIsCurrentClipboard(this.iDataObject.getAddress()) == COM.S_OK); + + if (data == null || dataTypes == null || data.length != dataTypes.length) { + DND.error(SWT.ERROR_INVALID_ARGUMENT); + } + + this.data = data; + this.transferAgents = dataTypes; + + int retries = 0; + int result = 0; + while ((result = COM.OleSetClipboard(this.iDataObject.getAddress())) != COM.S_OK && retries < MAX_RETRIES){ + retries++; + } + if (retries == MAX_RETRIES) { + DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result); + } + + if (COM.OleIsCurrentClipboard(this.iDataObject.getAddress()) != COM.S_OK) return; + + retries = 0; + while ((COM.OleFlushClipboard() != COM.S_OK) && (retries < MAX_RETRIES)) { + retries++; + } + + this.data = new Object[0]; + this.transferAgents = new Transfer[0]; +} +private int AddRef() { + refCount++; + return refCount; +} +private void createCOMInterfaces() { + // register each of the interfaces that this object implements + iUnknown = new COMObject(new int[]{2, 0, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + }; + iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return GetData(args[0], args[1]);} + // method4 GetDataHere - not implemented + public int method5(int[] args) {return QueryGetData(args[0]);} + // method6 GetCanonicalFormatEtc - not implemented + // method7 SetData - not implemented + public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);} + // method9 DAdvise - not implemented + // method10 DUnadvise - not implemented + // method11 EnumDAdvise - not implemented + }; +} +private void disposeCOMInterfaces() { + if (iUnknown != null) + iUnknown.dispose(); + iUnknown = null; + + if (iDataObject != null) + iDataObject.dispose(); + iDataObject = null; +} +private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) { + // only allow getting of data - SetData is not currently supported + if (dwDirection == COM.DATADIR_SET) return COM.E_NOTIMPL; + + // what types have been registered? + TransferData[] allowedDataTypes = new TransferData[0]; + for (int i = 0; i < transferAgents.length; i++){ + TransferData[] formats = transferAgents[i].getSupportedTypes(); + TransferData[] newAllowedDataTypes = new TransferData[allowedDataTypes.length + formats.length]; + System.arraycopy(allowedDataTypes, 0, newAllowedDataTypes, 0, allowedDataTypes.length); + System.arraycopy(formats, 0, newAllowedDataTypes, allowedDataTypes.length, formats.length); + allowedDataTypes = newAllowedDataTypes; + } + + OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC(); + enumFORMATETC.AddRef(); + + FORMATETC[] formats = new FORMATETC[allowedDataTypes.length]; + for (int i = 0; i < formats.length; i++){ + formats[i] = allowedDataTypes[i].formatetc; + } + enumFORMATETC.setFormats(formats); + + COM.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4); + return COM.S_OK; +} +private int GetData(int pFormatetc, int pmedium) { + /* Called by a data consumer to obtain data from a source data object. + The GetData method renders the data described in the specified FORMATETC + structure and transfers it through the specified STGMEDIUM structure. + The caller then assumes responsibility for releasing the STGMEDIUM structure. + */ + if (pFormatetc == 0 || pmedium == 0) return COM.E_INVALIDARG; + + if (QueryGetData(pFormatetc) != COM.S_OK) return COM.DV_E_FORMATETC; + + TransferData transferData = new TransferData(); + transferData.formatetc = new FORMATETC(); + COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof); + transferData.type = transferData.formatetc.cfFormat; + transferData.stgmedium = new STGMEDIUM(); + transferData.result = COM.E_FAIL; + + // get matching transfer agent to perform conversion + int transferIndex = -1; + for (int i = 0; i < transferAgents.length; i++){ + if (transferAgents[i].isSupportedType(transferData)){ + transferIndex = i; + break; + } + } + if (transferIndex == -1) return COM.DV_E_FORMATETC; + + transferAgents[transferIndex].javaToNative(data[transferIndex], transferData); + COM.MoveMemory(pmedium, transferData.stgmedium, STGMEDIUM.sizeof); + return transferData.result; +} +private int QueryGetData(int pFormatetc) { + + if (transferAgents == null) return COM.E_FAIL; + + TransferData transferData = new TransferData(); + transferData.formatetc = new FORMATETC(); + COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof); + transferData.type = transferData.formatetc.cfFormat; + + // is this type supported by the transfer agent? + for (int i = 0; i < transferAgents.length; i++){ + if (transferAgents[i].isSupportedType(transferData)) + return COM.S_OK; + } + + return COM.DV_E_FORMATETC; +} +private int QueryInterface(int riid, int ppvObject) { + + if (riid == 0 || ppvObject == 0) + return COM.E_INVALIDARG; + GUID guid = new GUID(); + COM.MoveMemory(guid, riid, GUID.sizeof); + + if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { + COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + + if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) { + COM.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + + COM.MoveMemory(ppvObject, new int[] {0}, 4); + return COM.E_NOINTERFACE; +} +private int Release() { + refCount--; + if (refCount == 0) { + disposeCOMInterfaces(); + COM.CoFreeUnusedLibraries(); + } + + return refCount; +} + +/* + * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should + * NOT be used within an application because it provides platform specfic + * information. + */ +public String[] getAvailableTypeNames() { + int[] ppv = new int[1]; + int retrys = 0; + while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retrys < MAX_RETRIES) { + retrys++; + } + if (retrys == MAX_RETRIES) return null; + + IDataObject dataObject = new IDataObject(ppv[0]); + + int[] ppFormatetc = new int[1]; + int rc = dataObject.EnumFormatEtc(COM.DATADIR_GET, ppFormatetc); + dataObject.Release(); + if (rc != COM.S_OK) + DND.error(SWT.ERROR_UNSPECIFIED); + + IEnumFORMATETC enum = new IEnumFORMATETC(ppFormatetc[0]); + + // Loop over enumerator and save any types that match what we are looking for + int rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, FORMATETC.sizeof); + int[] pceltFetched = new int[1]; + enum.Reset(); + String[] types = new String[0]; + while (enum.Next(1, rgelt, pceltFetched) == COM.S_OK && pceltFetched[0] == 1) { + FORMATETC formatetc = new FORMATETC(); + COM.MoveMemory(formatetc, rgelt, FORMATETC.sizeof); + int maxSize = 128; + byte[] buffer = new byte[maxSize]; + int size = COM.GetClipboardFormatName(formatetc.cfFormat, buffer, maxSize); + String type = null; + if (size == 0) { + switch (formatetc.cfFormat) { + case COM.CF_HDROP: + type = "CF_HDROP"; + break; + case COM.CF_TEXT: + type = "CF_TEXT"; + break; + case COM.CF_BITMAP: + type = "CF_BITMAP"; + break; + case COM.CF_METAFILEPICT: + type = "CF_METAFILEPICT"; + break; + case COM.CF_SYLK: + type = "CF_SYLK"; + break; + case COM.CF_DIF: + type = "CF_DIF"; + break; + case COM.CF_TIFF: + type = "CF_TIFF"; + break; + case COM.CF_OEMTEXT: + type = "CF_OEMTEXT"; + break; + case COM.CF_DIB: + type = "CF_DIB"; + break; + case COM.CF_PALETTE: + type = "CF_PALETTE"; + break; + case COM.CF_PENDATA: + type = "CF_PENDATA"; + break; + case COM.CF_RIFF: + type = "CF_RIFF"; + break; + case COM.CF_WAVE: + type = "CF_WAVE"; + break; + case COM.CF_UNICODETEXT: + type = "CF_UNICODETEXT"; + break; + case COM.CF_ENHMETAFILE: + type = "CF_ENHMETAFILE"; + break; + case COM.CF_LOCALE: + type = "CF_LOCALE"; + break; + case COM.CF_MAX: + type = "CF_MAX"; + break; + default: + continue; + } + } else { + byte[] buffer2 = new byte[size]; + System.arraycopy(buffer, 0, buffer2, 0, size); + type = new String(buffer2); + } + + String[] newTypes = new String[types.length + 1]; + System.arraycopy(types, 0, newTypes, 0, types.length); + newTypes[types.length] = type; + types = newTypes; + } + OS.GlobalFree(rgelt); + enum.Release(); + + return types; + +} + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java new file mode 100755 index 0000000000..e3437522d0 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java @@ -0,0 +1,437 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.*; +import org.eclipse.swt.ole.win32.*; +import org.eclipse.swt.internal.ole.win32.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.internal.win32.*; + +/** + * + * ClassDragSource
defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ * This class defines the following items:
Control
that the user clicks on to intiate a drag;
+ * 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 + * but it can also be dropped on another application such as an external Text editor.
+ * + *The application supplies the content of the data being transferred by implementing the interface
+ * DragSourceListener
which uses the class DragSourceEvent
.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.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() == 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 == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ *
+ *
+ *
+ * DragSource
to handle dragging from the specified Control
.
+ *
+ * @param control the Control
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
+ *
+ */
+public DragSource(Control control, int style) {
+
+ super (control, checkStyle (style));
+
+ this.control = control;
+
+ createCOMInterfaces();
+
+ this.AddRef();
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ if (event.type == SWT.Dispose){
+ DragSource.this.dispose();
+ }
+ if (event.type == SWT.DragDetect) {
+ DragSource.this.drag();
+ }
+ }
+ };
+ control.addListener (SWT.Dispose, controlListener);
+ control.addListener (SWT.DragDetect, controlListener);
+
+ this.addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event e) {
+ onDispose();
+ }
+ });
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * DropTarget
defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is not intended to be subclassed.
+ *
+ * This class identifies the Control
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 Control
and a DropTarget
.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).
+ * 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);
+ *
+ *
+ * The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface DropTargetListener
which uses the class
+ * DropTargetEvent
. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the event.detail
field or the
+ * event.currentDataType
field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ *
+ *
+ *
+ * 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 == 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
+ * }
+ * });
+ *
DropTarget
to handle dropping on the specified Control
.
+ *
+ * @param control the Control
over which the user positions the cursor to drop 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
+ *
+ */
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ createCOMInterfaces();
+
+ int result = 0;
+ if ((result = COM.CoLockObjectExternal(iDropTarget.getAddress(), true, true)) != COM.S_OK)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP, result);
+ if ((result = COM.RegisterDragDrop( control.handle, iDropTarget.getAddress() )) != COM.S_OK)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP, result);
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ DropTarget.this.dispose();
+ }
+ };
+
+ control.addListener (SWT.Dispose, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ onDispose();
+ }
+ });
+
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * FileTransfer
class is used to transfer files in a drag and drop operation.
+ *
+ */
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+
+private FileTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ *
+ */
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a list of file names to a platform specific representation of these file names.
+ *
+ * On a successful conversion, the transferData.result field will be set to COM.S_OK. + * If this transfer agent is unable to perform the conversion, the transferData.result field + * will be set to the failure value of COM.DV_E_TYMED.
+ * + * @param object a list of file names + * + * @param transferData an empty TransferData 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 (object == null || !(object instanceof String[])) { + transferData.result = COM.E_FAIL; + return; + } + + // build a byte array from data + String[] fileNames = (String[]) object; + int fileNameSize = 0; + byte[][] files = new byte[fileNames.length][]; + for (int i = 0; i < fileNames.length; i++) { + files[i] = (fileNames[i]+'\0').getBytes(); // each name is null terminated + fileNameSize += files[i].length; + } + byte[] buffer = new byte[DROPFILES.sizeof + fileNameSize + 1]; // there is an extra null terminator at the very end + DROPFILES dropfiles = new DROPFILES(); + dropfiles.pFiles = DROPFILES.sizeof; + dropfiles.pt_x = dropfiles.pt_y = 0; + dropfiles.fNC = 0; + dropfiles.fWide = 0; + COM.MoveMemory(buffer, dropfiles, DROPFILES.sizeof); + + int offset = DROPFILES.sizeof; + for (int i = 0; i < fileNames.length; i++) { + System.arraycopy(files[i], 0, buffer, offset, files[i].length); + offset += files[i].length; + } + + // pass byte array on to super to convert to native + super.javaToNative(buffer, transferData); +} +/** + * + * Converts a platform specific representation of a list of file names to a Java array of String. + * + * @param transferData the platform specific representation of the data that has been transferred + * + * @return a Java array of String containing a list of file names if the conversion was successful; otherwise null + * + */ +public Object nativeToJava(TransferData transferData) { + + if (!isSupportedType(transferData) || transferData.pIDataObject == 0) { + transferData.result = COM.E_FAIL; + return null; + } + + // get file names from IDataObject + IDataObject dataObject = new IDataObject(transferData.pIDataObject); + dataObject.AddRef(); + + FORMATETC formatetc = new FORMATETC(); + formatetc.cfFormat = COM.CF_HDROP; + formatetc.ptd = 0; + formatetc.dwAspect = COM.DVASPECT_CONTENT; + formatetc.lindex = -1; + formatetc.tymed = COM.TYMED_HGLOBAL; + + STGMEDIUM stgmedium = new STGMEDIUM(); + stgmedium.tymed = COM.TYMED_HGLOBAL; + + transferData.result = dataObject.GetData(formatetc, stgmedium); + dataObject.Release(); + if (transferData.result != COM.S_OK) { + return null; + } + + // How many files are there? + int count = COM.DragQueryFile(stgmedium.unionField, 0xFFFFFFFF, null, 0); + String[] fileNames = new String[count]; + for (int i = 0; i < count; i++){ + // How long is the name ? + int size = COM.DragQueryFile(stgmedium.unionField, i, null, 0) + 1; + byte[] lpszFile = new byte[size]; + // Get file name and append it to string + COM.DragQueryFile(stgmedium.unionField, i, lpszFile, size); + String fileName = new String(lpszFile); + // remove terminating '\0' + int index = fileName.indexOf("\0"); + fileName = fileName.substring(0, index); + fileNames[i] = fileName; + } + COM.DragFinish(stgmedium.unionField); // frees data associated with HDROP data + return fileNames; +} +protected int[] getTypeIds(){ + return new int[] {COM.CF_HDROP}; +} +protected String[] getTypeNames(){ + return new String[] {"CF_HDROP"}; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java new file mode 100755 index 0000000000..0310b3b42a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java @@ -0,0 +1,157 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.*; +import org.eclipse.swt.ole.win32.*; +import org.eclipse.swt.internal.ole.win32.*; + +final class OleEnumFORMATETC { + + private COMObject iUnknown; + private COMObject iEnumFORMATETC; + + private int refCount; + private int index; + + private FORMATETC[] formats; + +OleEnumFORMATETC() { + + createCOMInterfaces(); + +} +int AddRef() { + refCount++; + return refCount; +} +private void createCOMInterfaces() { + // register each of the interfaces that this object implements + iUnknown = new COMObject(new int[] {2, 0, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + }; + iEnumFORMATETC = new COMObject(new int[] {2, 0, 0, 3, 1, 0, 1}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return Next(args[0], args[1], args[2]);} + public int method4(int[] args) {return Skip(args[0]);} + public int method5(int[] args) {return Reset();} + // method6 Clone - not implemented + }; +} +private void disposeCOMInterfaces() { + + if (iUnknown != null) + iUnknown.dispose(); + iUnknown = null; + + if (iEnumFORMATETC != null) + iEnumFORMATETC.dispose(); + iEnumFORMATETC = null; +} +int getAddress() { + return iEnumFORMATETC.getAddress(); +} +private FORMATETC[] getNextItems(int numItems){ + + if (formats == null || numItems < 1) return null; + + int endIndex = index + numItems - 1; + if (endIndex > (formats.length - 1)) endIndex = formats.length - 1; + if (index > endIndex) return null; + + FORMATETC[] items = new FORMATETC[endIndex - index + 1]; + for (int i = 0; i < items.length; i++){ + items[i] = formats[index]; + index++; + } + + return items; +} +private int Next(int celt, int rgelt, int pceltFetched) { + /* Retrieves the next celt items in the enumeration sequence. + If there are fewer than the requested number of elements left in the sequence, + it retrieves the remaining elements. + The number of elements actually retrieved is returned through pceltFetched + (unless the caller passed in NULL for that parameter). + */ + + if (rgelt == 0) return COM.E_INVALIDARG; + if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG; + + FORMATETC[] nextItems = getNextItems(celt); + if (nextItems != null) { + for (int i = 0; i < nextItems.length; i++) { + COM.MoveMemory(rgelt + i*FORMATETC.sizeof, nextItems[i], FORMATETC.sizeof); + } + + if (pceltFetched != 0) + COM.MoveMemory(pceltFetched, new int[] {nextItems.length}, 4); + + if (nextItems.length == celt) return COM.S_OK; + + } else { + if (pceltFetched != 0) + COM.MoveMemory(pceltFetched, new int[] {0}, 4); + COM.MoveMemory(rgelt, new FORMATETC(), FORMATETC.sizeof); + + } + return COM.S_FALSE; +} +private int QueryInterface(int riid, int ppvObject) { + + if (riid == 0 || ppvObject == 0) return COM.E_NOINTERFACE; + + GUID guid = new GUID(); + COM.MoveMemory(guid, riid, GUID.sizeof); + + if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { + COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIEnumFORMATETC)) { + COM.MoveMemory(ppvObject, new int[] {iEnumFORMATETC.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + COM.MoveMemory(ppvObject, new int[] {0}, 4); + return COM.E_NOINTERFACE; +} +int Release() { + refCount--; + + if (refCount == 0) { + disposeCOMInterfaces(); + COM.CoFreeUnusedLibraries(); + } + + return refCount; +} +private int Reset() { + //Resets the enumeration sequence to the beginning. + index = 0; + return COM.S_OK; +} +void setFormats(FORMATETC[] newFormats) { + formats = newFormats; + index = 0; +} +private int Skip(int celt) { + //Skips over the next specified number of elements in the enumeration sequence. + if (celt < 1 ) return COM.E_INVALIDARG; + + index += celt; + if (index > (formats.length - 1)){ + index = formats.length - 1; + return COM.S_FALSE; + } + return COM.S_OK; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java new file mode 100755 index 0000000000..5abdf1088f --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java @@ -0,0 +1,81 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ + +/** + * + * TheRTFTransfer
class is used to transfer text with the RTF format
+ * in a drag and drop operation.
+ *
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static final String CF_RTF_NAME = "Rich Text Format";
+ private static final int CF_RTF = registerType(CF_RTF_NAME);
+ private static RTFTransfer _instance = new RTFTransfer();
+
+private RTFTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ *
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a Java String to a platform specific representation of the string.
+ *
+ * On a successful conversion, the transferData.result field will be set to OLE.S_OK. + * If this transfer agent is unable to perform the conversion, the transferData.result field + * will be set to the failure value of OLE.DV_E_TYMED.
+ * + * @param object a Java String containing the data to be transferred + * + * @param transferData an empty TransferData 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 (object == null || !(object instanceof String)) return; + + // CF_RTF is stored as a null terminated byte array + // create a byte array from object + String text = (String) object+'\0'; + // pass byte array on to super to convert to native + super.javaToNative(text.getBytes(), transferData); +} +/** + * + * Converts a platform specific representation of a string to a Java String. + * + * @param transferData the platform specific representation of the data that has been transferred + * + * @return a Java String containing the transferred data if the conversion was successful; otherwise null + * + */ +public Object nativeToJava(TransferData transferData){ + // get byte array from super + byte[] buffer = (byte[])super.nativeToJava(transferData); + if (buffer == null) return null; + // convert byte array to a string + String string = new String(buffer); + // remove null terminator + int index = string.indexOf("\0"); + string = string.substring(0, index); + return string; +} +protected int[] getTypeIds(){ + return new int[] {CF_RTF}; +} +protected String[] getTypeNames(){ + return new String[] {"CF_RTF"}; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java new file mode 100755 index 0000000000..5cd21361d0 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java @@ -0,0 +1,61 @@ +package org.eclipse.swt.dnd; + +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.internal.win32.LVITEM; +import org.eclipse.swt.internal.win32.OS; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +class TableDragUnderEffect extends DragUnderEffect { + private Table table; + private TableItem currentItem; + +TableDragUnderEffect(Table table) { + this.table = table; +} +void show(int effect, int x, int y) { + TableItem item = findItem(x, y); + if (item == null) { + effect = DND.FEEDBACK_NONE; + } + setDragUnderEffect(effect, item); +} +private TableItem findItem(int x, int y){ + if (table == null) return null; + Point coordinates = new Point(x, y); + coordinates = table.toControl(coordinates); + TableItem item = table.getItem(coordinates); + if (item != null) return item; + + Rectangle area = table.getClientArea(); + for (int x1 = area.x; x1 < area.x + area.width; x1++) { + coordinates = new Point(x1, y); + coordinates = table.toControl(coordinates); + item = table.getItem(coordinates); + if (item != null) return item; + } + return null; + +} +private void setDragUnderEffect(int effect, TableItem item) { + if (currentItem != item) { + setDropSelection(item); + currentItem = item; + } +} +private void setDropSelection (TableItem item) { + LVITEM lvItem = new LVITEM (); + lvItem.stateMask = OS.LVIS_DROPHILITED; + // remove all drop highlighting + OS.SendMessage (table.handle, OS.LVM_SETITEMSTATE, -1, lvItem); + if (item != null) { + lvItem.state = OS.LVIS_DROPHILITED; + int index = table.indexOf(item); + OS.SendMessage (table.handle, OS.LVM_SETITEMSTATE, index, lvItem); + } +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java new file mode 100755 index 0000000000..85dbdfbbe2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java @@ -0,0 +1,78 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.internal.ole.win32.COM; + +/** + * + * TheTextTransfer
class is used to transfer text in a drag and drop operation.
+ *
+ */
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+private TextTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ *
+ */
+public static TextTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a Java String to a platform specific representation of the string.
+ *
+ * On a successful conversion, the transferData.result field will be set to OLE.S_OK. + * If this transfer agent is unable to perform the conversion, the transferData.result field + * will be set to the failure value of OLE.DV_E_TYMED.
+ * + * @param object a Java String containing the data to be transferred + * + * @param transferData an empty TransferData 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 (object == null || !(object instanceof String)) return; + + // CF_TEXT is stored as a null terminated byte array + // create a byte array from object + String text = (String) object+'\0'; + // pass byte array on to super to convert to native + super.javaToNative(text.getBytes(), transferData); +} +/** + * + * Converts a platform specific representation of a string to a Java String. + * + * @param transferData the platform specific representation of the data that has been transferred + * + * @return a Java String containing the transferred data if the conversion was successful; otherwise null + * + */ +public Object nativeToJava(TransferData transferData){ + // get byte array from super + byte[] buffer = (byte[])super.nativeToJava(transferData); + if (buffer == null) return null; + // convert byte array to a string + String string = new String(buffer); + // remove null terminator + int index = string.indexOf("\0"); + string = string.substring(0, index); + return string; +} +protected int[] getTypeIds(){ + return new int[] {COM.CF_TEXT}; +} +protected String[] getTypeNames(){ + return new String[] {"CF_TEXT"}; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java new file mode 100755 index 0000000000..4556298271 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java @@ -0,0 +1,87 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.internal.ole.win32.COM; + +/** + * The classTransfer
provides a mechanism for converting a Java object to a
+ * platform specific format that can be passed around in a Drag and Drop operation and vice versa.
+ *
+ * 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.
+ * + */ +public abstract class Transfer { +/** + * Returns a list of the data types that can be transferred using this Transfer agent. + * + *Only the data type fields of the TransferData Object are filled in.
+ * + * @return a list of the data types that can be transferred using this Transfer agent + * + */ +abstract public TransferData[] getSupportedTypes(); +/** + * Returns true if the transferData data type can be transferred using this Transfer agent. + * + * @param transferData a platform specific description of a data type; only the data type fields + * of the TransferData Object need to be filled in + * + * @return true if the transferData data type can be transferred using this Transfer agent + * + */ +abstract public boolean isSupportedType(TransferData transferData); + +abstract protected int[] getTypeIds(); +abstract protected String[] getTypeNames(); +/** + * Converts a Java Object to a platform specific representation of the data. + * + *On a successful conversion, the transferData.result field will be set to OLE.S_OK. + * If this transfer agent is unable to perform the conversion, the transferData.result field + * will be set to the failure value of OLE.DV_E_TYMED.
+ * + * @param object a Java Object containing the data to be transferred + * + * @param transferData an empty TransferData object; this object will be filled in on return + * with the platform specfifc representation of the data + * + */ + + abstract protected void javaToNative (Object object, TransferData transferData); +/** + * Converts a platform specific representation of data to a Java Object. + * + * @param transferData the platform specific representation of the data that has been transferred + * + * @return a Java Object containing the transferred data if the conversion was successful; otherwise null + * + */ + + abstract protected Object nativeToJava(TransferData transferData); +/** + * Registers a name for a data type and returns the associated unique identifier. + * + *You may register the same type more than once, the same unique identifier will be returned if the + * type has been previously registered.
+ * + *Note: Do not call this method with pre-defined Clipboard Format types such as CF_TEXT + * or CF_BITMAP because the pre-defined value will not be returned
+ * + * @param formatName the name of a data type + * + * @return the unique identifier associated with htis data type + * + */ +public static int registerType(String formatName){ + // Look name up in the registry + // If name is not in registry, add it and return assigned value. + // If name already exists in registry, return its assigned value + byte[] chFormatName = (formatName+'\0').getBytes(); + return COM.RegisterClipboardFormat(chFormatName); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java new file mode 100755 index 0000000000..02a8c329fb --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java @@ -0,0 +1,50 @@ +package org.eclipse.swt.dnd; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.internal.ole.win32.*; + +/** + * + * TheTransferData
class is a platform specific data structure for describing the type and the
+ * contents of data being transferred in a Drag and Drop operation.
+ *
+ * As an application writer, you do not need to know anything about the specifics of TransferData. You + * should just pass the TransferData instances to subclass of Transfer and let the Transfer objects deal + * with the platform specific issues. You can ask a Transfer subclass if it can handle this data by calling + * TextTransfer.isSupportedType(transferData). You can get a list of the types of TransferData supported by a + * Transfer object by calling TextTransfer.getSupportedTypes().
+ * + *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.
+ * + */ +public class TransferData { + /** + * Data Type - a pre-defined clipboard format or the unique identifier of a user defined format + */ + public int type; + /** + * Data Type - a Windows format structure which describes additional aspects of the type + */ + public FORMATETC formatetc; + + /** + * Set Data - a data storage structure which you update to contain the data to be transferred in the + * Windows specific format + */ + public STGMEDIUM stgmedium; + /** + * Set Data - the result of converting a Java object into an stgmedium value + */ + public int result = COM.E_FAIL; + + /** + * Get Data - the address of an IDataObject OLE Interface which contains the data that was transferred + */ + public int pIDataObject; + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java new file mode 100755 index 0000000000..5115aba9db --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java @@ -0,0 +1,108 @@ +package org.eclipse.swt.dnd; + +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.internal.win32.OS; +import org.eclipse.swt.internal.win32.TVITEM; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +class TreeDragUnderEffect extends DragUnderEffect { + + private Tree tree; + private TreeItem currentItem = null; + private int currentEffect = DND.FEEDBACK_NONE; + private TreeItem[] selection = new TreeItem[0]; + +TreeDragUnderEffect(Tree tree) { + this.tree = tree; +} +void show(int effect, int x, int y) { + TreeItem item = findItem(x, y); + if (item == null) { + effect = DND.FEEDBACK_NONE; + } + if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) { + selection = tree.getSelection(); + tree.setSelection(new TreeItem[0]); + } + boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE; + setDragUnderEffect(effect, item); + if (restoreSelection) { + TVITEM tvItem = new TVITEM (); + tvItem.mask = OS.TVIF_STATE; + tvItem.stateMask = OS.TVIS_SELECTED; + tvItem.state = OS.TVIS_SELECTED; + for (int i = 0; i < selection.length; i++) { + tvItem.hItem = selection[i].handle; + OS.SendMessage (tree.handle, OS.TVM_SETITEM, 0, tvItem); + OS.SendMessage (tree.handle, OS.TVM_ENSUREVISIBLE, 0, selection[i].handle); + } + selection = new TreeItem[0]; + } +} +private TreeItem findItem(int x , int y){ + Point coordinates = new Point(x, y); + coordinates = tree.toControl(coordinates); + TreeItem item = tree.getItem(coordinates); + if (item != null) return item; + + Rectangle area = tree.getClientArea(); + for (int x1 = area.x; x1 < area.x + area.width; x1++) { + coordinates = new Point(x1, y); + coordinates = tree.toControl(coordinates); + item = tree.getItem(coordinates); + if (item != null) return item; + } + return null; +} +private void setDragUnderEffect(int effect, TreeItem item) { + switch (effect) { + case DND.FEEDBACK_SELECT: + if (currentEffect == DND.FEEDBACK_INSERT_AFTER || + currentEffect == DND.FEEDBACK_INSERT_BEFORE) { + tree.setInsertMark(null, false); + currentEffect = DND.FEEDBACK_NONE; + currentItem = null; + } + if (currentEffect != effect || currentItem != item) { + setDropSelection(item); + currentEffect = DND.FEEDBACK_SELECT; + currentItem = item; + } + break; + case DND.FEEDBACK_INSERT_AFTER: + case DND.FEEDBACK_INSERT_BEFORE: + if (currentEffect == DND.FEEDBACK_SELECT) { + setDropSelection(null); + currentEffect = DND.FEEDBACK_NONE; + currentItem = null; + } + if (currentEffect != effect || currentItem != item) { + tree.setInsertMark(item, effect == DND.FEEDBACK_INSERT_BEFORE); + currentEffect = effect; + currentItem = item; + } + break; + default : + if (currentEffect == DND.FEEDBACK_INSERT_AFTER || + currentEffect == DND.FEEDBACK_INSERT_BEFORE) { + tree.setInsertMark(null, false); + } + if (currentEffect == DND.FEEDBACK_SELECT) { + setDropSelection(null); + } + currentEffect = DND.FEEDBACK_NONE; + currentItem = null; + break; + } +} +private void setDropSelection (TreeItem item) { + int hNewItem = 0; + if (item != null) hNewItem = item.handle; + OS.SendMessage (tree.handle, OS.TVM_SELECTITEM, OS.TVIS_DROPHILITED, hNewItem); +} +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java new file mode 100755 index 0000000000..1583e9dac0 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class CAUUID { + + public int cElems; + public int pElems; + + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java new file mode 100755 index 0000000000..1d5bd02e7c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java @@ -0,0 +1,562 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.internal.win32.*; + +public class COM extends OS { + + static { + /* Initialize OLE */ + // OleInitialize Initializes the COM library on the current apartment + // and identifies the concurrency model as single-thread apartment (STA). + // To use any other threading model, you must call CoInitializeEx + OS.OleInitialize(0); + } + + /* Constants */ + + // !!!! GUIDs for Home Page Browser !!!! + public static final GUID IIDIEditorSiteTime = IIDFromString("{6BD2AEFE-7876-45e6-A6E7-3BFCDF6540AA}"); + public static final GUID IIDIEditorSiteProperty = IIDFromString("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}"); + public static final GUID IIDIEditorBaseProperty = IIDFromString("{61E55B0B-2647-47c4-8C89-E736EF15D636}"); + public static final GUID IIDIEditorSite = IIDFromString("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}"); + public static final GUID IIDIEditorService = IIDFromString("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}"); + public static final GUID IIDIEditorManager = IIDFromString("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}"); + + + public static final GUID IIDIAdviseSink = IIDFromString("{0000010F-0000-0000-C000-000000000046}"); + //public static final GUID IIDIAdviseSink2 = IIDFromString("{00000125-0000-0000-C000-000000000046}"); + //public static final GUID IIDIBindCtx = IIDFromString("{0000000E-0000-0000-C000-000000000046}"); + //public static final GUID IIDIClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}"); + public static final GUID IIDIClassFactory2 = IIDFromString("{B196B28F-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIConnectionPoint = IIDFromString("{B196B286-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIConnectionPointContainer = IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}"); + //public static final GUID IIDICreateErrorInfo = IIDFromString("{22F03340-547D-101B-8E65-08002B2BD119}"); + //public static final GUID IIDICreateTypeInfo = IIDFromString("{00020405-0000-0000-C000-000000000046}"); + //public static final GUID IIDICreateTypeLib = IIDFromString("{00020406-0000-0000-C000-000000000046}"); + //public static final GUID IIDIDataAdviseHolder = IIDFromString("{00000110-0000-0000-C000-000000000046}"); + public static final GUID IIDIDataObject = IIDFromString("{0000010E-0000-0000-C000-000000000046}"); + public static final GUID IIDIDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}"); + public static final GUID IIDIDropSource = IIDFromString("{00000121-0000-0000-C000-000000000046}"); + public static final GUID IIDIDropTarget = IIDFromString("{00000122-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumConnectionPoints = IIDFromString("{B196B285-BAB4-101A-B69C-00AA00341D07}"); + //public static final GUID IIDIEnumConnections = IIDFromString("{B196B287-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIEnumFORMATETC = IIDFromString("{00000103-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumMoniker = IIDFromString("{00000102-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumOLEVERB = IIDFromString("{00000104-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumSTATDATA = IIDFromString("{00000105-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumSTATSTG = IIDFromString("{0000000D-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumString = IIDFromString("{00000101-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumUnknown = IIDFromString("{00000100-0000-0000-C000-000000000046}"); + //public static final GUID IIDIEnumVARIANT = IIDFromString("{00020404-0000-0000-C000-000000000046}"); + //public static final GUID IIDIErrorInfo = IIDFromString("{1CF2B120-547D-101B-8E65-08002B2BD119}"); + //public static final GUID IIDIErrorLog = IIDFromString("{3127CA40-446E-11CE-8135-00AA004BB851}"); + //public static final GUID IIDIExternalConnection = IIDFromString("{00000019-0000-0000-C000-000000000046}"); + public static final GUID IIDIFont = IIDFromString("{BEF6E002-A874-101A-8BBA-00AA00300CAB}"); + //public static final GUID IIDIFontDisp = IIDFromString("{BEF6E003-A874-101A-8BBA-00AA00300CAB}"); + //public static final GUID IIDILockBytes = IIDFromString("{0000000A-0000-0000-C000-000000000046}"); + //public static final GUID IIDIMalloc = IIDFromString("{00000002-0000-0000-C000-000000000046}"); + //public static final GUID IIDIMallocSpy = IIDFromString("{0000001D-0000-0000-C000-000000000046}"); + //public static final GUID IIDIMarshal = IIDFromString("{00000003-0000-0000-C000-000000000046}"); + //public static final GUID IIDIMessageFilter = IIDFromString("{00000016-0000-0000-C000-000000000046}"); + //public static final GUID IIDIMoniker = IIDFromString("{0000000F-0000-0000-C000-000000000046}"); + //public static final GUID IIDIOleAdviseHolder = IIDFromString("{00000111-0000-0000-C000-000000000046}"); + //public static final GUID IIDIOleCache = IIDFromString("{0000011E-0000-0000-C000-000000000046}"); + //public static final GUID IIDIOleCache2 = IIDFromString("{00000128-0000-0000-C000-000000000046}"); + //public static final GUID IIDIOleCacheControl = IIDFromString("{00000129-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleClientSite = IIDFromString("{00000118-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleCommandTarget = IIDFromString("{B722BCCB-4E68-101B-A2BC-00AA00404770}"); + public static final GUID IIDIOleContainer = IIDFromString("{0000011B-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleControl = IIDFromString("{B196B288-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIOleControlSite = IIDFromString("{B196B289-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIOleInPlaceActiveObject = IIDFromString("{00000117-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleInPlaceFrame = IIDFromString("{00000116-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleInPlaceObject = IIDFromString("{00000113-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleInPlaceSite = IIDFromString("{00000119-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleInPlaceUIWindow = IIDFromString("{00000115-0000-0000-C000-000000000046}"); + //public static final GUID IIDIOleItemContainer = IIDFromString("{0000011C-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleLink = IIDFromString("{0000011D-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}"); + public static final GUID IIDIOleWindow = IIDFromString("{00000114-0000-0000-C000-000000000046}"); + //public static final GUID IIDIParseDisplayName = IIDFromString("{0000011A-0000-0000-C000-000000000046}"); + //public static final GUID IIDIPerPropertyBrowsing = IIDFromString("{376BD3AA-3845-101B-84ED-08002B2EC713}"); + public static final GUID IIDIPersist = IIDFromString("{0000010C-0000-0000-C000-000000000046}"); + public static final GUID IIDIPersistFile = IIDFromString("{0000010B-0000-0000-C000-000000000046}"); + //public static final GUID IIDIPersistMemory = IIDFromString("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}"); + //public static final GUID IIDIPersistPropertyBag = IIDFromString("{37D84F60-42CB-11CE-8135-00AA004BB851}"); + public static final GUID IIDIPersistStorage = IIDFromString("{0000010A-0000-0000-C000-000000000046}"); + public static final GUID IIDIPersistStream = IIDFromString("{00000109-0000-0000-C000-000000000046}"); + //public static final GUID IIDIPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}"); + //public static final GUID IIDIPicture = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"); + //public static final GUID IIDIPictureDisp = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}"); + //public static final GUID IIDIPropertyBag = IIDFromString("{55272A00-42CB-11CE-8135-00AA004BB851}"); + public static final GUID IIDIPropertyNotifySink = IIDFromString("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}"); + //public static final GUID IIDIPropertyPage = IIDFromString("{B196B28D-BAB4-101A-B69C-00AA00341D07}"); + //public static final GUID IIDIPropertyPage2 = IIDFromString("{01E44665-24AC-101B-84ED-08002B2EC713}"); + //public static final GUID IIDIPropertyPageSite = IIDFromString("{B196B28C-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIProvideClassInfo = IIDFromString("{B196B283-BAB4-101A-B69C-00AA00341D07}"); + public static final GUID IIDIProvideClassInfo2 = IIDFromString("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}"); + //public static final GUID IIDIPSFactoryBuffer = IIDFromString("{D5F569D0-593B-101A-B569-08002B2DBF7A}"); + //public static final GUID IIDIRootStorage = IIDFromString("{00000012-0000-0000-C000-000000000046}"); + //public static final GUID IIDIROTData = IIDFromString("{F29F6BC0-5021-11CE-AA15-00006901293F}"); + //public static final GUID IIDIRpcChannelBuffer = IIDFromString("{D5F56B60-593B-101A-B569-08002B2DBF7A}"); + //public static final GUID IIDIRpcProxyBuffer = IIDFromString("{D5F56A34-593B-101A-B569-08002B2DBF7A}"); + //public static final GUID IIDIRpcStubBuffer = IIDFromString("{D5F56AFC-593B-101A-B569-08002B2DBF7A}"); + //public static final GUID IIDIRunnableObject = IIDFromString("{00000126-0000-0000-C000-000000000046}"); + //public static final GUID IIDIRunningObjectTable = IIDFromString("{00000010-0000-0000-C000-000000000046}"); + //public static final GUID IIDISimpleFrameSite = IIDFromString("{742B0E01-14E6-101B-914E-00AA00300CAB}"); + public static final GUID IIDISpecifyPropertyPages = IIDFromString("{B196B28B-BAB4-101A-B69C-00AA00341D07}"); + //public static final GUID IIDIStdMarshalInfo = IIDFromString("{00000018-0000-0000-C000-000000000046}"); + public static final GUID IIDIStorage = IIDFromString("{0000000B-0000-0000-C000-000000000046}"); + public static final GUID IIDIStream = IIDFromString("{0000000C-0000-0000-C000-000000000046}"); + //public static final GUID IIDISupportErrorInfo = IIDFromString("{DF0B3D60-548F-101B-8E65-08002B2BD119}"); + //public static final GUID IIDITypeComp = IIDFromString("{00020403-0000-0000-C000-000000000046}"); + //public static final GUID IIDITypeLib = IIDFromString("{00020402-0000-0000-C000-000000000046}"); + public static final GUID IIDIUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}"); + //public static final GUID IIDIViewObject = IIDFromString("{0000010D-0000-0000-C000-000000000046}"); + public static final GUID IIDIViewObject2 = IIDFromString("{00000127-0000-0000-C000-000000000046}"); + + //public static final int ADVF_DATAONSTOP = 64; + //public static final int ADVF_NODATA = 1; + //public static final int ADVF_ONLYONCE = 2; + //public static final int ADVF_PRIMEFIRST = 4; + //public static final int ADVFCACHE_FORCEBUILTIN = 16; + //public static final int ADVFCACHE_NOHANDLER = 8; + //public static final int ADVFCACHE_ONSAVE = 32; + public static final int CF_TEXT = 1; + public static final int CF_BITMAP = 2; + public static final int CF_METAFILEPICT = 3; + public static final int CF_SYLK = 4; + public static final int CF_DIF = 5; + public static final int CF_TIFF = 6; + public static final int CF_OEMTEXT = 7; + public static final int CF_DIB = 8; + public static final int CF_PALETTE = 9; + public static final int CF_PENDATA = 10; + public static final int CF_RIFF = 11; + public static final int CF_WAVE = 12; + public static final int CF_UNICODETEXT = 13; + public static final int CF_ENHMETAFILE = 14; + public static final int CF_HDROP = 15; + public static final int CF_LOCALE = 16; + public static final int CF_MAX = 17; + public static final int CLSCTX_INPROC_HANDLER = 2; + public static final int CLSCTX_INPROC_SERVER = 1; + public static final int CLSCTX_LOCAL_SERVER = 4; + public static final int CLSCTX_REMOTE_SERVER = 16; + public static final int CO_E_CLASSSTRING = -2147221005; + //public static final int COINIT_APARTMENTTHREADED = 2; Apartment model + //public static final int COINIT_DISABLE_OLE1DDE = 4; Don't use DDE for Ole1 support. + //public static final int COINIT_MULTITHREADED = 0; OLE calls objects on any thread. + //public static final int COINIT_SPEED_OVER_MEMORY = 8; Trade memory for speed. + public static final int DATADIR_GET = 1; + public static final int DATADIR_SET = 2; + public static final int DISP_E_EXCEPTION = 0x80020009; + public static final int DISP_E_MEMBERNOTFOUND = -2147352573; + public static final int DISP_E_UNKNOWNINTERFACE = 0x80020001; + //public static final int DISPID_AMBIENT_APPEARANCE = -716; + //public static final int DISPID_AMBIENT_AUTOCLIP = -715; + public static final int DISPID_AMBIENT_BACKCOLOR = -701; + //public static final int DISPID_AMBIENT_CHARSET = -727; + //public static final int DISPID_AMBIENT_CODEPAGE = -725; + //public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713; + //public static final int DISPID_AMBIENT_DISPLAYNAME = -702; + public static final int DISPID_AMBIENT_FONT = -703; + public static final int DISPID_AMBIENT_FORECOLOR = -704; + public static final int DISPID_AMBIENT_LOCALEID = -705; + public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706; + public static final int DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501; + //public static final int DISPID_AMBIENT_PALETTE = -726; + //public static final int DISPID_AMBIENT_RIGHTTOLEFT = -732; + //public static final int DISPID_AMBIENT_SCALEUNITS = -707; + public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711; + public static final int DISPID_AMBIENT_SHOWHATCHING = -712; + public static final int DISPID_AMBIENT_SILENT = -5502; + public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714; + //public static final int DISPID_AMBIENT_TEXTALIGN = -708; + //public static final int DISPID_AMBIENT_TOPTOBOTTOM = -733; + //public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728; + public static final int DISPID_AMBIENT_UIDEAD = -710; + public static final int DISPID_AMBIENT_USERMODE = -709; + public static final int DISPID_BACKCOLOR = -501; + public static final int DISPID_FONT = -512; + public static final int DISPID_FONT_BOLD = 3; + public static final int DISPID_FONT_CHARSET = 8; + public static final int DISPID_FONT_ITALIC = 4; + public static final int DISPID_FONT_NAME = 0; + public static final int DISPID_FONT_SIZE = 2; + public static final int DISPID_FONT_STRIKE = 6; + public static final int DISPID_FONT_UNDER = 5; + public static final int DISPID_FONT_WEIGHT = 7; + public static final int DISPID_FORECOLOR = -513; + //public static final int DISPID_READYSTATE = -525; + //public static final int DISPID_READYSTATECHANGE = -609; + public static final int DRAGDROP_S_DROP = 0x00040100; //Successful drop took place + public static final int DRAGDROP_S_CANCEL = 0x00040101; // Drag-drop operation canceled + public static final int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102; // Use the default cursor + public static final int DROPEFFECT_NONE = 0; // Drop target cannot accept the data. + public static final int DROPEFFECT_COPY = 1; // Drop results in a copy. The original data is untouched by + // the drag source. + public static final int DROPEFFECT_MOVE = 2; // Drag source should remove the data. + public static final int DROPEFFECT_LINK = 4; // Drag source should create a link to the original data. + public static final int DROPEFFECT_SCROLL = 0x80000000; // Scrolling is about to start or is currently + // occurring in the target. This value is used in + // addition to the other values. + public static final int DV_E_FORMATETC = -2147221404; + public static final int DV_E_STGMEDIUM = -2147221402; + public static final int DV_E_TYMED = -2147221399; + public static final int DVASPECT_CONTENT = 1; + //public static final int DVASPECT_DOCPRINT = 8; + //public static final int DVASPECT_ICON = 4; + //public static final int DVASPECT_THUMBNAIL = 2; + public static final int E_FAIL = -2147467259; //Unspecified failure. + public static final int E_INVALIDARG = -2147024809; + public static final int E_NOINTERFACE = -2147467262; //QueryInterface did not recognize the requested interface. + public static final int E_NOTIMPL = -2147467263; //Member function contains no implementation. + //public static final int E_NOTLICENSED = -2147221230; + //public static final int E_OUTOFMEMORY = -2147024882; //Function failed to allocate necessary memory. + //public static final int E_POINTER = -2147467261; + public static final int GMEM_FIXED = 0; //Global Memory Constants + //public static final int GMEM_MOVABLE = 2; + //public static final int GMEM_NODISCARD = 32; + public static final int GMEM_ZEROINIT = 64; + public static final int GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1; + public static final int IMPLTYPEFLAG_FDEFAULT = 1; + //public static final int IMPLTYPEFLAG_FDEFAULTVTABLE = 2048; + public static final int IMPLTYPEFLAG_FRESTRICTED = 4; + public static final int IMPLTYPEFLAG_FSOURCE = 2; + public static final int LOCALE_SYSTEM_DEFAULT = 1024; //Locale Constants + public static final int LOCALE_USER_DEFAULT = 2048; + //public static final int MEMCTX_TASK = 1; //dwMemContext values for COM's task memory allocation service + //public static final int OLEACTIVATEAUTO = 3; //Object is activated based on the object's default method of activation + //public static final int OLEACTIVATEDOUBLECLICK = 2; //Object is activated when the OLE container control is double-clicked + //public static final int OLEACTIVATEGETFOCUS = 1; //Object is activated when the OLE container control gets the focus + //public static final int OLEACTIVATEMANUAL = 0; //OLE object isn't automatically activated + //public static final int OLEAUTOMATIC = 0; //Object is updated each time the linked data changes + //public static final int OLECHANGED = 0; //Object's data has changed + public static final int OLECLOSE_NOSAVE = 1; + //public static final int OLECLOSE_PROMPTSAVE = 2; + public static final int OLECLOSE_SAVEIFDIRTY = 0; + //public static final int OLECLOSED = 2; //Application file containing the linked object's data has been closed + //public static final int OLECONTF_EMBEDDINGS = 1; //The OLECONTF enumeration indicates the kind of objects to be enumerated by the returned IEnumUnknown interface + //public static final int OLECONTF_LINKS = 2; + //public static final int OLECONTF_ONLYIFRUNNING = 16; + //public static final int OLECONTF_ONLYUSER = 8; + //public static final int OLECONTF_OTHERS = 4; + //public static final int OLEDEACTIVATEMANUAL = 1; //The OLE object can only be deactivated programatically via the #doVerb: method." + //public static final int OLEDEACTIVATEONLOSEFOCUS = 0; //The OLE object is deactivated whenever focus is given to another widget in the receiver's shell. + //public static final int OLEDECBORDER = 1; //a border is displayed around the receiver. + //public static final int OLEDECBORDERANDNIBS = 3; //border and resize nibs are displayed. + //public static final int OLEDECNIBS = 2; //resize nibs are displayed around the reciever. + //public static final int OLEDECNONE = 0; //no special trimmings are displayed around the receiver. + //public static final int OLEDISPLAYCONTENT = 0; //Object's data is displayed in the OLE container control + //public static final int OLEDISPLAYICON = 1; //Object's icon is displayed in the OLE container control + //public static final int OLEEITHER = 2; //OLE container control can contain either a linked or an embedded object + public static final int OLEEMBEDDED = 1; //OLE container control contains an embedded object + //public static final int OLEFROZEN = 1; //Object is updated whenever the user saves the linked document from within the application in which it was created + public static final int OLEIVERB_DISCARDUNDOSTATE = -6; //close the OLE object and discard the undo state + //public static final int OLEIVERB_HIDE = -3; //hide the OLE object + public static final int OLEIVERB_INPLACEACTIVATE = -5; //open the OLE for editing in-place + //public static final int OLEIVERB_OPEN = -2; //open the OLE object for editing in a separate window + public static final int OLEIVERB_PRIMARY = 0; //opens the OLE object for editing + //public static final int OLEIVERB_PROPERTIES = -7; //request the OLE object properties dialog + //public static final int OLEIVERB_SHOW = -1; //show the OLE object + //public static final int OLEIVERB_UIACTIVATE = -4; //activate the UI for the OLE object + public static final int OLELINKED = 0; //OLE container control contains a linked object + //public static final int OLEMANUAL = 2; //Object is updated only when the Action property is set to 6 (Update) + //public static final int OLEMISC_ACTIVATEWHENVISIBLE = 256; + //public static final int OLEMISC_ACTSLIKEBUTTON = 4096; + //public static final int OLEMISC_ACTSLIKELABEL = 8192; + //public static final int OLEMISC_ALIGNABLE = 32768; + //public static final int OLEMISC_ALWAYSRUN = 2048; + //public static final int OLEMISC_CANLINKBYOLE1 = 32; + //public static final int OLEMISC_CANTLINKINSIDE = 16; + //public static final int OLEMISC_IGNOREACTIVATEWHENVISIBLE = 524288; + //public static final int OLEMISC_IMEMODE = 262144; + //public static final int OLEMISC_INSERTNOTREPLACE = 4; + //public static final int OLEMISC_INSIDEOUT = 128; + //public static final int OLEMISC_INVISIBLEATRUNTIME = 1024; + //public static final int OLEMISC_ISLINKOBJECT = 64; + //public static final int OLEMISC_NOUIACTIVATE = 16384; + //public static final int OLEMISC_ONLYICONIC = 2; + //public static final int OLEMISC_RECOMPOSEONRESIZE = 1; + //public static final int OLEMISC_RENDERINGISDEVICEINDEPENDENT = 512; + //public static final int OLEMISC_SETCLIENTSITEFIRST = 131072; + //public static final int OLEMISC_SIMPLEFRAME = 65536; + //public static final int OLEMISC_STATIC = 8; + //public static final int OLEMISC_SUPPORTSMULTILEVELUNDO = 2097152; + //public static final int OLEMISC_WANTSTOMENUMERGE = 1048576; + //public static final int OLENONE = 3; //OLE container control doesn't contain an object + //public static final int OLERENAMED = 3; //Application file containing the linked object's data has been renamed + //public static final int OLERENDER_ASIS = 3; //Ole Create rendering formats + public static final int OLERENDER_DRAW = 1; + //public static final int OLERENDER_FORMAT = 2; + //public static final int OLERENDER_NONE = 0; + //public static final int OLESAVED = 1; //Object's data has been saved by the application that created the object + //public static final int OLESIZEAUTOSIZE = 2; //OLE container control is automatically resized to display the entire object + //public static final int OLESIZECLIP = 0; //Object's image is clipped by the OLE container control's borders + //public static final int OLESIZESTRETCH = 1; //Object's image is sized to fill the OLE container control + //public static final int OLESIZEZOOM = 3; //Object's image is stretched but in proportion + //public static final int OLEWHICHMK_CONTAINER = 1; + //public static final int OLEWHICHMK_OBJFULL = 3; + //public static final int OLEWHICHMK_OBJREL = 2; + public static final int S_FALSE = 1; //Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded. + public static final int S_OK = 0; //Function succeeded. + public static final int STG_E_FILENOTFOUND = 0x80030002; + public static final int STG_S_CONVERTED = 0x00030200; + //public static final int STGC_CONSOLIDATE = 8; + //public static final int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4; + public static final int STGC_DEFAULT = 0; + //public static final int STGC_ONLYIFCURRENT = 2; + //public static final int STGC_OVERWRITE = 1; + public static final int STGM_CONVERT = 0x00020000; + public static final int STGM_CREATE = 0x00001000; + public static final int STGM_DELETEONRELEASE = 0x04000000; + public static final int STGM_DIRECT = 0x00000000; + public static final int STGM_DIRECT_SWMR = 0x00400000; + public static final int STGM_FAILIFTHERE = 0x00000000; + public static final int STGM_NOSCRATCH = 0x00100000; + public static final int STGM_NOSNAPSHOT = 0x00200000; + public static final int STGM_PRIORITY = 0x00040000; + public static final int STGM_READ = 0x00000000; + public static final int STGM_READWRITE = 0x00000002; + public static final int STGM_SHARE_DENY_NONE = 0x00000040; + public static final int STGM_SHARE_DENY_READ = 0x00000030; + public static final int STGM_SHARE_DENY_WRITE = 0x00000020; + public static final int STGM_SHARE_EXCLUSIVE = 0x00000010; + public static final int STGM_SIMPLE = 0x08000000; + public static final int STGM_TRANSACTED = 0x00010000; + public static final int STGM_WRITE = 0x00000001; + public static final int STGTY_STORAGE = 1; + public static final int STGTY_STREAM = 2; + public static final int STGTY_LOCKBYTES = 3; + public static final int STGTY_PROPERTY = 4; + //public static final int TYMED_ENHMF = 64; //Values for tymed + //public static final int TYMED_FILE = 2; + //public static final int TYMED_GDI = 16; + public static final int TYMED_HGLOBAL = 1; + //public static final int TYMED_ISTORAGE = 8; + //public static final int TYMED_ISTREAM = 4; + //public static final int TYMED_MFPICT = 32; + //public static final int TYMED_NULL = 0; + + public static final short DISPATCH_METHOD = 0x1; //Dispatch Constants + public static final short DISPATCH_PROPERTYGET = 0x2; + public static final short DISPATCH_PROPERTYPUT = 0x4; + public static final short DISPATCH_PROPERTYPUTREF = 0x8; + //public static final short DISPID_CONSTRUCTOR = -6; + //public static final short DISPID_DESTRUCTOR = -7; + //public static final short DISPID_EVALUATE = -5; + //public static final short DISPID_NEWENUM = -4; + public static final short DISPID_PROPERTYPUT = -3; + //public static final short DISPID_UNKNOWN = -1; + //public static final short DISPID_VALUE = 0; + + // Variant types + public static final short VT_BOOL = 11; // Boolean; True=-1, False=0. + public static final short VT_BSTR = 8; // Binary String. + public static final short VT_BYREF = 16384; // By reference - must be combined with one of the othre VT values + public static final short VT_CY = 6; // Currency. + public static final short VT_DATE = 7; // Date. + public static final short VT_DISPATCH = 9; // IDispatch + public static final short VT_EMPTY = 0; // Not specified. + public static final short VT_ERROR = 10; // Scodes. + public static final short VT_I2 = 2; // 2-byte signed int. + public static final short VT_I4 = 3; // 4-byte signed int. + public static final short VT_NULL = 1; // Null. + public static final short VT_R4 = 4; // 4-byte real. + public static final short VT_R8 = 5; // 8-byte real. + public static final short VT_UI1 = 17; // Unsigned char. + public static final short VT_UI4 = 19; // Unsigned int. + public static final short VT_UNKNOWN = 13; // IUnknown FAR*. + public static final short VT_VARIANT = 12; // VARIANT FAR*. + +public static final native int CLSIDFromProgID(char[] lpszProgID, GUID pclsid); +public static final native int CLSIDFromString(char[] lpsz, GUID pclsid); +public static final native int CoCreateInstance( + GUID rclsid, + int pUnkOuter, + int dwClsContext, + GUID riid, + int[] ppv +); + +public static final native void CoFreeUnusedLibraries(); +public static final native int CoGetClassObject(GUID rclsid, int dwClsContext, int pServerInfo, GUID riid, int[] ppv); +public static final native int CoLockObjectExternal( + int pUnk, //Pointer to object to be locked or unlocked + boolean fLock, //TRUE = lock, FALSE = unlock + boolean fLastUnlockReleases //TRUE = release all pointers to object +); +public static final native int CoTaskMemAlloc(int cb); //Size in bytes of memory block to be allocated +public static final native void CoTaskMemFree(int pv); +public static final native int DoDragDrop( + int pDataObject, //Pointer to the data object + int pDropSource, //Pointer to the source + int dwOKEffect, //Effects allowed by the source + int[] pdwEffect //Pointer to effects on the source +); + +public static final native void DragFinish(int hDrop); + +public static final native int DragQueryFile( + int hDrop, + int iFile, + byte[] lpszFile, + int cch +); + +public static final native int GetClassFile( + char[] szFileName, //Pointer to filename for which you are requesting a CLSID + GUID clsid //Pointer to location for returning the CLSID +); +public static final native int GetClipboardFormatName( + int format, + byte[] lpszFormatName, + int cchMaxCount); +public static final native int IIDFromString(char[] lpsz, GUID lpiid); +private static GUID IIDFromString(String lpsz) { + // create a null terminated array of char + char[] buffer = (lpsz +"\0").toCharArray(); + + // invoke system method + GUID lpiid = new GUID(); + if (COM.IIDFromString(buffer, lpiid) == COM.S_OK) + return lpiid; + return null; +} +public static final native boolean IsEqualGUID(GUID rguid1, GUID rguid2); +public static final native void MoveMemory( byte[] Destination, DROPFILES Source, int Length); +public static final native void MoveMemory(char[] Destination, int SourcePtr, int Length); +public static final native void MoveMemory(double[] Destination, int SourcePtr, int Length); +public static final native void MoveMemory(float[] Destination, int SourcePtr, int Length); +public static final native void MoveMemory(short[] Destination, int SourcePtr, int Length); +public static final native void MoveMemory(int DestinationPtr, double[] Source, int Length); +public static final native void MoveMemory(int DestinationPtr, float[] Source, int Length); +public static final native void MoveMemory(int DestinationPtr, short[] Source, int Length); +public static final native void MoveMemory( int Destination, FORMATETC Source, int Length); +public static final native void MoveMemory(int DestinationPtr, GUID Source, int Length); +public static final native void MoveMemory(int DestinationPtr, OLEINPLACEFRAMEINFO Source, int Length); +public static final native void MoveMemory( int Destination, STATSTG Source, int Length); +public static final native void MoveMemory( int Destination, STGMEDIUM Source, int Length); +public static final native void MoveMemory(DISPPARAMS Destination, int SourcePtr, int Length); +public static final native void MoveMemory(FORMATETC Destination, int Source, int Length); +public static final native void MoveMemory(GUID Destination, int SourcePtr, int Length); +public static final native void MoveMemory(STATSTG Destination, int Source, int Length); +public static final native void MoveMemory(TYPEATTR Destination, int SourcePtr, int Length); +public static final native void MoveMemory (RECT Destination, int Source, int Length); +public static final native void MoveMemory (FUNCDESC1 Destination, int Source, int Length); +public static final native void MoveMemory (VARDESC1 Destination, int Source, int Length); +public static final native void MoveMemory (FUNCDESC2 Destination, int Source, int Length); +public static final native void MoveMemory (VARDESC2 Destination, int Source, int Length); + +public static final native int OleCreate( GUID rclsid, GUID riid, int renderopt, FORMATETC pFormatEtc, int pClientSite, int pStg, int[] ppvObject); +public static final native int OleCreateFromFile( + GUID rclsid, //Reserved. Must be CLSID_NULL + char[] lpszFileName, //Pointer to full path of file used to create object + GUID riid, //Reference to the identifier of the interface to be used to + // communicate with new object + int renderopt, //Value from OLERENDER + FORMATETC pFormatEtc, //Pointer to the FORMATETC structure + int pClientSite, //Pointer to an interface + int pStg, //Pointer tothe interface to be used as object storage + int[] ppvObj); //Address of output variable that receives the interface pointer + // requested in riid +public static final native int OleCreatePropertyFrame(int hwndOwner,int x, int y, char[] lpszCaption, int cObjects, int[] lplpUnk, int cPages, int lpPageClsID, int lcid, int dwReserved, int lpvReserved); +public static final native int OleDraw(int pUnk, //Pointer to the view object to be drawn + int dwAspect, //How the object is to be represented + int hdcDraw, //Device context on which to draw + int lprcBounds);//Pointer to the rectangle in which the object is drawn +public static final native int OleFlushClipboard(); +public static final native int OleGetClipboard(int[] ppDataObject); +public static final native int OleIsCurrentClipboard(int pDataObject); +public static final native boolean OleIsRunning(int pObject); +public static final native int OleLoad( + int pStg, //Pointer to the storage object from which to load + GUID riid, //Reference to the identifier of the interface + int pClientSite, //Pointer to the client site for the object + int[] ppvObj //Address of output variable that receives the interface pointer requested in riid +); +public static final native int OleRun(int pUnknown); +public static final native int OleSave(int pPS, int pStg,boolean fSameAsLoad); +public static final native int OleSetClipboard(int pDataObject); +public static final native int OleSetContainedObject(int pUnk, boolean fContained); +public static final native int OleSetMenuDescriptor(int holemenu, int hwndFrame, int hwndActiveObject, int lpFrame, int lpActiveObj); +public static final native int OleTranslateColor(int clr, int hpal, int[] pcolorref); +public static final native int ProgIDFromCLSID( + GUID clsid, //CLSID for which the ProgID is requested + int[] lplpszProgID //Address of output variable that receives a pointer to the requested ProgID string +); +public static final native int RegisterClipboardFormat(byte[] lpszFormat); +public static final native int RegisterDragDrop( + int hwnd, //Handle to a window that can accept drops + int pDropTarget //Pointer to object that is to be target of drop +); +public static final native void ReleaseStgMedium( + STGMEDIUM pmedium //Pointer to storage medium to be freed +); +public static final native int RevokeDragDrop( + int hwnd //Handle to a window that can accept drops +); +public static final native int StgCreateDocfile(char[] pwcsName, int grfMode, int reserved, int[] ppstgOpen); +public static final native int StgIsStorageFile( + char[] pwcsName //Points to a path of the file to check +); +public static final native int StgOpenStorage( + char[] pwcsName, //Points to the path of the file containing storage object + int pstgPriority, //Points to a previous opening of a root storage object + int grfMode, //Specifies the access mode for the object + int snbExclude, //Points to an SNB structure specifying elements to be excluded + int reserved, //Reserved; must be zero + int[] ppstgOpen //Address of output variable that receives the IStorage interface pointer +); +public static final native int SysAllocString(char [] sz); +public static final native void SysFreeString(int bstr); +public static final native int SysStringByteLen(int bstr); +public static final native int VariantChangeType(int pvargDest, int pvarSrc, short wFlags, short vt); +public static final native int VariantClear(int pvarg); +public static final native void VariantInit(int pvarg); +public static final native int VtblCall (int fnNumber, int ppVtbl); +public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0); +public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, char[] arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int[] arg4); +public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int arg4, int[] arg5); +public static final native int VtblCall (int fnNumber, int ppVtbl, int[] arg0); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int[] arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int[] arg2); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int arg2); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int[] arg3); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, DVTARGETDEVICE arg2, SIZE arg3); +public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, GUID arg2, int arg3, int[] arg4); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, FORMATETC arg1, int[] arg2); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, GUID arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3); +public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3, DISPPARAMS arg4, int arg5, EXCEPINFO arg6, int[] arg7); +public static final native int VtblCall(int ppVtbl, int fnNumber, int arg0, STATSTG arg1, int[] arg2); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, MSG arg1, int arg2, int arg3, int arg4, RECT arg5); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, SIZE arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, boolean arg1); +public static final native int VtblCall(int fnNumber, int ppVtbl, CAUUID arg0); +public static final native int VtblCall(int ppVtbl, int fnNumber, CONTROLINFO arg0); +public static final native int VtblCall (int fnNumber, int ppVtbl, FORMATETC arg0); +public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1); +public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1, boolean arg2); +public static final native int VtblCall (int ppVtbl, int fnNumber, GUID arg0); +public static final native int VtblCall(int ppVtbl, int fnNumber, GUID arg0, int[] arg1); +public static final native int VtblCall (int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int[] arg4); +public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int arg4); +public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, OLECMD arg2, OLECMDTEXT arg3); +public static final native int VtblCall(int fnNumber, int ppVtbl, LICINFO arg0); +public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, int arg1, boolean arg2); +public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, RECT arg1); +public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int[] arg2, int[] arg3, int[] arg4); +public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int arg2, int[] arg3); + +public static final native int WriteClassStg(int pStg, GUID rclsid); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java new file mode 100755 index 0000000000..bef6d7e995 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java @@ -0,0 +1,1024 @@ +package org.eclipse.swt.internal.ole.win32; + +import java.util.Hashtable; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.win32.*; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +public class COMObject { + + private int ppVtable; + + static private final int MAX_ARG_COUNT = 12; + static private final int MAX_VTABLE_LENGTH = 80; + static private Callback[][] Callbacks = new Callback[MAX_VTABLE_LENGTH][MAX_ARG_COUNT]; + static private Hashtable ObjectMap = new Hashtable(); + +public COMObject(int[] argCounts) { + int[] callbackAddresses = new int[argCounts.length]; + for (int i = 0, length = argCounts.length; i < length; i++){ + if ((Callbacks[i][argCounts[i]]) == null) { + Callbacks[i][argCounts[i]] = new Callback(this.getClass(), "callback"+i, argCounts[i] + 1, true); + } + callbackAddresses[i] = Callbacks[i][argCounts[i]].getAddress(); + } + + int pVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * argCounts.length); + COM.MoveMemory(pVtable, callbackAddresses, 4 * argCounts.length); + ppVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4); + COM.MoveMemory(ppVtable, new int[] {pVtable}, 4); + ObjectMap.put(new Integer(ppVtable), this); +} + +public static GUID IIDFromString(String lpsz) { + // create a null terminated array of char + char[] buffer = (lpsz +"\0").toCharArray(); + + // invoke system method + GUID lpiid = new GUID(); + if (COM.IIDFromString(buffer, lpiid) == COM.S_OK) + return lpiid; + return null; +} + +static int callback0(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method0(args); +} +static int callback1(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method1(args); +} +static int callback2(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method2(args); +} +static int callback3(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method3(args); +} +static int callback4(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method4(args); +} +static int callback5(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method5(args); +} +static int callback6(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method6(args); +} +static int callback7(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method7(args); +} +static int callback8(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method8(args); +} +static int callback9(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method9(args); +} +static int callback10(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method10(args); +} +static int callback11(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method11(args); +} +static int callback12(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method12(args); +} +static int callback13(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method13(args); +} +static int callback14(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method14(args); +} +static int callback15(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method15(args); +} +static int callback16(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method16(args); +} +static int callback17(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method17(args); +} +static int callback18(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method18(args); +} +static int callback19(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method19(args); +} +static int callback20(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method20(args); +} +static int callback21(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method21(args); +} +static int callback22(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method22(args); +} +static int callback23(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method23(args); +} +static int callback24(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method24(args); +} +static int callback25(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method25(args); +} +static int callback26(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method26(args); +} +static int callback27(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method27(args); +} +static int callback28(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method28(args); +} +static int callback29(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method29(args); +} +static int callback30(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method30(args); +} +static int callback31(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method31(args); +} +static int callback32(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method32(args); +} +static int callback33(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method33(args); +} +static int callback34(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method34(args); +} +static int callback35(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method35(args); +} +static int callback36(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method36(args); +} +static int callback37(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method37(args); +} +static int callback38(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method38(args); +} +static int callback39(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method39(args); +} +static int callback40(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method40(args); +} +static int callback41(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method41(args); +} +static int callback42(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method42(args); +} +static int callback43(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method43(args); +} +static int callback44(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method44(args); +} +static int callback45(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method45(args); +} +static int callback46(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method46(args); +} +static int callback47(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method47(args); +} +static int callback48(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method48(args); +} +static int callback49(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method49(args); +} +static int callback50(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method50(args); +} +static int callback51(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method51(args); +} +static int callback52(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method52(args); +} +static int callback53(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method53(args); +} +static int callback54(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method54(args); +} +static int callback55(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method55(args); +} +static int callback56(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method56(args); +} +static int callback57(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method57(args); +} +static int callback58(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method58(args); +} +static int callback59(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method59(args); +} +static int callback60(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method60(args); +} +static int callback61(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method61(args); +} +static int callback62(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method62(args); +} +static int callback63(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method63(args); +} +static int callback64(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method64(args); +} +static int callback65(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method65(args); +} +static int callback66(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method66(args); +} +static int callback67(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method67(args); +} +static int callback68(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method68(args); +} +static int callback69(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method69(args); +} +static int callback70(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method70(args); +} +static int callback71(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method71(args); +} +static int callback72(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method72(args); +} +static int callback73(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method73(args); +} +static int callback74(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method74(args); +} +static int callback75(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method75(args); +} +static int callback76(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method76(args); +} +static int callback77(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method77(args); +} +static int callback78(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method78(args); +} +static int callback79(int[] callbackArgs) { + // find the object on which this call was invoked + int address = callbackArgs[0]; + Object object = ObjectMap.get(new Integer(address)); + if (object == null) return COM.E_FAIL; + int[] args = new int[callbackArgs.length - 1]; + System.arraycopy(callbackArgs, 1, args, 0, args.length); + return ((COMObject) object).method79(args); +} +public void dispose() { + // free the memory for this reference + int[] pVtable = new int[1]; + OS.MoveMemory(pVtable, ppVtable, 4); + OS.GlobalFree(pVtable[0]); + OS.GlobalFree(ppVtable); + + // remove this ppVtable from the list + ObjectMap.remove(new Integer(ppVtable)); + + ppVtable = 0; +} +public int getAddress () { + return ppVtable; +} +public int method0(int[] args) { + return COM.E_NOTIMPL; +} +public int method1(int[] args) { + return COM.E_NOTIMPL; +} +public int method2(int[] args) { + return COM.E_NOTIMPL; +} +public int method3(int[] args) { + return COM.E_NOTIMPL; +} +public int method4(int[] args) { + return COM.E_NOTIMPL; +} +public int method5(int[] args) { + return COM.E_NOTIMPL; +} +public int method6(int[] args) { + return COM.E_NOTIMPL; +} +public int method7(int[] args) { + return COM.E_NOTIMPL; +} +public int method8(int[] args) { + return COM.E_NOTIMPL; +} +public int method9(int[] args) { + return COM.E_NOTIMPL; +} +public int method10(int[] args) { + return COM.E_NOTIMPL; +} +public int method11(int[] args) { + return COM.E_NOTIMPL; +} +public int method12(int[] args) { + return COM.E_NOTIMPL; +} +public int method13(int[] args) { + return COM.E_NOTIMPL; +} +public int method14(int[] args) { + return COM.E_NOTIMPL; +} +public int method15(int[] args) { + return COM.E_NOTIMPL; +} +public int method16(int[] args) { + return COM.E_NOTIMPL; +} +public int method17(int[] args) { + return COM.E_NOTIMPL; +} +public int method18(int[] args) { + return COM.E_NOTIMPL; +} +public int method19(int[] args) { + return COM.E_NOTIMPL; +} +public int method20(int[] args) { + return COM.E_NOTIMPL; +} +public int method21(int[] args) { + return COM.E_NOTIMPL; +} +public int method22(int[] args) { + return COM.E_NOTIMPL; +} +public int method23(int[] args) { + return COM.E_NOTIMPL; +} +public int method24(int[] args) { + return COM.E_NOTIMPL; +} +public int method25(int[] args) { + return COM.E_NOTIMPL; +} +public int method26(int[] args) { + return COM.E_NOTIMPL; +} +public int method27(int[] args) { + return COM.E_NOTIMPL; +} +public int method28(int[] args) { + return COM.E_NOTIMPL; +} +public int method29(int[] args) { + return COM.E_NOTIMPL; +} +public int method30(int[] args) { + return COM.E_NOTIMPL; +} +public int method31(int[] args) { + return COM.E_NOTIMPL; +} +public int method32(int[] args) { + return COM.E_NOTIMPL; +} +public int method33(int[] args) { + return COM.E_NOTIMPL; +} +public int method34(int[] args) { + return COM.E_NOTIMPL; +} +public int method35(int[] args) { + return COM.E_NOTIMPL; +} +public int method36(int[] args) { + return COM.E_NOTIMPL; +} +public int method37(int[] args) { + return COM.E_NOTIMPL; +} +public int method38(int[] args) { + return COM.E_NOTIMPL; +} +public int method39(int[] args) { + return COM.E_NOTIMPL; +} +public int method40(int[] args) { + return COM.E_NOTIMPL; +} +public int method41(int[] args) { + return COM.E_NOTIMPL; +} +public int method42(int[] args) { + return COM.E_NOTIMPL; +} +public int method43(int[] args) { + return COM.E_NOTIMPL; +} +public int method44(int[] args) { + return COM.E_NOTIMPL; +} +public int method45(int[] args) { + return COM.E_NOTIMPL; +} +public int method46(int[] args) { + return COM.E_NOTIMPL; +} +public int method47(int[] args) { + return COM.E_NOTIMPL; +} +public int method48(int[] args) { + return COM.E_NOTIMPL; +} +public int method49(int[] args) { + return COM.E_NOTIMPL; +} +public int method50(int[] args) { + return COM.E_NOTIMPL; +} +public int method51(int[] args) { + return COM.E_NOTIMPL; +} +public int method52(int[] args) { + return COM.E_NOTIMPL; +} +public int method53(int[] args) { + return COM.E_NOTIMPL; +} +public int method54(int[] args) { + return COM.E_NOTIMPL; +} +public int method55(int[] args) { + return COM.E_NOTIMPL; +} +public int method56(int[] args) { + return COM.E_NOTIMPL; +} +public int method57(int[] args) { + return COM.E_NOTIMPL; +} +public int method58(int[] args) { + return COM.E_NOTIMPL; +} +public int method59(int[] args) { + return COM.E_NOTIMPL; +} +public int method60(int[] args) { + return COM.E_NOTIMPL; +} +public int method61(int[] args) { + return COM.E_NOTIMPL; +} +public int method62(int[] args) { + return COM.E_NOTIMPL; +} +public int method63(int[] args) { + return COM.E_NOTIMPL; +} +public int method64(int[] args) { + return COM.E_NOTIMPL; +} +public int method65(int[] args) { + return COM.E_NOTIMPL; +} +public int method66(int[] args) { + return COM.E_NOTIMPL; +} +public int method67(int[] args) { + return COM.E_NOTIMPL; +} +public int method68(int[] args) { + return COM.E_NOTIMPL; +} +public int method69(int[] args) { + return COM.E_NOTIMPL; +} +public int method70(int[] args) { + return COM.E_NOTIMPL; +} +public int method71(int[] args) { + return COM.E_NOTIMPL; +} +public int method72(int[] args) { + return COM.E_NOTIMPL; +} +public int method73(int[] args) { + return COM.E_NOTIMPL; +} +public int method74(int[] args) { + return COM.E_NOTIMPL; +} +public int method75(int[] args) { + return COM.E_NOTIMPL; +} +public int method76(int[] args) { + return COM.E_NOTIMPL; +} +public int method77(int[] args) { + return COM.E_NOTIMPL; +} +public int method78(int[] args) { + return COM.E_NOTIMPL; +} +public int method79(int[] args) { + return COM.E_NOTIMPL; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java new file mode 100755 index 0000000000..08cfe9319a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java @@ -0,0 +1,17 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class CONTROLINFO +{ + public int cb; + public int hAccel; + public short cAccel; + public short filler; + public int dwFlags; + + public static final int sizeof = 16; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java new file mode 100755 index 0000000000..7177ca2654 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class COSERVERINFO { + public int dwReserved1; + public int pwszName; + public int pAuthInfo; + public int dwReserved2; + + public static final int sizeof = 16; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java new file mode 100755 index 0000000000..e55bcb0030 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java @@ -0,0 +1,17 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class DISPPARAMS +{ + public int rgvarg; + public int rgdispidNamedArgs; + public int cArgs; + public int cNamedArgs; + + public static final int sizeof = 16; + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java new file mode 100755 index 0000000000..c34ffd0cbc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java @@ -0,0 +1,21 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class DROPFILES { + public int pFiles; // Offset of the file list from the beginning of this structure, in bytes. + //public POINT pt; // Drop point. The coordinates depend on fNC. + public int pt_x; + public int pt_y; + public int fNC; // Nonclient area flag. If this member is TRUE, pt specifies the screen + // coordinates of a point in a window's nonclient area. If it is FALSE, + // pt specifies the client coordinates of a point in the client area. + public int fWide; // Value that indicates whether the file contains ANSI or Unicode + // characters. If it is zero, it contains ANSI characters. Otherwise, it + // contains Unicode characters. + + public static final int sizeof = 20; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java new file mode 100755 index 0000000000..f5ae048ad2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java @@ -0,0 +1,18 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class DVTARGETDEVICE +{ + public int tdSize; + public short tdDriverNameOffset; + public short tdDeviceNameOffset; + public short tdPortNameOffset; + public short tdExtDevmodeOffset; + public byte tdData; + + public static final int sizeof = 13; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java new file mode 100755 index 0000000000..ed85c472da --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java @@ -0,0 +1,21 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class EXCEPINFO +{ + public short wCode; + public short wReserved; + public int bstrSource; + public int bstrDescription; + public int bstrHelpFile; + public int dwHelpContext; + public int pvReserved; + public int pfnDeferredFillIn; + public int scode; + + public static final int sizeof = 32; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java new file mode 100755 index 0000000000..1b177e7044 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java @@ -0,0 +1,17 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class FORMATETC +{ + public int cfFormat; + public int ptd; + public int dwAspect; + public int lindex; + public int tymed; + + public static final int sizeof = 20; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java new file mode 100755 index 0000000000..50fddbb9cd --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java @@ -0,0 +1,32 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +public class FUNCDESC1 { + public int memid; + public int lprgscode; + public int lprgelemdescParam; + public int funckind; + public int invkind; + public int callconv; + public short cParams; + public short cParamsOpt; + public short oVft; + public short cScodes; + //ELEMDESC elemdescFunc; + //TYPEDESC elemdescFunc.tdesc + public int elemdescFunc_tdesc_union; + public short elemdescFunc_tdesc_vt; + public short elemdescFunc_tdesc_filler; + //PARAMDESC elemdescFunc.paramdesc + public int elemdescFunc_paramdesc_pparamdescex; + public short elemdescFunc_paramdesc_wParamFlags; + public short elemdescFunc_paramdesc_filler; + public short wFuncFlags; + + public static final int sizeof = 50; + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java new file mode 100755 index 0000000000..cba1125f53 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java @@ -0,0 +1,32 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +public class FUNCDESC2 { + public int memid; + public int lprgscode; + public int lprgelemdescParam; + public int funckind; + public int invkind; + public int callconv; + public short cParams; + public short cParamsOpt; + public short oVft; + public short cScodes; + //ELEMDESC elemdescFunc; + //TYPEDESC elemdescFunc.tdesc + public int elemdescFunc_tdesc_union; + public short elemdescFunc_tdesc_vt; + public short elemdescFunc_tdesc_filler; + //IDLDESC elemdescFunc.idldesc + public int elemdescFunc_idldesc_dwReserved; + public short elemdescFunc_idldesc_wIDLFlags; + public short elemdescFunc_idldesc_filler; + public short wFuncFlags; + + public static final int sizeof = 50; + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java new file mode 100755 index 0000000000..2a3af7d23d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java @@ -0,0 +1,23 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public final class GUID +{ + public int data1; + public short data2; + public short data3; + public byte b0; + public byte b1; + public byte b2; + public byte b3; + public byte b4; + public byte b5; + public byte b6; + public byte b7; + + public static final int sizeof = 16; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java new file mode 100755 index 0000000000..ad71bed45f --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java @@ -0,0 +1,22 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class IClassFactory2 extends IUnknown +{ +public IClassFactory2(int address) { + super(address); +} +public int CreateInstanceLic(int pUnkOuter, int pUnkReserved, GUID riid, int bstrKey, int ppvObject[]) { + return COM.VtblCall(7, address, pUnkOuter, pUnkReserved, riid, bstrKey, ppvObject); +} +public int GetLicInfo(LICINFO licInfo) { + return COM.VtblCall(5, address, licInfo); +} +public int RequestLicKey(int dwReserved, int[] pBstrKey) { + return COM.VtblCall(6, address, dwReserved, pBstrKey); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java new file mode 100755 index 0000000000..ee7dd708ea --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java @@ -0,0 +1,19 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class IConnectionPoint extends IUnknown +{ +public IConnectionPoint(int address) { + super(address); +} +public int Advise(int pUnk, int[] pdwCookie) { + return COM.VtblCall(5, address, pUnk, pdwCookie); +} +public int Unadvise(int dwCookie) { + return COM.VtblCall(6, address, dwCookie); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java new file mode 100755 index 0000000000..d4ce46a4d9 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class IConnectionPointContainer extends IUnknown +{ +public IConnectionPointContainer(int address) { + super(address); +} +public int FindConnectionPoint(GUID riid, int[] ppCP) { + return COM.VtblCall(4, address, riid, ppCP); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java new file mode 100755 index 0000000000..e513252fe1 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java @@ -0,0 +1,42 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +public class IDataObject extends IUnknown { +/** + * IDataObject constructor comment. + * @param address int + */ +public IDataObject(int address) { + super(address); +} +public int EnumFormatEtc(int dwDirection, int[] ppenumFormatetc) { + return COM.VtblCall(8, address, dwDirection, ppenumFormatetc); +} +public int GetData(FORMATETC pFormatetc, STGMEDIUM pmedium) { + //Called by a data consumer to obtain data from a source data object. + //The GetData method renders the data described in the specified FORMATETC + //structure and transfers it through the specified STGMEDIUM structure. + //The caller then assumes responsibility for releasing the STGMEDIUM structure. + return COM.VtblCall(3, address, pFormatetc, pmedium); +} +public int GetDataHere(FORMATETC pFormatetc, STGMEDIUM pmedium) { + //Called by a data consumer to obtain data from a source data object. + //This method differs from the GetData method in that the caller must + //allocate and free the specified storage medium. + return COM.VtblCall(4, address, pFormatetc, pmedium); +} +public int QueryGetData(FORMATETC pFormatetc) { + return COM.VtblCall(5, address, pFormatetc); +} +public int SetData( + FORMATETC pFormatetc, // Pointer to the FORMATETC structure + STGMEDIUM pmedium, // Pointer to STGMEDIUM structure + boolean fRelease // Indicates which object owns the storage medium after the call is completed + ){ + return COM.VtblCall(7, address, pFormatetc, pmedium, fRelease); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java new file mode 100755 index 0000000000..171ce98771 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java @@ -0,0 +1,61 @@ +package org.eclipse.swt.internal.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ +import org.eclipse.swt.internal.win32.*; + +public class IDispatch extends IUnknown +{ +public IDispatch(int address) { + super(address); +} +public int GetIDsOfNames(GUID riid, String[] rgszNames, int cNames, int lcid, int[] rgDispId) { + + char[] buffer; + int size = rgszNames.length; + + // create an array to hold the addresses + int hHeap = OS.GetProcessHeap(); + int ppNames = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, size*4); + int[] memTracker = new int[size]; + + try { + // add the address of each string to the array + + for (int i=0; iDefinitions for these constants can be found in MSDN. + * + */ +public class OLE extends SWT { + + public static final int S_FALSE = 1; // Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded. + public static final int S_OK = 0; // Function succeeded. + + // Verbs that can be invoked on this client + public static final int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state + public static final int OLEIVERB_HIDE = -3; // hide the OLE object + public static final int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place + public static final int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window + public static final int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing + public static final int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog + public static final int OLEIVERB_SHOW = -1; // show the OLE object + public static final int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object + + public static final int PROPERTY_CHANGING = 0; + public static final int PROPERTY_CHANGED = 1; + + /** + * Error code for OleError - No specific error information available + */ + public static final int HRESULT_UNSPECIFIED = 0; + /** + * Error code for OleError - Failed to create file + */ + public static final int ERROR_CANNOT_CREATE_FILE = 1000; + /** + * Error code for OleError - Failed to create Ole Client + */ + public static final int ERROR_CANNOT_CREATE_OBJECT = 1001; + /** + * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format + */ + public static final int ERROR_CANNOT_OPEN_FILE = 1002; + /** + * Error code for OleError - Failed to find requested interface on OLE Object + */ + public static final int ERROR_INTERFACE_NOT_FOUND = 1003; + /** + * Error code for OleError - Class ID not found in registry + */ + public static final int ERROR_INVALID_CLASSID = 1004; + /** + * Error code for OleError - Failed to get the class factory for the specified classID + */ + public static final int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005; + /** + * Error code for OleError - Failed to create Licensed instance + */ + public static final int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006; + /** + * Error code for OleError - Out of Memory + */ + public static final int ERROR_OUT_OF_MEMORY = 1007; + /** + * Error code for OleError - Failed to change Variant type + */ + public static final int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010; + /** + * Error code for OleError - Invalid address received for Ole Interface + */ + public static final int ERROR_INVALID_INTERFACE_ADDRESS = 1011; + /** + * Error code for OleError - Unable to find Application + */ + public static final int ERROR_APPLICATION_NOT_FOUND = 1013; + /** + * Error code for OleError - Action can not be performed + */ + public static final int ERROR_ACTION_NOT_PERFORMED = 1014; + + public static final int OLECMDF_SUPPORTED = 1; + public static final int OLECMDF_ENABLED = 2; + public static final int OLECMDF_LATCHED = 4; + public static final int OLECMDF_NINCHED = 8; + + public static final int OLECMDTEXTF_NONE = 0; + public static final int OLECMDTEXTF_NAME = 1; + public static final int OLECMDTEXTF_STATUS = 2; + + public static final int OLECMDEXECOPT_DODEFAULT = 0; + public static final int OLECMDEXECOPT_PROMPTUSER = 1; + public static final int OLECMDEXECOPT_DONTPROMPTUSER = 2; + public static final int OLECMDEXECOPT_SHOWHELP = 3; + + public static final int OLECMDID_OPEN = 1; + public static final int OLECMDID_NEW = 2; + public static final int OLECMDID_SAVE = 3; + public static final int OLECMDID_SAVEAS = 4; + public static final int OLECMDID_SAVECOPYAS = 5; + public static final int OLECMDID_PRINT = 6; + public static final int OLECMDID_PRINTPREVIEW = 7; + public static final int OLECMDID_PAGESETUP = 8; + public static final int OLECMDID_SPELL = 9; + public static final int OLECMDID_PROPERTIES = 10; + public static final int OLECMDID_CUT = 11; + public static final int OLECMDID_COPY = 12; + public static final int OLECMDID_PASTE = 13; + public static final int OLECMDID_PASTESPECIAL = 14; + public static final int OLECMDID_UNDO = 15; + public static final int OLECMDID_REDO = 16; + public static final int OLECMDID_SELECTALL = 17; + public static final int OLECMDID_CLEARSELECTION = 18; + public static final int OLECMDID_ZOOM = 19; + public static final int OLECMDID_GETZOOMRANGE = 20; + public static final int OLECMDID_UPDATECOMMANDS = 21; + public static final int OLECMDID_REFRESH = 22; + public static final int OLECMDID_STOP = 23; + public static final int OLECMDID_HIDETOOLBARS = 24; + public static final int OLECMDID_SETPROGRESSMAX = 25; + public static final int OLECMDID_SETPROGRESSPOS = 26; + public static final int OLECMDID_SETPROGRESSTEXT = 27; + public static final int OLECMDID_SETTITLE = 28; + public static final int OLECMDID_SETDOWNLOADSTATE = 29; + public static final int OLECMDID_STOPDOWNLOAD = 30; + + /* Ole Property Description flags */ + public static int VARFLAG_FREADONLY = 0x1; + public static int VARFLAG_FSOURCE = 0x2; + public static int VARFLAG_FBINDABLE = 0x4; + public static int VARFLAG_FREQUESTEDIT = 0x8; + public static int VARFLAG_FDISPLAYBIND = 0x10; + public static int VARFLAG_FDEFAULTBIND = 0x20; + public static int VARFLAG_FHIDDEN = 0x40; + public static int VARFLAG_FRESTRICTED = 0x80; + public static int VARFLAG_FDEFAULTCOLLELEM = 0x100; + public static int VARFLAG_FUIDEFAULT = 0x200; + public static int VARFLAG_FNONBROWSABLE = 0x400; + public static int VARFLAG_FREPLACEABLE = 0x800; + public static int VARFLAG_FIMMEDIATEBIND = 0x1000; + + /* Ole Property Description kind */ + public static int VAR_PERINSTANCE = 0; + public static int VAR_STATIC = 1; + public static int VAR_CONST = 2; + public static int VAR_DISPATCH = 3; + + /* Ole Parameter Description flags */ + public static short IDLFLAG_NONE = 0; + public static short IDLFLAG_FIN = 1; + public static short IDLFLAG_FOUT = 2; + public static short IDLFLAG_FLCID = 4; + public static short IDLFLAG_FRETVAL = 8; + + /* Ole Description types */ + public static final short VT_BOOL = 11; // Boolean; True=-1, False=0. + public static final short VT_BSTR = 8; // Binary String. + public static final short VT_BYREF = 16384; // By reference - must be combined with one of the othre VT values + public static final short VT_CY = 6; // Currency. + public static final short VT_DATE = 7; // Date. + public static final short VT_DISPATCH = 9; // IDispatch + public static final short VT_EMPTY = 0; // Not specified. + public static final short VT_ERROR = 10; // Scodes. + public static final short VT_I2 = 2; // 2-byte signed int. + public static final short VT_I4 = 3; // 4-byte signed int. + public static final short VT_NULL = 1; // Null. + public static final short VT_R4 = 4; // 4-byte real. + public static final short VT_R8 = 5; // 8-byte real. + public static final short VT_UI1 = 17; // Unsigned char. + public static final short VT_UI4 = 19; // Unsigned int. + public static final short VT_UNKNOWN = 13; // IUnknown FAR*. + public static final short VT_VARIANT = 12; // VARIANT FAR*. + public static final short VT_PTR = 26; + public static final short VT_USERDEFINED = 29; + public static final short VT_HRESULT = 25; + public static final short VT_DECIMAL = 14; + public static final short VT_I1 = 16; + public static final short VT_UI2 = 18; + public static final short VT_I8 = 20; + public static final short VT_UI8 = 21; + public static final short VT_INT = 22; + public static final short VT_UINT = 23; + public static final short VT_VOID = 24; + public static final short VT_SAFEARRAY = 27; + public static final short VT_CARRAY = 28; + public static final short VT_LPSTR = 30; + public static final short VT_LPWSTR = 31; + public static final short VT_RECORD = 36; + public static final short VT_FILETIME = 64; + public static final short VT_BLOB = 65; + public static final short VT_STREAM = 66; + public static final short VT_STORAGE = 67; + public static final short VT_STREAMED_OBJECT = 68; + public static final short VT_STORED_OBJECT = 69; + public static final short VT_BLOB_OBJECT = 70; + public static final short VT_CF = 71; + public static final short VT_CLSID = 72; + public static final short VT_VERSIONED_STREAM = 73; + public static final short VT_BSTR_BLOB = 0xfff; + public static final short VT_VECTOR = 0x1000; + public static final short VT_ARRAY = 0x2000; + + /* Ole Function Description Invoke Kind values */ + public static final int INVOKE_FUNC = 1; + public static final int INVOKE_PROPERTYGET = 2; + public static final int INVOKE_PROPERTYPUT = 4; + public static final int INVOKE_PROPERTYPUTREF = 8; + + /* Ole Function Description function kind */ + public static final int FUNC_VIRTUAL = 0; + public static final int FUNC_PUREVIRTUAL = 1; + public static final int FUNC_NONVIRTUAL = 2; + public static final int FUNC_STATIC = 3; + public static final int FUNC_DISPATCH = 4; + + /* Ole Function Description function flags */ + public static final short FUNCFLAG_FRESTRICTED = 1; + public static final short FUNCFLAG_FSOURCE = 0x2; + public static final short FUNCFLAG_FBINDABLE = 0x4; + public static final short FUNCFLAG_FREQUESTEDIT = 0x8; + public static final short FUNCFLAG_FDISPLAYBIND = 0x10; + public static final short FUNCFLAG_FDEFAULTBIND = 0x20; + public static final short FUNCFLAG_FHIDDEN = 0x40; + public static final short FUNCFLAG_FUSESGETLASTERROR = 0x80; + public static final short FUNCFLAG_FDEFAULTCOLLELEM = 0x100; + public static final short FUNCFLAG_FUIDEFAULT = 0x200; + public static final short FUNCFLAG_FNONBROWSABLE = 0x400; + public static final short FUNCFLAG_FREPLACEABLE = 0x800; + public static final short FUNCFLAG_FIMMEDIATEBIND = 0x1000; + + /* Ole Function Description calling convention */ + public static final int CC_FASTCALL = 0; + public static final int CC_CDECL = 1; + public static final int CC_MSCPASCAL = 2; + public static final int CC_PASCAL = 2; + public static final int CC_MACPASCAL = 3; + public static final int CC_STDCALL = 4; + public static final int CC_FPFASTCALL = 5; + public static final int CC_SYSCALL = 6; + public static final int CC_MPWCDECL = 7; + public static final int CC_MPWPASCAL = 8; + public static final int CC_MAX = 9; + + static final String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported."; + static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file."; + static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client."; + static final String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format."; + static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object."; + static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry"; + static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID"; + static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance"; + static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory"; + static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type"; + static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface."; + static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application."; + static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed."; + + +public static void error (int code) { + error (code, 0); +} +public static void error (int code, int hresult) { + + switch (code) { + /* Illegal Arguments (non-fatal) */ + case ERROR_INVALID_INTERFACE_ADDRESS :{ + throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG); + } + + /* SWT Errors (non-fatal) */ + case ERROR_CANNOT_CREATE_FILE : { + String msg = ERROR_CANNOT_CREATE_FILE_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_CANNOT_CREATE_OBJECT : { + String msg = ERROR_CANNOT_CREATE_OBJECT_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_CANNOT_OPEN_FILE : { + String msg = ERROR_CANNOT_OPEN_FILE_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_INTERFACE_NOT_FOUND : { + String msg = ERROR_INTERFACE_NOT_FOUND_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_INVALID_CLASSID : { + String msg = ERROR_INVALID_CLASSID_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_CANNOT_ACCESS_CLASSFACTORY : { + String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_CANNOT_CREATE_LICENSED_OBJECT : { + String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_CANNOT_CHANGE_VARIANT_TYPE : { + String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_APPLICATION_NOT_FOUND : { + String msg = ERROR_APPLICATION_NOT_FOUND_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + case ERROR_ACTION_NOT_PERFORMED : { + String msg = ERROR_ACTION_NOT_PERFORMED_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTException (code, msg); + } + + /* OS Failure/Limit (fatal, may occur only on some platforms) */ + case ERROR_OUT_OF_MEMORY : { + String msg = ERROR_ACTION_NOT_PERFORMED_MSG; + if (hresult != 0) msg += " result = "+hresult; + throw new SWTError (code, msg); + } + } + + /* Unknown/Undefined Error */ + SWT.error(code); +} + +/* + * Finds the OLE program id that is associated with an extension. + * The extension may or may not begin with a '.'. On platforms + * that do not support OLE, an empty string is returned. + * + * @param extension the program extension + * @return a string that is the OLE program id or an empty string + * + * @exception SWTError
The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
+ * OleAutomation support. The additional functionality provided by the OLE Object is specified in
+ * its IDL file. The additional methods can either be to get property values (getProperty
),
+ * to set property values (setProperty
) or to invoke a method (invoke
or
+ * invokeNoReply
). Arguments are passed around in the form of Variant
+ * objects.
+ *
+ *
Here is a sample IDL fragment: + * + *
+ * interface IMyControl : IDispatch + * { + * [propget, id(0)] HRESULT maxFileCount([retval, out] int *c); + * [propput, id(0)] HRESULT maxFileCount([in] int c); + * [id(1)] HRESULT AddFile([in] BSTR fileName); + * }; + *+ * + *
An example of how to interact with this extended functionality is shown below:
+ *
+ *
+ */
+public final class OleAutomation {
+ private IDispatch objIDispatch;
+ private String exceptionDescription;
+ private ITypeInfo objITypeInfo;
+
+OleAutomation(int address) {
+ if (address == 0) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
+ objIDispatch = new IDispatch(address);
+ objIDispatch.AddRef();
+}
+/**
+ * Creates an OleAutomation object for the specified client.
+ *
+ * @param clientSite the site for the OLE Document or ActiveX Control whose additional functionality
+ * you need to access
+ *
+ * @exception SWTError
+ * OleAutomation automation = new OleAutomation(myControlSite);
+ *
+ * // Look up the ID of the maxFileCount parameter
+ * int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
+ * int maxFileCountID = rgdispid[0];
+ *
+ * // Set the property maxFileCount to 100:
+ * if (automation.setProperty(maxFileCountID, new Variant(100))) {
+ * System.out.println("Max File Count was successfully set.");
+ * }
+ *
+ * // Get the new value of the maxFileCount parameter:
+ * Variant pVarResult = automation.getProperty(maxFileCountID);
+ * if (pVarResult != null) {
+ * System.out.println("Max File Count is "+pVarResult.getInt());
+ * }
+ *
+ * // Invoke the AddFile method
+ * // Look up the IDs of the AddFile method and its parameter
+ * rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
+ * int dispIdMember = rgdispid[0];
+ * int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
+ *
+ * // Convert arguments to Variant objects
+ * Variant[] rgvarg = new Variant[1];
+ * String fileName = "C:\\testfile";
+ * rgvarg[0] = new Variant(fileName);
+ *
+ * // Call the method
+ * Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
+ *
+ * // Check the return value
+ * if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
+ * System.out.println("Failed to add file "+fileName);
+ * }
+ *
+ * automation.dispose();
+ *
+ *
+ * This method releases the IDispatch interface on the OLE Document or ActiveX Control.
+ * Do not use the OleAutomation object after it has been disposed.
+ */
+public void dispose() {
+
+ if (objIDispatch != null){
+ objIDispatch.Release();
+ }
+ objIDispatch = null;
+
+ if (objITypeInfo != null){
+ objITypeInfo.Release();
+ }
+ objITypeInfo = null;
+
+}
+int getAddress() {
+ return objIDispatch.getAddress();
+}
+public String getHelpFile(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] file = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file );
+ if (rc == OLE.S_OK) return file[0];
+ return null;
+}
+public String getDocumentation(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] doc = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null );
+ if (rc == OLE.S_OK) return doc[0];
+ return null;
+}
+public OlePropertyDescription getPropertyDescription(int index) {
+ if (objITypeInfo == null) return null;
+ int[] ppVarDesc = new int[1];
+ int rc = objITypeInfo.GetVarDesc(index, ppVarDesc);
+ if (rc != OLE.S_OK) return null;
+ VARDESC1 vardesc = new VARDESC1();
+ COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC1.sizeof);
+
+ OlePropertyDescription data = new OlePropertyDescription();
+ data.id = vardesc.memid;
+ data.name = getName(vardesc.memid);
+ data.type = vardesc.elemdescVar_tdesc_vt;
+ if (data.type == OLE.VT_PTR) {
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + 4, 2);
+ data.type = vt[0];
+ }
+ data.flags = vardesc.wVarFlags;
+ data.kind = vardesc.varkind;
+ data.description = getDocumentation(vardesc.memid);
+ data.helpFile = getHelpFile(vardesc.memid);
+
+ objITypeInfo.ReleaseVarDesc(ppVarDesc[0]);
+ return data;
+}
+public OleFunctionDescription getFunctionDescription(int index) {
+ if (objITypeInfo == null) return null;
+ int[] ppFuncDesc = new int[1];
+ int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc);
+ if (rc != OLE.S_OK) return null;
+ FUNCDESC1 funcdesc = new FUNCDESC1();
+ COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC1.sizeof);
+
+ OleFunctionDescription data = new OleFunctionDescription();
+
+ data.id = funcdesc.memid;
+ data.optionalArgCount = funcdesc.cParamsOpt;
+ data.invokeKind = funcdesc.invkind;
+ data.funcKind = funcdesc.funckind;
+ data.flags = funcdesc.wFuncFlags;
+ data.callingConvention = funcdesc.callconv;
+ data.documentation = getDocumentation(funcdesc.memid);
+ data.helpFile = getHelpFile(funcdesc.memid);
+
+ String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1);
+ data.name = names[0];
+ data.args = new OleParameterDescription[funcdesc.cParams];
+ for (int i = 0; i < data.args.length; i++) {
+ data.args[i] = new OleParameterDescription();
+ data.args[i].name = names[i + 1];
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * 16 + 4, 2);
+ if (vt[0] == OLE.VT_PTR) {
+ int[] pTypedesc = new int[1];
+ COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * 16, 4);
+ short[] vt2 = new short[1];
+ COM.MoveMemory(vt2, pTypedesc[0] + 4, 2);
+ vt[0] = (short)(vt2[0] | COM.VT_BYREF);
+ }
+ data.args[i].type = vt[0];
+ short[] wParamFlags = new short[1];
+ COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * 16 + 12, 2);
+ data.args[i].flags = wParamFlags[0];
+ }
+
+ data.returnType = funcdesc.elemdescFunc_tdesc_vt;
+ if (data.returnType == OLE.VT_PTR) {
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + 4, 2);
+ data.returnType = vt[0];
+ }
+
+ objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]);
+ return data;
+}
+public TYPEATTR getTypeInfoAttributes() {
+ if (objITypeInfo == null) return null;
+ int[] ppTypeAttr = new int[1];
+ int rc = objITypeInfo.GetTypeAttr(ppTypeAttr);
+ if (rc != OLE.S_OK) return null;
+ TYPEATTR typeattr = new TYPEATTR();
+ COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof);
+ objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]);
+ return typeattr;
+}
+public String getName(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] name = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null );
+ if (rc == OLE.S_OK) return name[0];
+ return null;
+}
+public String[] getNames(int dispId, int maxSize) {
+ if (objITypeInfo == null) return new String[0];
+ String[] names = new String[maxSize];
+ int[] count = new int[1];
+ int rc = objITypeInfo.GetNames(dispId, names, maxSize, count);
+ if (rc == OLE.S_OK) {
+ String[] newNames = new String[count[0]];
+ System.arraycopy(names, 0, newNames, 0, count[0]);
+ return newNames;
+ }
+ return new String[0];
+}
+/**
+ * Returns the positive integer values (IDs) that are associated with the specified names by the
+ * IDispatch implementor. If you are trying to get the names of the parameters in a method, the first
+ * String in the names array must be the name of the method followed by the names of the parameters.
+ *
+ * @param names an array of names for which you require the identifiers
+ *
+ * @return positive integer values that are associated with the specified names in the same
+ * order as the names where provided; or null if the names are unknown
+ */
+public int[] getIDsOfNames(String[] names) {
+
+ int[] rgdispid = new int[names.length];
+ int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid);
+ if (result != COM.S_OK) return null;
+
+ return rgdispid;
+}
+/**
+ * Returns a description of the last error encountered.
+ *
+ * @return a description of the last error encountered
+ */
+public String getLastError() {
+
+ return exceptionDescription;
+
+}
+/**
+ * Returns the value of the property specified by the dispIdMember.
+ *
+ * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @return the value of the property specified by the dispIdMember
+ */
+public Variant getProperty(int dispIdMember) {
+ // get the IDispatch interface for the control
+ if (objIDispatch == null) return null;
+
+ DISPPARAMS pDispParams = new DISPPARAMS();
+ EXCEPINFO excepInfo = new EXCEPINFO();
+ int[] pArgErr = new int[1];
+ int pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, COM.DISPATCH_PROPERTYGET, pDispParams, pVarResultAddress, excepInfo, pArgErr);
+
+ // save error string and cleanup EXCEPINFO
+ manageExcepinfo(result, excepInfo);
+
+ Variant pVarResult = null;
+ if (result == COM.S_OK) {
+ pVarResult = new Variant();
+ pVarResult.setData(pVarResultAddress);
+ }
+
+ COM.VariantClear(pVarResultAddress);
+ OS.GlobalFree(pVarResultAddress);
+
+ return pVarResult;
+
+}
+/**
+ * Invokes a method on the OLE Object; the method has no parameters.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, null, null, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+/**
+ * Invokes a method on the OLE Object; the method has no optional parameters.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember, Variant[] rgvarg) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, rgvarg, null, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+/**
+ * Invokes a method on the OLE Object; the method has optional parameters. It is not
+ * neccessary to specify all the optional parameters, only include the parameters for which
+ * you are providing values.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
+ * parameter IDs must be in the same order as their corresponding values;
+ * all arguments must have an identifier - identifiers can be obtained using
+ * OleAutomation.getIDsOfNames
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, rgvarg, rgdispidNamedArgs, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+private int invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) {
+
+ // get the IDispatch interface for the control
+ if (objIDispatch == null) return COM.E_FAIL;
+
+ // create a DISPPARAMS structure for the input parameters
+ DISPPARAMS pDispParams = new DISPPARAMS();
+ // store arguments in rgvarg
+ if (rgvarg != null && rgvarg.length > 0) {
+ pDispParams.cArgs = rgvarg.length;
+ pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof * rgvarg.length);
+ int offset = 0;
+ for (int i = rgvarg.length - 1; i >= 0 ; i--) {
+ rgvarg[i].getData(pDispParams.rgvarg + offset);
+ offset += Variant.sizeof;
+ }
+ }
+
+ // if arguments have ids, store the ids in rgdispidNamedArgs
+ if (rgdispidNamedArgs != null && rgdispidNamedArgs.length > 0) {
+ pDispParams.cNamedArgs = rgdispidNamedArgs.length;
+ pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length);
+ int offset = 0;
+ for (int i = rgdispidNamedArgs.length; i > 0; i--) {
+ COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4);
+ offset += 4;
+ }
+ }
+
+ // invoke the method
+ EXCEPINFO excepInfo = new EXCEPINFO();
+ int[] pArgErr = new int[1];
+ int pVarResultAddress = 0;
+ if (pVarResult != null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, COM.DISPATCH_METHOD, pDispParams, pVarResultAddress, excepInfo, pArgErr);
+
+ if (pVarResultAddress != 0){
+ pVarResult.setData(pVarResultAddress);
+ COM.VariantClear(pVarResultAddress);
+ OS.GlobalFree(pVarResultAddress);
+ }
+
+ // free the Dispparams resources
+ if (pDispParams.rgdispidNamedArgs != 0){
+ OS.GlobalFree(pDispParams.rgdispidNamedArgs);
+ }
+ if (pDispParams.rgvarg != 0) {
+ int offset = 0;
+ for (int i = 0, length = rgvarg.length; i < length; i++){
+ COM.VariantClear(pDispParams.rgvarg + offset);
+ offset += Variant.sizeof;
+ }
+ OS.GlobalFree(pDispParams.rgvarg);
+ }
+
+ // save error string and cleanup EXCEPINFO
+ manageExcepinfo(result, excepInfo);
+
+ return result;
+}
+/**
+ * Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE,
+ * the IDispatch interface was not well defined and some applications (mainly Word) did not support
+ * a return value. For these applications, call this method instead of calling
+ * public void invoke(int dispIdMember)
.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @exception SWTError
public void invoke(int dispIdMember, Variant[] rgvarg)
.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @exception SWTError public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
+ * parameter IDs must be in the same order as their corresponding values;
+ * all arguments must have an identifier - identifiers can be obtained using
+ * OleAutomation.getIDsOfNames
+ *
+ * @exception SWTError The OleClientSite provides the following capabilities: + *
This object implements the OLE Interfaces IUnknown, IOleClientSite, IAdviseSink, + * IOleInPlaceSite + * + *
In addition to the behaviour provided by OleClientSite, this object provides the following: + *
This object implements the OLE Interfaces IOleControlSite, IDispatch, and IPropertyNotifySink. + * + *
+* This method notifies all listeners that an event +* has occurred. +* +* @param eventType the desired SWT event +* @param event the event data +* +* @exception SWTError
This object implements the OLE Interfaces IUnknown and IOleInPlaceFrame + * + *
OleFrame allows the container to do the following:
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the Container location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getContainerMenus(){ + return containerMenuItems; +} +/** + * + * Returns the application menu items that will appear in the File location when an OLE Document + * is in-place activated. + * + *
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the File location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getFileMenus(){ + return fileMenuItems; +} +int getIOleInPlaceFrame() { + return iOleInPlaceFrame.getAddress(); +} +Menu getMenubar(){ + return menubar; +} +private int getMenuItemID(int hMenu, int index) { + int id = 0; + MENUITEMINFO lpmii = new MENUITEMINFO(); + lpmii.cbSize = MENUITEMINFO.sizeof; + lpmii.fMask = OS.MIIM_STATE | OS.MIIM_SUBMENU | OS.MIIM_ID; + OS.GetMenuItemInfo(hMenu, index, true, lpmii); + if ((lpmii.fState & OS.MF_POPUP) == OS.MF_POPUP) { + id = lpmii.hSubMenu; + } else { + id = lpmii.wID; + } + return id; +} +private int GetWindow(int phwnd) { + if (phwnd != 0) { + COM.MoveMemory(phwnd, new int[] {handle}, 4); + } + return COM.S_OK; +} +/** + * + * Returns the application menu items that will appear in the Window location when an OLE Document + * is in-place activated. + * + *
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the Window location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getWindowMenus(){ + return windowMenuItems; +} +private int InsertMenus(int hmenuShared, int lpMenuWidths) { + // locate menu bar + if (menubar == null || menubar.isDisposed()) { + COM.MoveMemory(lpMenuWidths, new int[] {0}, 4); + return COM.S_OK; + } + int hMenu = menubar.handle; + + // Create a holder for menu information. This will be passed down to + // the OS and the OS will fill in the requested information for each menu. + MENUITEMINFO lpmii = new MENUITEMINFO(); + int hHeap = OS.GetProcessHeap(); + int maxTextLength = 128; + int pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, maxTextLength); + lpmii.cbSize = MENUITEMINFO.sizeof; + lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU; + lpmii.dwTypeData = pszText; + lpmii.cch = maxTextLength; + + // Loop over all "File-like" menus in the menubar and get information about the + // item from the OS. + int fileMenuCount = 0; + int newindex = 0; + if (this.fileMenuItems != null) { + for (int i = 0; i < this.fileMenuItems.length; i++) { + MenuItem item = this.fileMenuItems[i]; + if (item != null) { + int index = item.getParent().indexOf(item); + lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact nuber of characters in name. Reset it to our max size + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) { + // keep track of the number of items + fileMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths, new int[] {fileMenuCount}, 4); + + // Loop over all "Container-like" menus in the menubar and get information about the + // item from the OS. + int containerMenuCount = 0; + if (this.containerMenuItems != null) { + for (int i = 0; i < this.containerMenuItems.length; i++) { + MenuItem item = this.containerMenuItems[i]; + if (item != null) { + int index = item.getParent().indexOf(item); + lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact nuber of characters in name. Reset it to a large number + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) { + // keep track of the number of items + containerMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths + 8, new int[] {containerMenuCount}, 4); + + // Loop over all "Window-like" menus in the menubar and get information about the + // item from the OS. + int windowMenuCount = 0; + if (this.windowMenuItems != null) { + for (int i = 0; i < this.windowMenuItems.length; i++) { + MenuItem item = this.windowMenuItems[i]; + if (item != null) { + int index = item.getParent().indexOf(item); + lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact nuber of characters in name. Reset it to a large number + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) { + // keep track of the number of items + windowMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths + 16, new int[] {windowMenuCount}, 4); + + // free resources used in querying the OS + if (pszText != 0) + OS.HeapFree(hHeap, 0, pszText); + return COM.S_OK; +} +private void onDispose(Event e) { + + releaseObjectInterfaces(); + currentdoc = null; + + this.Release(); +} +private void onResize(Event e) { + if (objIOleInPlaceActiveObject != null) { + RECT lpRect = new RECT(); + OS.GetClientRect(handle, lpRect); + objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true); + } +} +private int QueryInterface(int riid, int ppvObject) { +// implements IUnknown, IOleInPlaceFrame, IOleContainer, IOleInPlaceUIWindow + if (riid == 0 || ppvObject == 0) + return COM.E_INVALIDARG; + GUID guid = new GUID(); + COM.MoveMemory(guid, riid, GUID.sizeof); + if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIOleInPlaceFrame) ) { + COM.MoveMemory(ppvObject, new int[] {iOleInPlaceFrame.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + + COM.MoveMemory(ppvObject, new int[] {0}, 4); + return COM.E_NOINTERFACE; +} +/** + * Decrement the count of references to this instance + * + * @return the current reference count + */ +int Release() { + refCount--; + if (refCount == 0){ + disposeCOMInterfaces(); + COM.CoFreeUnusedLibraries(); + } + return refCount; +} +private void releaseObjectInterfaces() { + if (objIOleInPlaceActiveObject != null) { + objIOleInPlaceActiveObject.Release(); + } + objIOleInPlaceActiveObject = null; +} +private int RemoveMenus(int hmenuShared) { + + if (menubar == null || menubar.isDisposed()) return COM.S_FALSE; + + int hMenu = menubar.handle; + + Vector ids = new Vector(); + if (this.fileMenuItems != null) { + for (int i = 0; i < this.fileMenuItems.length; i++) { + MenuItem item = this.fileMenuItems[i]; + if (item != null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + // get Id from original menubar + int id = getMenuItemID(hMenu, index); + ids.addElement(new Integer(id)); + } + } + } + if (this.containerMenuItems != null) { + for (int i = 0; i < this.containerMenuItems.length; i++) { + MenuItem item = this.containerMenuItems[i]; + if (item != null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + int id = getMenuItemID(hMenu, index); + ids.addElement(new Integer(id)); + } + } + } + if (this.windowMenuItems != null) { + for (int i = 0; i < this.windowMenuItems.length; i++) { + MenuItem item = this.windowMenuItems[i]; + if (item != null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + int id = getMenuItemID(hMenu, index); + ids.addElement(new Integer(id)); + } + } + } + int index = OS.GetMenuItemCount(hmenuShared) - 1; + for (int i = index; i >= 0; i--) { + int id = getMenuItemID(hmenuShared, i); + if (ids.contains(new Integer(id))){ + OS.RemoveMenu(hmenuShared, i, OS.MF_BYPOSITION); + } + } + return COM.S_OK; +} +private int RequestBorderSpace(int pborderwidths) { + return COM.S_OK; +} +int SetActiveObject(int pActiveObject, int pszObjName) { + if (objIOleInPlaceActiveObject != null) { + objIOleInPlaceActiveObject.Release(); + objIOleInPlaceActiveObject = null; + } + if (pActiveObject != 0) { + objIOleInPlaceActiveObject = new IOleInPlaceActiveObject(pActiveObject); + objIOleInPlaceActiveObject.AddRef(); + } + + return COM.S_OK; +} +private int SetBorderSpace(int pborderwidths) { + // A Control/Document can : + // Use its own toolbars, requesting border space of a specific size, or, + // Use no toolbars, but force the container to remove its toolbars by passing a + // valid BORDERWIDTHS structure containing nothing but zeros in the pborderwidths parameter, or, + // Use no toolbars but allow the in-place container to leave its toolbars up by + // passing NULL as the pborderwidths parameter. + + RECT borderwidth = new RECT(); + if (pborderwidths == 0 || currentdoc == null ) return COM.S_OK; + + COM.MoveMemory(borderwidth, pborderwidths, RECT.sizeof); + currentdoc.setBorderSpace(borderwidth); + + return COM.S_OK; +} +/** + * + * Specify the menu items that should appear in the Container location when an OLE Document + * is in-place activated. + * + *
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + *
This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param containerMenus an array of top level MenuItems to be inserted into the Container location of + * the menubar + */ +public void setContainerMenus(MenuItem[] containerMenus){ + containerMenuItems = containerMenus; +} +OleClientSite getCurrentDocument() { + return currentdoc; +} +void setCurrentDocument(OleClientSite doc) { + currentdoc = doc; + + if (currentdoc != null && objIOleInPlaceActiveObject != null) { + RECT lpRect = new RECT(); + OS.GetClientRect(handle, lpRect); + objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true); + } +} +/** + * + * Specify the menu items that should appear in the File location when an OLE Document + * is in-place activated. + * + *
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + *
This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param fileMenus an array of top level MenuItems to be inserted into the Flie location of + * the menubar + */ +public void setFileMenus(MenuItem[] fileMenus){ + fileMenuItems = fileMenus; +} +public boolean forceFocus () { + if (currentdoc == null) return super.forceFocus(); + return currentdoc.forceFocus(); +} +private int SetMenu(int hmenuShared, int holemenu, int hwndActiveObject) { + + int inPlaceActiveObject = 0; + if (objIOleInPlaceActiveObject != null) + inPlaceActiveObject = objIOleInPlaceActiveObject.getAddress(); + + if (menubar == null || menubar.isDisposed()){ + return COM.OleSetMenuDescriptor(0, getShell().handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject); + } + + int handle = menubar.getShell().handle; + + if (hmenuShared == 0 && holemenu == 0) { + // re-instate the original menu - this occurs on deactivation + hmenuShared = menubar.handle; + } + if (hmenuShared == 0) return COM.E_FAIL; + + OS.SetMenu(handle, hmenuShared); + OS.DrawMenuBar(handle); + + return COM.OleSetMenuDescriptor(holemenu, handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject); +} +private void setMenubar(Menu bar){ + menubar = bar; +} +/** + * + * Set the menu items that should appear in the Window location when an OLE Document + * is in-place activated. + * + *
When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + *
This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param windowMenus an array of top level MenuItems to be inserted into the Window location of + * the menubar + */ +public void setWindowMenus(MenuItem[] windowMenus){ + windowMenuItems = windowMenus; +} +private int TranslateAccelerator(int lpmsg, int wID){ + return COM.E_NOTIMPL; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java new file mode 100755 index 0000000000..6ea8d8b923 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java @@ -0,0 +1,24 @@ +package org.eclipse.swt.ole.win32; + +import org.eclipse.swt.internal.ole.win32.COM; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +public class OleFunctionDescription { + + public int id; + public String name; + public OleParameterDescription[] args; + public int optionalArgCount; + public short returnType; + public int invokeKind; + public int funcKind; + public short flags; + public int callingConvention; + public String documentation; + public String helpFile; + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java new file mode 100755 index 0000000000..111bed3bc5 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java @@ -0,0 +1,17 @@ +package org.eclipse.swt.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * WebSphere Studio Workbench + * (c) Copyright IBM Corp 2000 + */ + +/** + */ +public interface OleListener +{ +/** + * + */ +public void handleEvent(OleEvent event); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java new file mode 100755 index 0000000000..797c891085 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java @@ -0,0 +1,12 @@ +package org.eclipse.swt.ole.win32; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +public class OleParameterDescription { + public String name; + public short flags; + public short type; +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java new file mode 100755 index 0000000000..4a4a84b75a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java @@ -0,0 +1,179 @@ +package org.eclipse.swt.ole.win32; + +import org.eclipse.swt.internal.ole.win32.*; +import org.eclipse.swt.*; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved + */ + +final class OlePropertyChangeSink { + + private OleControlSite controlSite; + //private IUnknown objIUnknown; + + private COMObject iUnknown; + private COMObject iPropertyNotifySink; + + private int refCount; + + private int propertyCookie; + + private OleEventTable eventTable; + +OlePropertyChangeSink(OleControlSite controlSite) { + + this.controlSite = controlSite; + + createCOMInterfaces(); +} +void addListener(int propertyID, OleListener listener) { + if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) eventTable = new OleEventTable (); + eventTable.hook(propertyID, listener); +} +int AddRef() { + refCount++; + return refCount; +} +void connect(IUnknown objIUnknown) { + + // Set up property change notification sink + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) { + IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]); + if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) { + IConnectionPoint cp = new IConnectionPoint(ppvObject[0]); + int[] cookie = new int[1]; + if (cp.Advise(iPropertyNotifySink.getAddress(), cookie) == COM.S_OK) { + propertyCookie = cookie[0]; + } + cp.Release(); + } + cpc.Release(); + } +} +private void createCOMInterfaces() { + // register each of the interfaces that this object implements + iUnknown = new COMObject(new int[]{2, 0, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + }; + + iPropertyNotifySink = new COMObject(new int[]{2, 0, 0, 1, 1}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return OnChanged(args[0]);} + public int method4(int[] args) {return OnRequestEdit(args[0]);} + }; +} +void disconnect(IUnknown objIUnknown) { + + // disconnect property notification sink + if (propertyCookie != 0 && objIUnknown != null) { + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) { + IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]); + if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) { + IConnectionPoint cp = new IConnectionPoint(ppvObject[0]); + if (cp.Unadvise(propertyCookie) == COM.S_OK) { + propertyCookie = 0; + } + cp.Release(); + } + cpc.Release(); + } + } +} +private void disposeCOMInterfaces() { + + if (iUnknown != null); + iUnknown.dispose(); + iUnknown = null; + + if (iPropertyNotifySink != null) + iPropertyNotifySink.dispose(); + iPropertyNotifySink = null; + +} +/** +* Notify listeners of an event. +*
+* This method notifies all listeners that an event +* has occurred. +* +* @param eventType the desired SWT event +* @param event the event data +* +* @exception SWTError
It is used within the OleAutomation object for getting a property, setting a property or invoking + * a method on an OLE Control or OLE Document. + * + */ +public final class Variant +{ + // A variant always takes up 16 bytes, no matter what you + // store in it. Objects, strings, and arrays are not physically + // stored in the Variant; in these cases, four bytes of the + // Variant are used to hold either an object reference, or a + // pointer to the string or array. The actual data are stored elsewhere. + public static final int sizeof = 16; + + private short type; // OLE.VT_* type + + private boolean booleanData; + private float floatData; + private int intData; + private short shortData; + private String stringData; + private int byRefPtr; + private OleAutomation dispatchData; + private IUnknown unknownData; +Variant(){ + type = COM.VT_EMPTY; +} +/** + * Create a Variant object which represents a Java float as a VT_R4. + * + * @param val the Java float value that this Variant represents + * + */ +public Variant(float val) { + type = COM.VT_R4; + floatData = val; + +} +/** + * Create a Variant object which represents a Java int as a VT_I4. + * + * @param val the Java int value that this Variant represents + * + */ + public Variant(int val) { + + type = COM.VT_I4; + intData = val; +} +/** + * Create a Variant object which contains a reference to the data being transferred. + * + *
When creating a VT_BYREF Variant, you must give the full Variant type including VT_BYREF
+ * (such as short byRefType = OLE.VT_BSTR | OLE.VT_BYREF
).
+ *
+ * @param ptr a pointer to the data being transferred.
+ * @param byRefType the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREF
+ *
+ */
+public Variant(int ptr, short byRefType) {
+ type = byRefType;
+ byRefPtr = ptr;
+}
+/**
+ * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
+ *
+ * @param automation the OleAutomation object that this Variant represents
+ *
+ */
+public Variant(OleAutomation automation) {
+ type = COM.VT_DISPATCH;
+ dispatchData = automation;
+}
+/**
+ * Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN.
+ *
+ *
The caller is expected to have appropriately invoked unknown.AddRef() before creating + * this Variant. + * + * @param unknown the IUnknown object that this Variant represents + * + */ +public Variant(IUnknown unknown) { + type = COM.VT_UNKNOWN; + unknownData = unknown; +} +/** + * Create a Variant object which represents a Java String as a VT_BSTR. + * + * @param string the Java String value that this Variant represents + * + */ +public Variant(String string) { + type = COM.VT_BSTR; + stringData = string; +} +/** + * Create a Variant object which represents a Java short as a VT_I2. + * + * @param val the Java short value that this Variant represents + * + */ +public Variant(short val) { + type = COM.VT_I2; + shortData = val; +} +/** + * Create a Variant object which represents a Java boolean as a VT_BOOL. + * + * @param val the Java boolean value that this Variant represents + * + */ +public Variant(boolean val) { + + type = COM.VT_BOOL; + booleanData = val; +} +/** + * Returns the OleAutomation object represented by this Variant. + * + *
If this Variant does not contain an OleAutomation object, an attempt is made to + * coerce the Variant type into an OleAutomation object. If this fails, an error is + * thrown. + * + * @return the OleAutomation object represented by this Variant + * + * @exception SWTError + * ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an OleAutomation object + */ +public OleAutomation getAutomation() { + if (type == COM.VT_DISPATCH) + return dispatchData; + + // try to coerce the value to the desired type + int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof); + int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH); + if (result != COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant autoVar = new Variant(); + autoVar.setData(newPtr); + return autoVar.getAutomation(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + // OleAutomation object is created as Variant Clear + // will result in a Release being performed on the + // Dispatch object + OS.GlobalFree(newPtr); + } +} +/** + * Returns the Java boolean represented by this Variant. + * + *
If this Variant does not contain a Java boolean, an attempt is made to + * coerce the Variant type into a Java boolean. If this fails, an error is thrown. + * + * @return the Java boolean represented by this Variant + * + * @exception SWTError + *
If this Variant does not contain a reference to data, zero is returned. + * + * @return a pointer to the referenced data represented by this Variant or 0 + * + */ +public int getByRef() { + if ((type & COM.VT_BYREF)== COM.VT_BYREF) + return byRefPtr; + + return 0; +} +void getData(int pData){ + if (pData == 0) OLE.error(OLE.ERROR_OUT_OF_MEMORY); + + COM.VariantInit(pData); + + if ((type & COM.VT_BYREF) == COM.VT_BYREF) { + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new int[]{byRefPtr}, 4); + return; + } + + switch (type) { + case COM.VT_EMPTY : + break; + case COM.VT_BOOL : + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new short[]{(short)((booleanData) ? 1 : 0)}, 2); + break; + case COM.VT_R4 : + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new float[]{floatData}, 4); + break; + case COM.VT_I4 : + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new int[]{intData}, 4); + break; + case COM.VT_DISPATCH : + IDispatch dispatch = new IDispatch(dispatchData.getAddress()); + dispatch.AddRef(); + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new int[]{dispatch.getAddress()}, 4); + break; + case COM.VT_UNKNOWN : + unknownData.AddRef(); + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new int[]{unknownData.getAddress()}, 4); + break; + case COM.VT_I2 : + COM.MoveMemory(pData, new short[] {type}, 2); + COM.MoveMemory(pData + 8, new short[]{shortData}, 2); + break; + case COM.VT_BSTR : + COM.MoveMemory(pData, new short[] {type}, 2); + char[] data = (stringData+"\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pData + 8, new int[] {ptr}, 4); + break; + + default : + OLE.error(SWT.ERROR_NOT_IMPLEMENTED); + } +} +/** + * Returns the Java float represented by this Variant. + * + *
If this Variant does not contain a Java float, an attempt is made to + * coerce the Variant type into a Java float. If this fails, an error is thrown. + * + * @return the Java float represented by this Variant + * + * @exception SWTError + *
If this Variant does not contain a Java int, an attempt is made to + * coerce the Variant type into a Java int. If this fails, an error is thrown. + * + * @return the Java int represented by this Variant + * + * @exception SWTError + *
If this Variant does not contain a Java short, an attempt is made to + * coerce the Variant type into a Java short. If this fails, an error is thrown. + * + * @return the Java short represented by this Variant + * + * @exception SWTError + *
If this Variant does not contain a Java String, an attempt is made to + * coerce the Variant type into a Java String. If this fails, an error is thrown. + * + * @return the Java String represented by this Variant + * + * @exception SWTError + *
If this Variant does not contain an IUnknown object, an attempt is made to + * coerce the Variant type into an IUnknown object. If this fails, an error is + * thrown. + * + * @return the IUnknown object represented by this Variant + * + * @exception SWTError + *
+ * Application code does not need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no dispose()
method is provided.
+ *
ALL_PAGES
PAGE_RANGE
SELECTION
scope
field value indicating that
+ * all pages should be printed
+ */
+ public static final int ALL_PAGES = 0;
+
+ /**
+ * scope
field value indicating that
+ * the range of pages specified by startPage and endPage
+ * should be printed
+ */
+ public static final int PAGE_RANGE = 1;
+
+ /**
+ * scope
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 PrintDialog
.
+ * 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.
+ *
+ * @exception IllegalArgumentException + * IMPORTANT: This class is intended to be subclassed only + * within the SWT implementation. + *
+ */ + +public class PrintDialog extends Dialog { + int scope = PrinterData.ALL_PAGES; + int startPage = -1, endPage = -1; + boolean 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
+ * The style value is either one of the style constants defined in
+ * class SWT
which is applicable to instances of this
+ * class, or must be built by bitwise OR'ing together
+ * (that is, using the int
"|" operator) two or more
+ * of those SWT
style constants. The class description
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ *
ALL_PAGES
PAGE_RANGE
SELECTION
ALL_PAGES
PAGE_RANGE
SELECTION
+ * Note that this value is only valid if the scope is PAGE_RANGE
.
+ *
+ * Note that this value is only valid if the scope is PAGE_RANGE
.
+ *
new GC(printer)
+ * and then draw on the printer GC using the usual graphics calls.
+ *
+ * A Printer
object may be constructed by providing
+ * a PrinterData
object which identifies the printer.
+ * A PrintDialog
presents a print dialog to the user
+ * and returns an initialized instance of PrinterData
.
+ * Alternatively, calling new Printer()
will construct a
+ * printer object for the user's default printer.
+ *
+ * Application code must explicitly invoke the Printer.dispose()
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ *
PrinterData
objects
+ * representing all available printers.
+ *
+ * @exception IllegalArgumentException PrinterData
object representing
+ * the default printer.
+ *
+ * @exception IllegalArgumentException + * You must dispose the printer when it is no longer required. + *
+ * + * @exception IllegalArgumentExceptionPrinterData
+ * object representing the desired printer.
+ * + * You must dispose the printer when it is no longer required. + *
+ * + * @param data the printer data for the specified printer + * + * @exception IllegalArgumentExceptionDevice
class.
+ */
+protected void create(DeviceData deviceData) {
+ data = (PrinterData)deviceData;
+ byte[] driver = Converter.wcsToMbcs(0, data.driver, true);
+ byte[] device = Converter.wcsToMbcs(0, data.name, true);
+ int lpInitData = 0;
+ byte buffer [] = data.otherData;
+ int hHeap = OS.GetProcessHeap();
+ if (buffer != null && buffer.length != 0) {
+ lpInitData = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory(lpInitData, buffer, buffer.length);
+ }
+ handle = OS.CreateDC(driver, device, 0, lpInitData);
+ if (lpInitData != 0) OS.HeapFree(hHeap, 0, lpInitData);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new GC handle.
+ *
+ * IMPORTANT: This method is not part of the public
+ * API for Printer
. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ * IMPORTANT: This method is not part of the public
+ * API for Printer
. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ * 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. + *
+ * + * @return true if the job started successfully and false otherwise. + * + * @exception SWTException+ * After calling startJob, this method may be called any number of times + * along with a matching endPage. + *
+ * + * @return true if the page started successfully and false otherwise. + * + * @exception SWTException+ * 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). + *
+ * 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. + * + * @return the required bounds to produce the given client area + * + * @exception SWTExceptionFontData
s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however,
+ * a Font
object may 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
+ */
+public PrinterData getPrinterData() {
+ return data;
+}
+
+/**
+ * Checks the validity of this device.
+ *
+ * @exception SWTException Device
class.
+ */
+protected void release() {
+ super.release();
+ data = null;
+}
+
+/**
+ * Destroys the printer handle.
+ * This method is called internally by the dispose
+ * mechanism of the Device
class.
+ */
+protected void destroy() {
+ if (handle != 0) OS.DeleteDC(handle);
+ handle = 0;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
@@ -0,0 +1,13 @@
+
+
+
+
+ true
if the file is launched, otherwise false
+ *
+ * @exception SWTError true
if the file is launched, otherwise false
+ *
+ * @exception SWTError true
if the file is launched, otherwise false
+ *
+ * @exception SWTError true
if the file is launched, otherwise false
+ *
+ * @exception SWTError null
if not present
+ */
+public static Image loadLargeIcon(Display display, String fileName, int index) {
+ return loadSmallIcon(display, fileName, index);
+}
+
+/**
+ * Given a filename and registry index, this method will search
+ * the platform registry and return the registered small image
+ * associated with the filename. If the filename is not
+ * registered null is returned. Note: if the platform does not
+ * have registry support, null is always returned.
+ * The caller is responsible for destroying the Image.
+ * @param fileName name of exectuable file
+ * @param index registry index
+ * @return org.eclipse.swt.graphics.Image of registered icon or
+ * null
if not present
+ */
+public static Image loadSmallIcon(Display display, String fileName, int index) {
+ return null;
+}
+
+/**
+ * Given a RichText widget this method will attempt to print the
+ * contents of the editor.
+ * @param editor the widget that contains the text to be printed
+ */
+public static void print(org.eclipse.swt.widgets.Control editor) {
+
+}
+
+/**
+* Answer the path, name and command line parameters registered
+* for a given extension.
+* +* +* @param extension the extension to query. Must provide leading '.' +* +* @return the path, name and command line parameters registered for +* the extension. Empty string if the extension is not registered. +*/ +public static String queryExtension(String extension) { + return null; +} + +/** + * Given a file extension (something like .html ) the function + * returns the full path of the icon image registered to + * the extension. The file name has a comma and index appended + * to it. This is the offset into an icon registry of the image. + * @param extension the string that appears after the last dot + * of the file name + * @return String full path of executable file registered to the + * extension. If no extension has been registered an empty + * string is returned. Appended to the end after a comma + * is the offset of the image + */ +public static String queryExtensionIcon(String extension) { + return ""; +} + +/** + * This function querys the registery for a list of all the + * executable programs registered on the platform. + * @return String[] an array of strings. Each string contains the + * full path of the executable program. Duplicates may exist + * since multiple extensions may be registered to the same program. + */ +public static String[] queryRegisteredPrograms() { + return new String[0]; +} + +/** + * This method will change the parent of control to the composite. + * @param control org.eclipse.swt.widgets.Control - control with parent to be changed + * @param parent org.eclipse.swt.widgets.Widget - the new parent of control + */ +public static void setParent(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Composite parent) { + SWT.error(SWT.ERROR_NOT_IMPLEMENTED); +} + +/** + * Attempts to open the specified file. The effect varies based on + * the file type and underlying operating system. On win32, the effect + * is to invoke the ShellExecute API with the command "open". On motif + * the effect is to lookup the command to invoke using the underlying + * o/s's mime table support. + * + * @param file String + * a file to open. + * @return boolean + * true if successful, false otherwise. + */ +public static boolean shellExecute(String file) { + return shellExecute(file, null); +} + +/** + * Attempts to open the specified file. The effect varies based on + * the file type and underlying operating system. On win32, the effect + * is to invoke the ShellExecute API with the command "open". On motif + * the effect is to lookup the command to invoke using the underlying + * o/s's mime table support. + * + * Note: This method will be deprecated in the next release. + * + * @param file String + * a file to open. + * @param args String + * a String to be passed when the file is opened. + * @return boolean + * true if successful, false otherwise. + */ +public static boolean shellExecute(String file, String args) { +// if (Desktop == DESKTOP_UNKNOWN) return false; + + int startIndex = file.lastIndexOf('.'); + if (startIndex > -1) { + String extension = file.substring(startIndex + 1); + String command = queryExtension(extension); + int index = command.indexOf("%f"); + if (index > -1) { + command = command.substring(0, index) + file; + if (args != null) { + command += " "+args; + } + try { + Runtime.getRuntime().exec(command); + return true; + } catch (IOException e) { + return false; + } + } + } + + return false; +} + + + + + + + + + + + + + + + + +public static String getFriendlyName(String programId) { + SWT.error(SWT.ERROR_NOT_IMPLEMENTED); + return null; +} + +public static String queryExtensionProgramId(String extension) { + SWT.error(SWT.ERROR_NOT_IMPLEMENTED); + return null; +} + +public static String[] queryInsertables() { + SWT.error(SWT.ERROR_NOT_IMPLEMENTED); + return null; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java new file mode 100755 index 0000000000..259670d42c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java @@ -0,0 +1,259 @@ +package org.eclipse.swt.program; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +import java.io.IOException; + +/** + * Instances of this class represent programs and + * their assoicated file extensions in the operating + * system. + */ +public final class Program { + String name; + String command; + String iconName; + +/** + * 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 '.'. + * + * @param extension the program extension + * @return the program or nil + * + * @exception SWTError
false
+ *
+ * @exception SWTError true
if the file is launched, otherwise false
+ *
+ * @exception SWTError + * By defining constants like UP and DOWN in a single class, SWT + * can share common names and concepts at the same time minimizing + * the number of classes, names and constants for the application + * programmer. + *
+ * Note that, some of the constants provided by this class represent + * optional, appearance related aspects of widgets which are available + * either only on some window systems, or for a differing set of + * widgets on each window system. These constants are marked + * as HINTs. The set of widgets which support a particular + * HINT may change from release to release, although we typically + * will not withdraw support for a HINT once it is made available. + *
+ */ + +/* NOTE: + * Good javadoc coding style is to put the values of static final + * constants in the comments. This re-inforces the fact that + * consumers are allowed to rely on the value (and they must + * since the values are compiled inline in their code). We + * can not change the values of these constants between + * releases. + */ +public class SWT { + + /* Widget Event Constants */ + + /** + * key down event type (value is 1) + */ + public static final int KeyDown = 1; + + /** + * key up event type (value is 2) + */ + public static final int KeyUp = 2; + + /** + * mouse down event type (value is 3) + */ + public static final int MouseDown = 3; + + /** + * mouse up event type (value is 4) + */ + public static final int MouseUp = 4; + + /** + * mouse move event type (value is 5) + */ + public static final int MouseMove = 5; + + /** + * mouse enter event type (value is 6) + */ + public static final int MouseEnter = 6; + + /** + * Mouse exit event type (value is 7) + */ + public static final int MouseExit = 7; + + /** + * mouse double click event type (value is 8) + */ + public static final int MouseDoubleClick = 8; + + /** + * paint event type (value is 9) + */ + public static final int Paint = 9; + + /** + * pove event type (value is 10) + */ + public static final int Move = 10; + + /** + * resize event type (value is 11) + */ + public static final int Resize = 11; + + /** + * dispose event type (value is 12) + */ + public static final int Dispose = 12; + + /** + * selection event type (value is 13) + */ + public static final int Selection = 13; + + /** + * default selection event type (value is 14) + */ + public static final int DefaultSelection = 14; + + /** + * focus in event type (value is 15) + */ + public static final int FocusIn = 15; + + /** + * focus out event type (value is 16) + */ + public static final int FocusOut = 16; + + /** + * expand event type (value is 17) + */ + public static final int Expand = 17; + + /** + * collapse event type (value is 18) + */ + public static final int Collapse = 18; + + /** + * iconify event type (value is 19) + */ + public static final int Iconify = 19; + + /** + * de-iconify event type (value is 20) + */ + public static final int Deiconify = 20; + + /** + * close event type (value is 21) + */ + public static final int Close = 21; + + /** + * show event type (value is 22) + */ + public static final int Show = 22; + + /** + * hide event type (value is 23) + */ + public static final int Hide = 23; + + /** + * modify event type (value is 24) + */ + public static final int Modify = 24; + + /** + * verify event type (value is 25) + */ + public static final int Verify = 25; + + /** + * activate event type (value is 26) + */ + public static final int Activate = 26; + + /** + * deactivate event type (value is 27) + */ + public static final int Deactivate = 27; + + /** + * help event type (value is 28) + */ + public static final int Help = 28; + + /** + * drag detect event type (value is 29) + */ + public static final int DragDetect = 29; + + /** + * arm event type (value is 30) + */ + public static final int Arm = 30; + + /** + * traverse event type (value is 31) + */ + public static final int Traverse = 31; + + /** + * mouse hover event type (value is 32) + */ + public static final int MouseHover = 32; + + /* Event Details */ + + /** + * a constant known to be zero (0), used in operations which + * take bit flags to indicate that "no bits are set" + */ + public static final int NONE = 0; + + /** + * indicates that a user-interface component is being dragged, + * for example dragging the thumb of a scroll bar (value is 1) + */ + public static final int DRAG = 1; + + /** + * a constant known to be zero (0), used in operations which + * take pointers to indicate a null argument + */ + public static final int NULL = 0; + + /** + * indicates that a default should be used (value is -1) + */ + public static final int DEFAULT = -1; + + /** + *Menu
style constant for menu bar behavior (value is 1<<1)
+ */
+ public static final int BAR = 1 << 1;
+
+ /**
+ * Menu
style constant for drop down menu behavior (value is 1<<2)
+ */
+ public static final int DROP_DOWN = 1 << 2;
+
+ /**
+ * Menu
style constant for pop up menu behavior (value is 1<<3)
+ */
+ public static final int POP_UP = 1 << 3;
+
+ /**
+ * MenuItem
style constant for line separator behavior (value is 1<<1)
+ */
+ public static final int SEPARATOR = 1 << 1;
+
+ /* Button, MenuItem Constants */
+
+ /**
+ * Button
style constant for toggle button behavior (value is 1<<1)
+ */
+ public static final int TOGGLE = 1 << 1;
+
+ /**
+ * Button
style constant for arrow button behavior (value is 1<<2)
+ */
+ public static final int ARROW = 1 << 2;
+
+ /**
+ * Button
and MenuItem
+ * style constant for push button behavior (value is 1<<3)
+ */
+ public static final int PUSH = 1 << 3;
+
+ /**
+ * Button
and MenuItem
+ * style constant for radio button behavior (value is 1<<4)
+ */
+ public static final int RADIO = 1 << 4;
+
+ /**
+ * Button
and MenuItem
+ * style constant for check box behavior (value is 1<<5)
+ */
+ public static final int CHECK = 1 << 5;
+
+ /**
+ * MenuItem
style constant for cascade behavior (value is 1<<6)
+ */
+ public static final int CASCADE = 1 << 6;
+
+ /**
+ * Text
and List
+ * style constant for multi-selection behavior in lists
+ * and multiple line support on text fields (value is 1<<1)
+ */
+ public static final int MULTI = 1 << 1;
+
+ /**
+ * Text
and List
+ * style constant for single selection behavior in lists
+ * and single line support on text fields (value is 1<<2)
+ */
+ public static final int SINGLE = 1 << 2;
+
+ /**
+ * Text
style constant for read-only behavior (value is 1<<3)
+ */
+ public static final int READ_ONLY = 1 << 3;
+
+ /**
+ * Text
style constant for auto-line wrap behavior (value is 1<<6)
+ */
+ public static final int WRAP = 1 << 6;
+
+ /**
+ * Combo
style constant for simple (not drop down) behavior (value is 1<<6)
+ */
+ public static final int SIMPLE = 1 << 6;
+
+ /**
+ * Group
and Label
+ * style constant for shadow in behavior (value is 1<<2)
+ */
+ public static final int SHADOW_IN = 1 << 2;
+
+ /**
+ * Group
, Label
and CustomLabel
+ * style constant for shadow out behavior (value is 1<<3)
+ */
+ public static final int SHADOW_OUT = 1 << 3;
+
+ /**
+ * Group
style constant for shadow etched in behavior (value is 1<<4)
+ * NOTE: This style is ignored on all platforms except Motif
+ */
+ public static final int SHADOW_ETCHED_IN = 1 << 4;
+
+ /**
+ * Label
style constant for no shadow behavior (value is 1<<5)
+ */
+ public static final int SHADOW_NONE = 1 << 5;
+
+ /**
+ * Group
style constant for shadow etched out behavior (value is 1<<6)
+ * NOTE: This style is ignored on all platforms except Motif
+ */
+ public static final int SHADOW_ETCHED_OUT = 1 << 6;
+
+ /**
+ * Shell
style constant for tool window behavior (value is 1<<2)
+ */
+ public static final int TOOL = 1 << 2;
+
+ /**
+ * Shell
style constant to ensure no trimmings are used.
+ * This overrides all other trim styles (value is 1<<3)
+ */
+ public static final int NO_TRIM = 1 << 3;
+
+ /**
+ * Shell
style constant for resize box trim (value is 1<<4)
+ */
+ public static final int RESIZE = 1 << 4;
+
+ /**
+ * Shell
style constant for title area trim (value is 1<<5)
+ */
+ public static final int TITLE = 1 << 5;
+
+ /**
+ * Shell
style constant for close box trim (value is 1<<6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ */
+ public static final int CLOSE = 1 << 6;
+
+ /**
+ * Shell
style constant for shell menu trim (value is 1<<6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ */
+ public static final int MENU = CLOSE;
+
+ /**
+ * Shell
style constant for minimize box trim (value is 1<<7)
+ */
+ public static final int MIN = 1 << 7;
+
+ /* ScrollBar, Composite, Shell Constants */
+
+ /**
+ * ScrollBar
, Composite
and Shell
+ * style constant for horizontal scrollbar behavior (value is 1<<8)
+ */
+ public static final int H_SCROLL = 1 << 8;
+
+ /**
+ * ScrollBar
, Composite
and Shell
+ * style constant for vertical scrollbar behavior (value is 1<<9)
+ */
+ public static final int V_SCROLL = 1 << 9;
+
+ /**
+ * Shell
style constant for maximize box trim (value is 1<<10)
+ */
+ public static final int MAX = 1 << 10;
+
+ /**
+ * all Widget
style constant for bordered behavior (value is 1<<11)
+ */
+ public static final int BORDER = 1 << 11;
+
+ /**
+ * all Widget
style constant indicating that the window
+ * manager should clip a widget's children with respect to its viewable
+ * area. Note that this is a HINT. (value is 1<<12)
+ */
+ public static final int CLIP_CHILDREN = 1 << 12;
+
+ /**
+ * all Widget
style constant indicating that the window
+ * manager should clip a widget's siblings with respect to its viewable
+ * area. Note that this is a HINT. (value is 1<<13)
+ */
+ public static final int CLIP_SIBLINGS = 1 << 13;
+
+ /**
+ * Shell
style constant for always on top behavior (value is 1<<14)
+ */
+ public static final int ON_TOP = 1 << 14;
+
+ /**
+ * Shell
trim style convenience constant for the
+ * most common top level shell appearance
+ * (value is CLOSE|TITLE|MIN|MAX|RESIZE)
+ */
+ public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;
+
+ /**
+ * Shell
trim style convenience constant for the
+ * most common dialog shell appearance
+ * (value is CLOSE|TITLE|BORDER)
+ */
+ public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;
+
+ /**
+ * Shell
style constant for modeless behavior (value is 0)
+ */
+ public static final int MODELESS = 0;
+
+ /**
+ * Shell
style constant for primary modal behavior (value is 1<<15)
+ */
+ public static final int PRIMARY_MODAL = 1 << 15;
+
+ /**
+ * Shell
style constant for application modal behavior (value is 1<<16)
+ */
+ public static final int APPLICATION_MODAL = 1 << 16;
+
+ /**
+ * Shell
style constant for system modal behavior (value is 1<<17)
+ */
+ public static final int SYSTEM_MODAL = 1 << 17;
+
+ /**
+ * all Widget
style constant for selection hiding
+ * behavior. Note that this is a HINT. (value is 1<<15)
+ */
+ public static final int HIDE_SELECTION = 1 << 15;
+
+ /**
+ * all Widget
style constant for full row selection
+ * behavior. Note that this is a HINT. (value is 1<<16 since
+ * FULL_SELECTION and SMOOTH share the same value, but are
+ * implemented on non-intersecting sets of widgets)
+ */
+ public static final int FULL_SELECTION = 1 << 16;
+
+ /**
+ * all Widget
style constant for flat appearance.
+ * Note that this is a HINT. (value is 1<<23)
+ */
+ public static final int FLAT = 1 << 23;
+
+ /**
+ * all Widget
style constant for flat appearance.
+ * Note that this is a HINT. (value is 1<<16 since
+ * FULL_SELECTION and SMOOTH share the same value, but are
+ * implemented on non-intersecting sets of widgets)
+ */
+ public static final int SMOOTH = FULL_SELECTION;
+
+ /**
+ * Canvas
style constant for no background behavior (value is 1<<18)
+ */
+ public static final int NO_BACKGROUND = 1 << 18;
+
+ /**
+ * Canvas
style constant for does not take focus behavior (value is 1<<19)
+ */
+ public static final int NO_FOCUS = 1 << 19;
+
+ /**
+ * Canvas
style constant for no redraw on resize behavior (value is 1<<20)
+ */
+ public static final int NO_REDRAW_RESIZE = 1 << 20;
+
+ /**
+ * Canvas
style constant for no paint event merging
+ * behavior (value is 1<<21)
+ */
+ public static final int NO_MERGE_PAINTS = 1 << 21;
+
+ /**
+ * Canvas
style constant for preventing child radio group
+ * behavior (value is 1<<22)
+ */
+ public static final int NO_RADIO_GROUP = 1 << 22;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align up behavior (value is 1<<7, since
+ * align UP and align TOP are considered the same)
+ */
+ public static final int UP = 1 << 7;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align top behavior (value is 1<<7, since
+ * align UP and align TOP are considered the same)
+ */
+ public static final int TOP = UP;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align down behavior (value is 1<<10, since
+ * align DOWN and align BOTTOM are considered the same)
+ */
+ public static final int DOWN = 1 << 10;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align bottom behavior (value is 1<<10, since
+ * align DOWN and align BOTTOM are considered the same)
+ */
+ public static final int BOTTOM = DOWN;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align left behavior (value is 1<<14)
+ */
+ public static final int LEFT = 1 << 14;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align right behavior (value is 1<<17)
+ */
+ public static final int RIGHT = 1 << 17;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align center behavior (value is 1<<24)
+ */
+ public static final int CENTER = 1 << 24;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align horizontal behavior (value is 1<<8)
+ */
+ public static final int HORIZONTAL = H_SCROLL;
+
+ /**
+ * various Widget
and Layout
+ * style constant for align vertical behavior (value is 1<<9)
+ */
+ public static final int VERTICAL = V_SCROLL;
+
+ /**
+ * Input Method Editor style constant for double byte
+ * input behavior (value is 1<<1)
+ */
+ public static final int DBCS = 1 << 1;
+
+ /**
+ * Input Method Editor style constant for alpha
+ * input behavior (value is 1<<2)
+ */
+ public static final int ALPHA = 1 << 2;
+
+ /**
+ * Input Method Editor style constant for native
+ * input behavior (value is 1<<3)
+ */
+ public static final int NATIVE = 1 << 3;
+
+ /**
+ * Input Method Editor style constant for phonetic
+ * input behavior (value is 1<<4)
+ */
+ public static final int PHONETIC = 1 << 4;
+
+ /**
+ * Input Method Editor style constant for romanicized
+ * input behavior (value is 1<<5)
+ */
+ public static final int ROMAN = 1 << 5;
+
+ /**
+ * ASCII character convenience constant for the escape character
+ * (value is the char
with value 27)
+ */
+ public static final char ESC = 27;
+
+ /**
+ * ASCII character convenience constant for the delete character
+ * (value is the char
with value 127)
+ */
+ public static final char DEL = 0x7F;
+
+ /**
+ * ASCII character convenience constant for the backspace character
+ * (value is the char
'\b')
+ */
+ public static final char BS = '\b';
+
+ /**
+ * ASCII character convenience constant for the carriage return character
+ * (value is the char
'\r')
+ */
+ public static final char CR = '\r';
+
+ /**
+ * ASCII character convenience constant for the line feed character
+ * (value is the char
'\n')
+ */
+ public static final char LF = '\n';
+
+ /**
+ * keyboard and/or mouse event mask indicating that the ALT key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1<<16)
+ */
+ public static final int ALT = 1 << 16;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the SHIFT key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1<<17)
+ */
+ public static final int SHIFT = 1 << 17;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the CTRL key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1<<18)
+ */
+ public static final int CTRL = 1 << 18;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the CTRL key
+ * was pushed on the keyboard when the event was generated. This
+ * is a synonym for CTRL (value is 1<<18)
+ */
+ public static final int CONTROL = CTRL;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button one
+ * was pushed when the event was generated. (value is 1<<19)
+ */
+ public static final int BUTTON1 = 1 << 19;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button two
+ * was pushed when the event was generated. (value is 1<<20)
+ */
+ public static final int BUTTON2 = 1 << 20;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button three
+ * was pushed when the event was generated. (value is 1<<21)
+ */
+ public static final int BUTTON3 = 1 << 21;
+
+ /**
+ * keyboard event constant representing the UP ARROW key
+ * (value is (1<<24)+1)
+ */
+ public static final int ARROW_UP = (1 << 24) + 1;
+
+ /**
+ * keyboard event constant representing the DOWN ARROW key
+ * (value is (1<<24)+2)
+ */
+ public static final int ARROW_DOWN = (1 << 24) + 2;
+
+ /**
+ * keyboard event constant representing the LEFT ARROW key
+ * (value is (1<<24)+3)
+ */
+ public static final int ARROW_LEFT = (1 << 24) + 3;
+
+ /**
+ * keyboard event constant representing the RIGHT ARROW key
+ * (value is (1<<24)+4)
+ */
+ public static final int ARROW_RIGHT = (1 << 24) + 4;
+
+ /**
+ * keyboard event constant representing the PAGE UP key
+ * (value is (1<<24)+5)
+ */
+ public static final int PAGE_UP = (1 << 24) + 5;
+
+ /**
+ * keyboard event constant representing the PAGE DOWN key
+ * (value is (1<<24)+6)
+ */
+ public static final int PAGE_DOWN = (1 << 24) + 6;
+
+ /**
+ * keyboard event constant representing the HOME key
+ * (value is (1<<24)+7)
+ */
+ public static final int HOME = (1 << 24) + 7;
+
+ /**
+ * keyboard event constant representing the END key
+ * (value is (1<<24)+8)
+ */
+ public static final int END = (1 << 24) + 8;
+
+ /**
+ * keyboard event constant representing the INSERT key
+ * (value is (1<<24)+9)
+ */
+ public static final int INSERT = (1 << 24) + 9;
+
+ /**
+ * keyboard event constant representing the F1 key
+ * (value is (1<<24)+10)
+ */
+ public static final int F1 = (1 << 24) + 10;
+
+ /**
+ * keyboard event constant representing the F2 key
+ * (value is (1<<24)+11)
+ */
+ public static final int F2 = (1 << 24) + 11;
+
+ /**
+ * keyboard event constant representing the F3 key
+ * (value is (1<<24)+12)
+ */
+ public static final int F3 = (1 << 24) + 12;
+
+ /**
+ * keyboard event constant representing the F4 key
+ * (value is (1<<24)+13)
+ */
+ public static final int F4 = (1 << 24) + 13;
+
+ /**
+ * keyboard event constant representing the F5 key
+ * (value is (1<<24)+14)
+ */
+ public static final int F5 = (1 << 24) + 14;
+
+ /**
+ * keyboard event constant representing the F6 key
+ * (value is (1<<24)+15)
+ */
+ public static final int F6 = (1 << 24) + 15;
+
+ /**
+ * keyboard event constant representing the F7 key
+ * (value is (1<<24)+16)
+ */
+ public static final int F7 = (1 << 24) + 16;
+
+ /**
+ * keyboard event constant representing the F8 key
+ * (value is (1<<24)+17)
+ */
+ public static final int F8 = (1 << 24) + 17;
+
+ /**
+ * keyboard event constant representing the F9 key
+ * (value is (1<<24)+18)
+ */
+ public static final int F9 = (1 << 24) + 18;
+
+ /**
+ * keyboard event constant representing the F10 key
+ * (value is (1<<24)+19)
+ */
+ public static final int F10 = (1 << 24) + 19;
+
+ /**
+ * keyboard event constant representing the F11 key
+ * (value is (1<<24)+20)
+ */
+ public static final int F11 = (1 << 24) + 20;
+
+ /**
+ * keyboard event constant representing the F12 key
+ * (value is (1<<24)+21)
+ */
+ public static final int F12 = (1 << 24) + 21;
+
+ /**
+ * MessageBox
style constant for error icon
+ * behavior (value is 1)
+ */
+ public static final int ICON_ERROR = 1;
+
+ /**
+ * MessageBox
style constant for information icon
+ * behavior (value is 1<<1)
+ */
+ public static final int ICON_INFORMATION = 1 << 1;
+
+ /**
+ * MessageBox
style constant for question icon
+ * behavior (value is 1<<2)
+ */
+ public static final int ICON_QUESTION = 1 << 2;
+
+ /**
+ * MessageBox
style constant for warning icon
+ * behavior (value is 1<<3)
+ */
+ public static final int ICON_WARNING = 1 << 3;
+
+ /**
+ * MessageBox
style constant for "working" icon
+ * behavior (value is 1<<1)
+ */
+ public static final int ICON_WORKING = 1 << 4;
+
+ /**
+ * MessageBox
style constant for an OK button.
+ * Valid combinations are OK, OK|CANCEL
+ * (value is 1<<5)
+ */
+ public static final int OK = 1 << 5;
+
+ /**
+ * MessageBox
style constant for YES button.
+ * Valid combinations are YES|NO, YES|NO|CANCEL
+ * (value is 1<<6)
+ */
+ public static final int YES = 1 << 6;
+
+ /**
+ * MessageBox
style constant for NO button.
+ * Valid combinations are YES|NO, YES|NO|CANCEL
+ * (value is 1<<7)
+ */
+ public static final int NO = 1 << 7;
+
+ /**
+ * MessageBox
style constant for a CANCEL button.
+ * Valid combinations are OK|CANCEL, YES|NO|CANCEL, RETRY|CANCEL
+ * (value is 1<<8)
+ */
+ public static final int CANCEL = 1 << 8;
+
+ /**
+ * MessageBox
style constant for an ABORT button.
+ * The only valid combination is ABORT|RETRY|IGNORE
+ * (value is 1<<9)
+ */
+ public static final int ABORT = 1 << 9;
+
+ /**
+ * MessageBox
style constant for a RETRY button.
+ * Valid combinations are ABORT|RETRY|IGNORE, RETRY|CANCEL
+ * (value is 1<<10)
+ */
+ public static final int RETRY = 1 << 10;
+
+ /**
+ * MessageBox
style constant for an IGNORE button.
+ * The only valid combination is ABORT|RETRY|IGNORE
+ * (value is 1<<11)
+ */
+ public static final int IGNORE = 1 << 11;
+
+ /**
+ * FileDialog
style constant for open file dialog behavior
+ * (value is 1<<12)
+ */
+ public static final int OPEN = 1 << 12;
+
+ /**
+ * FileDialog
style constant for save file dialog behavior
+ * (value is 1<<13)
+ */
+ public static final int SAVE = 1 << 13;
+
+ /**
+ * default color white (value is 1)
+ */
+ public static final int COLOR_WHITE = 1;
+
+ /**
+ * default color black (value is 2)
+ */
+ public static final int COLOR_BLACK = 2;
+
+ /**
+ * default color red (value is 3)
+ */
+ public static final int COLOR_RED = 3;
+
+ /**
+ * default color dark red (value is 4)
+ */
+ public static final int COLOR_DARK_RED = 4;
+
+ /**
+ * default color green (value is 5)
+ */
+ public static final int COLOR_GREEN = 5;
+
+ /**
+ * default color dark green (value is 6)
+ */
+ public static final int COLOR_DARK_GREEN = 6;
+
+ /**
+ * default color yellow (value is 7)
+ */
+ public static final int COLOR_YELLOW = 7;
+
+ /**
+ * default color dark yello (value is 8)
+ */
+ public static final int COLOR_DARK_YELLOW = 8;
+
+ /**
+ * default color blue (value is 9)
+ */
+ public static final int COLOR_BLUE = 9;
+
+ /**
+ * default color dark blue (value is 10)
+ */
+ public static final int COLOR_DARK_BLUE = 10;
+
+ /**
+ * default color magenta (value is 11)
+ */
+ public static final int COLOR_MAGENTA = 11;
+
+ /**
+ * default color dark magenta (value is 12)
+ */
+ public static final int COLOR_DARK_MAGENTA = 12;
+
+ /**
+ * default color cyan (value is 13)
+ */
+ public static final int COLOR_CYAN = 13;
+
+ /**
+ * default color dark cyan (value is 14)
+ */
+ public static final int COLOR_DARK_CYAN = 14;
+
+ /**
+ * default color gray (value is 15)
+ */
+ public static final int COLOR_GRAY = 15;
+
+ /**
+ * default color dark gray (value is 16)
+ */
+ public static final 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 final int COLOR_WIDGET_DARK_SHADOW = 17;
+
+ /**
+ * system color used to paint normal shadow areas (value is 18)
+ */
+ public static final int COLOR_WIDGET_NORMAL_SHADOW = 18;
+
+ /**
+ * system color used to paint light shadow areas (value is 19)
+ */
+ public static final int COLOR_WIDGET_LIGHT_SHADOW = 19;
+
+ /**
+ * system color used to paint highlight shadow areas (value is 20)
+ */
+ public static final int COLOR_WIDGET_HIGHLIGHT_SHADOW = 20;
+
+ /**
+ * system color used to paint foreground areas (value is 21)
+ */
+ public static final int COLOR_WIDGET_FOREGROUND = 21;
+
+ /**
+ * system color used to paint background areas (value is 22)
+ */
+ public static final int COLOR_WIDGET_BACKGROUND = 22;
+
+ /**
+ * system color used to paint border areas (value is 23)
+ */
+ public static final int COLOR_WIDGET_BORDER = 23;
+
+ /**
+ * system color used to paint list foreground areas (value is 24)
+ */
+ public static final int COLOR_LIST_FOREGROUND = 24;
+
+ /**
+ * system color used to paint list background areas (value is 25)
+ */
+ public static final int COLOR_LIST_BACKGROUND = 25;
+
+ /**
+ * system color used to paint list selection background areas (value is 26)
+ */
+ public static final int COLOR_LIST_SELECTION = 26;
+
+ /**
+ * system color used to paint list selected text (value is 27)
+ */
+ public static final int COLOR_LIST_SELECTION_TEXT = 27;
+
+ /**
+ * system color used to paint tooltip text (value is 28)
+ */
+ public static final int COLOR_INFO_FOREGROUND = 28;
+
+ /**
+ * system color used to paint tooltip background areas (value is 29)
+ */
+ public static final int COLOR_INFO_BACKGROUND = 29;
+
+ /**
+ * system color used to paint title text (value is 30)
+ */
+ public static final int COLOR_TITLE_FOREGROUND = 30;
+
+ /**
+ * system color used to paint title background areas (value is 31)
+ */
+ public static final int COLOR_TITLE_BACKGROUND = 31;
+
+ /**
+ * system color used to paint title background gradient (value is 32)
+ */
+ public static final int COLOR_TITLE_BACKGROUND_GRADIENT = 32;
+
+ /**
+ * system color used to paint inactive title text (value is 33)
+ */
+ public static final int COLOR_TITLE_INACTIVE_FOREGROUND = 33;
+
+ /**
+ * system color used to paint inactive title background areas (value is 34)
+ */
+ public static final int COLOR_TITLE_INACTIVE_BACKGROUND = 34;
+
+ /**
+ * system color used to paint inactive title background gradient (value is 35)
+ */
+ public static final int COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = 35;
+
+ /**
+ * SWT error constant indicating that no error number was specified
+ * (value is 1)
+ */
+ public static final int ERROR_UNSPECIFIED = 1;
+
+ /**
+ * SWT error constant indicating that no more handles for an
+ * operating system resource are available
+ * (value is 2)
+ */
+ public static final int ERROR_NO_HANDLES = 2;
+
+ /**
+ * SWT error constant indicating that no more callback resources are available
+ * (value is 3)
+ */
+ public static final int ERROR_NO_MORE_CALLBACKS = 3;
+
+ /**
+ * SWT error constant indicating that a null argument was passed in
+ * (value is 4)
+ */
+ public static final int ERROR_NULL_ARGUMENT = 4;
+
+ /**
+ * SWT error constant indicating that an invalid argument was passed in
+ * (value is 5)
+ */
+ public static final int ERROR_INVALID_ARGUMENT = 5;
+
+ /**
+ * SWT error constant indicating that a value was found to be
+ * outside the allowable range
+ * (value is 6)
+ */
+ public static final int ERROR_INVALID_RANGE = 6;
+
+ /**
+ * SWT error constant indicating that a value which can not be
+ * zero was found to be
+ * (value is 7)
+ */
+ public static final int ERROR_CANNOT_BE_ZERO = 7;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide the value of an item
+ * (value is 8)
+ */
+ public static final int ERROR_CANNOT_GET_ITEM = 8;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide the selection
+ * (value is 9)
+ */
+ public static final int ERROR_CANNOT_GET_SELECTION = 9;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide the height of an item
+ * (value is 11)
+ */
+ public static final int ERROR_CANNOT_GET_ITEM_HEIGHT = 11;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide the text of a widget
+ * (value is 12)
+ */
+ public static final int ERROR_CANNOT_GET_TEXT = 12;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to set the text of a widget
+ * (value is 13)
+ */
+ public static final int ERROR_CANNOT_SET_TEXT = 13;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to add an item
+ * (value is 14)
+ */
+ public static final int ERROR_ITEM_NOT_ADDED = 14;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to remove an item
+ * (value is 15)
+ */
+ public static final int ERROR_ITEM_NOT_REMOVED = 15;
+
+ /**
+ * SWT error constant indicating that a particular feature has
+ * not been implemented on this platform
+ * (value is 20)
+ */
+ public static final int ERROR_NOT_IMPLEMENTED = 20;
+
+ /**
+ * SWT error constant indicating that a menu which needed
+ * to have the drop down style had some other style instead
+ * (value is 21)
+ */
+ public static final int ERROR_MENU_NOT_DROP_DOWN = 21;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation which can only be executed by the
+ * user-interface thread from some other thread
+ * (value is 22)
+ */
+ public static final int ERROR_THREAD_INVALID_ACCESS = 22;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation using a widget which had already
+ * been disposed.
+ * (value is 24)
+ */
+ public static final int ERROR_WIDGET_DISPOSED = 24;
+
+ /**
+ * SWT error constant indicating that a menu item which needed
+ * to have the cascade style had some other style instead
+ * (value is 27)
+ */
+ public static final int ERROR_MENUITEM_NOT_CASCADE = 27;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to set the selection of a widget
+ * (value is 28)
+ */
+ public static final int ERROR_CANNOT_SET_SELECTION = 28;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to set the menu
+ * (value is 29)
+ */
+ public static final int ERROR_CANNOT_SET_MENU = 29;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to set the enabled state
+ * (value is 30)
+ */
+ public static final int ERROR_CANNOT_SET_ENABLED = 30;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide enabled/disabled state information
+ * (value is 31)
+ */
+ public static final int ERROR_CANNOT_GET_ENABLED = 31;
+
+ /**
+ * SWT error constant indicating that a provided widget can
+ * not be used as a parent in the current operation
+ * (value is 32)
+ */
+ public static final int ERROR_INVALID_PARENT = 32;
+
+ /**
+ * SWT error constant indicating that a menu which needed
+ * to have the menu bar style had some other style instead
+ * (value is 33)
+ */
+ public static final int ERROR_MENU_NOT_BAR = 33;
+
+ /**
+ * SWT error constant indicating that the underlying operating
+ * system was unable to provide count information
+ * (value is 36)
+ */
+ public static final int ERROR_CANNOT_GET_COUNT = 36;
+
+ /**
+ * SWT 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 final int ERROR_MENU_NOT_POP_UP = 37;
+
+ /**
+ * SWT error constant indicating that a graphics operation
+ * was attempted with an image of an unsupported depth
+ * (value is 38)
+ */
+ public static final int ERROR_UNSUPPORTED_DEPTH = 38;
+
+ /**
+ * SWT error constant indicating that an input/output operation
+ * failed during the execution of an SWT operation
+ * (value is 39)
+ */
+ public static final int ERROR_IO = 39;
+
+ /**
+ * SWT error constant indicating that a graphics operation
+ * was attempted with an image having an invalid format
+ * (value is 40)
+ */
+ public static final int ERROR_INVALID_IMAGE = 40;
+
+ /**
+ * SWT error constant indicating that a graphics operation
+ * was attempted with an image having a valid but unsupported
+ * format
+ * (value is 42)
+ */
+ public static final int ERROR_UNSUPPORTED_FORMAT = 42;
+
+ /**
+ * SWT error constant indicating that an attempt was made
+ * to subclass an SWT widget class without implementing the
+ * checkSubclass()
method. For additional
+ * information see the comment in Widget.checkSubclass()
+ * (value is 43)
+ *
+ * @see Widget#checkSubclass
+ */
+ public static final int ERROR_INVALID_SUBCLASS = 43;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation using a graphics object which had
+ * already been disposed.
+ * (value is 44)
+ */
+ public static final int ERROR_GRAPHIC_DISPOSED = 44;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation using a device which had already
+ * been disposed.
+ * (value is 45)
+ */
+ public static final int ERROR_DEVICE_DISPOSED = 45;
+
+ /**
+ * traversal event detail field value indicating that the ESC
+ * key was pressed (value is 1<<1)
+ */
+ public static final int TRAVERSE_ESCAPE = 1 << 1;
+
+ /**
+ * traversal event detail field value indicating that the ENTER
+ * key was pressed (value is 1<<2)
+ */
+ public static final int TRAVERSE_RETURN = 1 << 2;
+
+ /**
+ * traversal event detail field value indicating that the SHIFT-TAB
+ * key was pressed (value is 1<<3)
+ */
+ public static final int TRAVERSE_TAB_PREVIOUS = 1 << 3;
+
+ /**
+ * traversal event detail field value indicating that the TAB
+ * key was pressed (value is 1<<4)
+ */
+ public static final int TRAVERSE_TAB_NEXT = 1 << 4;
+
+ /**
+ * traversal event detail field value indicating that the LEFT-ARROW
+ * or UP-ARROW keys was pressed (value is 1<<5)
+ */
+ public static final int TRAVERSE_ARROW_PREVIOUS = 1 << 5;
+
+ /**
+ * traversal event detail field value indicating that the RIGHT-ARROW
+ * or DOWN-ARROW keys was pressed (value is 1<<6)
+ */
+ public static final int TRAVERSE_ARROW_NEXT = 1 << 6;
+
+ /**
+ * constant indicating that an image or operation is of type bitmap (value is 0)
+ */
+ public static final int BITMAP = 0;
+
+ /**
+ * constant indicating that an image or operation is of type icon (value is 1)
+ */
+ public static final int ICON = 1;
+
+ /**
+ * Image
constructor argument indicating that
+ * the new image should be a copy of the image provided as
+ * an argument (value is 0)
+ */
+ public static final int IMAGE_COPY = 0;
+
+ /**
+ * Image
constructor argument indicating that
+ * the new image should have the appearance of a "disabled"
+ * (using the platform's rules for how this should look)
+ * copy of the image provided as an argument (value is 1)
+ */
+ public static final int IMAGE_DISABLE = 1;
+
+ /**
+ * Image
constructor argument indicating that
+ * the new image should have the appearance of a "gray scaled"
+ * copy of the image provided as an argument (value is 2)
+ */
+ public static final int IMAGE_GRAY = 2;
+
+ /**
+ * font style constant indicating a normal weight, non-italic font
+ * (value is 0)
+ */
+ public static final int NORMAL = 0;
+
+ /**
+ * font style constant indicating a bold weight font
+ * (value is 1<<0)
+ */
+ public static final int BOLD = 1 << 0;
+
+ /**
+ * font style constant indicating an italic font
+ * (value is 1<<1)
+ */
+ public static final int ITALIC = 1 << 1;
+
+ /**
+ * system arrow cursor (value is 0)
+ */
+ public static final int CURSOR_ARROW = 0;
+
+ /**
+ * system wait cursor (value is 1)
+ */
+ public static final int CURSOR_WAIT = 1;
+
+ /**
+ * system cross hair cursor (value is 2)
+ */
+ public static final int CURSOR_CROSS = 2;
+
+ /**
+ * system app startup cursor (value is 3)
+ */
+ public static final int CURSOR_APPSTARTING = 3;
+
+ /**
+ * system help cursor (value is 4)
+ */
+ public static final int CURSOR_HELP = 4;
+
+ /**
+ * system resize all directions cursor (value is 5)
+ */
+ public static final int CURSOR_SIZEALL = 5;
+
+ /**
+ * system resize north-east-south-west cursor (value is 6)
+ */
+ public static final int CURSOR_SIZENESW = 6;
+
+ /**
+ * system resize north-south cursor (value is 7)
+ */
+ public static final int CURSOR_SIZENS = 7;
+
+ /**
+ * system resize north-west-south-east cursor (value is 8)
+ */
+ public static final int CURSOR_SIZENWSE = 8;
+
+ /**
+ * system resize west-east cursor (value is 9)
+ */
+ public static final int CURSOR_SIZEWE = 9;
+
+ /**
+ * system resize north cursor (value is 10)
+ */
+ public static final int CURSOR_SIZEN = 10;
+
+ /**
+ * system resize south cursor (value is 11)
+ */
+ public static final int CURSOR_SIZES = 11;
+
+ /**
+ * system resize east cursor (value is 12)
+ */
+ public static final int CURSOR_SIZEE = 12;
+
+ /**
+ * system resize west cursor (value is 13)
+ */
+ public static final int CURSOR_SIZEW = 13;
+
+ /**
+ * system resize north-east cursor (value is 14)
+ */
+ public static final int CURSOR_SIZENE = 14;
+
+ /**
+ * system resize south-east cursor (value is 15)
+ */
+ public static final int CURSOR_SIZESE = 15;
+
+ /**
+ * system resize south-west cursor (value is 16)
+ */
+ public static final int CURSOR_SIZESW = 16;
+
+ /**
+ * system resize north-west cursor (value is 17)
+ */
+ public static final int CURSOR_SIZENW = 17;
+
+ /**
+ * system up arrow cursor (value is 18)
+ */
+ public static final int CURSOR_UPARROW = 18;
+
+ /**
+ * system i-beam cursor (value is 19)
+ */
+ public static final int CURSOR_IBEAM = 19;
+
+ /**
+ * system "not allowed" cursor (value is 20)
+ */
+ public static final int CURSOR_NO = 20;
+
+ /**
+ * system hand cursor (value is 21)
+ */
+ public static final int CURSOR_HAND = 21;
+
+ /**
+ * line drawing style for solid lines (value is 1)
+ */
+ public static final int LINE_SOLID = 1;
+
+ /**
+ * line drawing style for dashed lines (value is 2)
+ */
+ public static final int LINE_DASH = 2;
+
+ /**
+ * line drawing style for dotted lines (value is 3)
+ */
+ public static final int LINE_DOT = 3;
+
+ /**
+ * line drawing style for alternating dash-dot lines (value is 4)
+ */
+ public static final int LINE_DASHDOT = 4;
+
+ /**
+ * line drawing style for dash-dot-dot lines (value is 5)
+ */
+ public static final int LINE_DASHDOTDOT = 5;
+
+ /**
+ * image format constant indicating an unknown image type (value is -1)
+ */
+ public static final int IMAGE_UNDEFINED = -1;
+
+ /**
+ * image format constant indicating a Windows BMP format image (value is 0)
+ */
+ public static final int IMAGE_BMP = 0;
+
+ /**
+ * image format constant indicating a run-length encoded
+ * Windows BMP format image (value is 1)
+ */
+ public static final int IMAGE_BMP_RLE = 1;
+
+ /**
+ * image format constant indicating a GIF format image (value is 2)
+ */
+ public static final int IMAGE_GIF = 2;
+
+ /**
+ * image format constant indicating a ICO format image (value is 3)
+ */
+ public static final int IMAGE_ICO = 3;
+
+ /**
+ * image format constant indicating a JPEG format image (value is 4)
+ */
+ public static final int IMAGE_JPEG = 4;
+
+ /**
+ * image format constant indicating a PNG format image (value is 5)
+ */
+ public static final int IMAGE_PNG = 5;
+
+ /**
+ * GIF image disposal method constants indicating that the
+ * disposal method is unspecified (value is 0)
+ */
+ public static final 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 final 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 final 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 final int DM_FILL_PREVIOUS = 0x3;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 0)
+ */
+ public static final int TRANSPARENCY_NONE = 0x0;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 1<<0)
+ */
+ public static final int TRANSPARENCY_ALPHA = 1 << 0;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 1<<1)
+ */
+ public static final int TRANSPARENCY_MASK = 1 << 1;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 1<<2)
+ */
+ public static final int TRANSPARENCY_PIXEL = 1 << 2;
+
+/**
+ * Answers a concise, human readable description of the error code.
+ *
+ * @param code the SWT error code.
+ * @return a description of the error code.
+ *
+ * @see SWT
+ */
+static String findErrorText (int code) {
+ switch (code) {
+ case ERROR_UNSPECIFIED: return "Unspecified error";
+ case ERROR_NO_HANDLES: return "No more handles";
+ case ERROR_NO_MORE_CALLBACKS: return "No more callbacks";
+ case ERROR_NULL_ARGUMENT: return "Argument cannot be null";
+ case ERROR_INVALID_ARGUMENT: return "Argument not valid";
+ case ERROR_INVALID_RANGE: return "Index out of bounds";
+ case ERROR_CANNOT_BE_ZERO: return "Argument cannot be zero";
+ case ERROR_CANNOT_GET_ITEM: return "Cannot get item";
+ case ERROR_CANNOT_GET_SELECTION: return "Cannot get selection";
+ case ERROR_CANNOT_GET_ITEM_HEIGHT: return "Cannot get item height";
+ case ERROR_CANNOT_GET_TEXT: return "Cannot get text";
+ case ERROR_CANNOT_SET_TEXT: return "Cannot set text";
+ case ERROR_ITEM_NOT_ADDED: return "Item not added";
+ case ERROR_ITEM_NOT_REMOVED: return "Item not removed";
+ case ERROR_NOT_IMPLEMENTED: return "Not implemented";
+ case ERROR_MENU_NOT_DROP_DOWN: return "Menu must be a drop down";
+ case ERROR_THREAD_INVALID_ACCESS: return "Invalid thread access";
+ case ERROR_WIDGET_DISPOSED: return "Widget is disposed";
+ case ERROR_MENUITEM_NOT_CASCADE: return "Menu item is not a CASCADE";
+ case ERROR_CANNOT_SET_SELECTION: return "Cannot set selection";
+ case ERROR_CANNOT_SET_MENU: return "Cannot set menu";
+ case ERROR_CANNOT_SET_ENABLED: return "Cannot set the enabled state";
+ case ERROR_CANNOT_GET_ENABLED: return "Cannot get the enabled state";
+ case ERROR_INVALID_PARENT: return "Widget has the wrong parent";
+ case ERROR_MENU_NOT_BAR: return "Menu is not a BAR";
+ case ERROR_CANNOT_GET_COUNT: return "Cannot get count";
+ case ERROR_MENU_NOT_POP_UP: return "Menu is not a POP_UP";
+ case ERROR_UNSUPPORTED_DEPTH: return "Unsupported color depth";
+ case ERROR_IO: return "i/o error";
+ case ERROR_INVALID_IMAGE: return "Invalid image";
+ case ERROR_UNSUPPORTED_FORMAT: return "Unsupported or unrecognized format";
+ case ERROR_INVALID_SUBCLASS: return "Subclassing not allowed";
+ case ERROR_GRAPHIC_DISPOSED: return "Graphic is disposed";
+ case ERROR_DEVICE_DISPOSED: return "Device is disposed";
+ }
+ return "Unknown error";
+}
+
+/**
+ * Answers the SWT platform name.
+ * Examples: "win32", "motif", "gtk", "photon"
+ *
+ * @return the SWT version number
+ */
+public static String getPlatform () {
+ return Callback.getPlatform ();
+}
+
+/**
+ * Answers the SWT version number as an integer.
+ * Example: "SWT051" == 51
+ *
+ * @return the SWT version number
+ */
+public static int getVersion () {
+ return Callback.getVersion ();
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the SWT error code
+ */
+public static void error (int code) {
+ error (code, null);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The throwable
argument should be either null, or the
+ * throwable which caused SWT to throw an exception.
+ * + * In SWT, errors are reported by throwing one of three exceptions: + *
throwable
field which holds the underlying
+ * throwable that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * + * SWTErrors are thrown when something fails internally which + * either leaves SWT in an unknown state (eg. the o/s call to + * remove an item from a list returns an error code) or when SWT + * is left in a known-to-be-unrecoverable state (eg. it runs out + * of callback resources). SWTErrors should not occur in typical + * programs, although "high reliability" applications should + * still catch them. + *
+ * This class also provides support methods used by SWT to match + * error codes to the appropriate exception class (SWTError, + * SWTException, or IllegalArgumentException) and to provide + * human readable strings for SWT error codes. + *
+ * + * @see SWTException + * @see SWT#error + */ + +public class SWTError extends Error { + public int code; + public Throwable throwable; + +/** + * Constructs a new instance of this class with its + * walkback filled in. The error code is set to an + * unspecified value. + */ +public SWTError () { + this (SWT.ERROR_UNSPECIFIED); +} + +/** + * Constructs a new instance of this class with its + * walkback and message filled in. The error code is + * set to an unspecified value. + * + * @param message the detail message for the exception + */ +public SWTError (String message) { + this (SWT.ERROR_UNSPECIFIED, message); +} + +/** + * Constructs a new instance of this class with its + * walkback and error code filled in. + * + * @param code the SWT error code + */ +public SWTError (int code) { + this (code, SWT.findErrorText (code)); +} + +/** + * Constructs a new instance of this class with its + * walkback, error code and message filled in. + * + * @param code the SWT error code + * @param message the detail message for the exception + */ +public SWTError (int code, String message) { + super (message); + this.code = code; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java new file mode 100755 index 0000000000..7f04b7c9fd --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java @@ -0,0 +1,73 @@ +package org.eclipse.swt; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +/** + * This runtime exception is thrown whenever a recoverable error + * occurs internally in SWT. The message text and error code + * provide a further description of the problem. The exception + * has athrowable
field which holds the underlying
+ * exception that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * + * SWTExceptions are thrown when something fails internally, + * but SWT is left in a known stable state (eg. a widget call + * was made from a non-u/i thread, or there is failure while + * reading an Image because the source file was corrupt). + *
+ * + * @see SWTError + */ + +public class SWTException extends RuntimeException { + public int code; + public Throwable throwable; + +/** + * Constructs a new instance of this class with its + * walkback filled in. The error code is set to an + * unspecified value. + */ +public SWTException () { + this (SWT.ERROR_UNSPECIFIED); +} + +/** + * Constructs a new instance of this class with its + * walkback and message filled in. The error code is + * set to an unspecified value. + * + * @param message the detail message for the exception + */ +public SWTException (String message) { + this (SWT.ERROR_UNSPECIFIED, message); +} + +/** + * Constructs a new instance of this class with its + * walkback and error code filled in. + * + * @param code the SWT error code + */ +public SWTException (int code) { + this (code, SWT.findErrorText (code)); +} + +/** + * Constructs a new instance of this class with its + * walkback, error code and message filled in. + * + * @param code the SWT error code + * @param message the detail message for the exception + */ +public SWTException (int code, String message) { + super (message); + this.code = code; +} + +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java new file mode 100755 index 0000000000..339b4de0c2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java @@ -0,0 +1,29 @@ +package org.eclipse.swt.events; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.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 extends TypedEvent { + +/** + * 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); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java new file mode 100755 index 0000000000..44dda803cc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java @@ -0,0 +1,32 @@ +package org.eclipse.swt.events; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import java.util.EventListener; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated when a widget, + * such as a menu item, is armed. + *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * addArmListener
method and removed using
+ * the removeArmListener
method. When the
+ * widget is armed, the widgetArmed method will be invoked.
+ *
ControlListener
interface.
+ *
+ * Classes that wish to deal with ControlEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
Shell
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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java
new file mode 100755
index 0000000000..22af9a8e0f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * controls being moved or resized.
+ *
+ * @see ControlListener
+ */
+
+public final class ControlEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java
new file mode 100755
index 0000000000..63ca027961
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by moving
+ * and resizing controls.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addControlListener
method and removed using
+ * the removeControlListener
method. When a
+ * control is moved or resized, the appropriate method will
+ * be invoked.
+ *
Shell
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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java
new file mode 100755
index 0000000000..2bcac89d4e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being disposed.
+ *
+ * @see DisposeListener
+ */
+
+public final class DisposeEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java
new file mode 100755
index 0000000000..586a3f467f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java
@@ -0,0 +1,33 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget
+ * is disposed.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * addDisposeListener
method and removed using
+ * the removeDisposeListener
method. When a
+ * widget is disposed, the widgetDisposed method will
+ * be invoked.
+ *
FocusListener
interface.
+ *
+ * Classes that wish to deal with FocusEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addFocusListener
method and removed using
+ * the removeFocusListener
method. When a
+ * control gains or loses focus, the appropriate method
+ * will be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addHelpListener
method and removed using
+ * the removeHelpListener
method. When help
+ * is requested for a control, the helpRequested method
+ * will be invoked.
+ *
KeyListener
interface.
+ *
+ * Classes that wish to deal with KeyEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addKeyListener
method and removed using
+ * the removeKeyListener
method. When a
+ * key is pressed or released, the appropriate method will
+ * be invoked.
+ *
MenuListener
interface.
+ *
+ * Classes that wish to deal with MenuEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addMenuListener
method and removed using
+ * the removeMenuListener
method. When a
+ * menu is hidden or shown, the appropriate method will
+ * be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text widget using the
+ * addModifyListener
method and removed using
+ * the removeModifyListener
method. When the
+ * text is modified, the modifyText method will be invoked.
+ *
MouseListener
interface.
+ *
+ * Classes that wish to deal with MouseEvent
s
+ * which occur as mouse buttons are pressed and released can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * Note: The button
field is an integer that
+ * represents the mouse button number. This is not the same
+ * as the SWT
mask constants BUTTONx
.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addMouseListener
method and removed using
+ * the removeMouseListener
method. When a
+ * mouse button is pressed or released, the appropriate method
+ * will be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addMouseMoveListener
method and removed using
+ * the removeMouseMoveListener
method. As the
+ * mouse moves, the mouseMove method will be invoked.
+ *
MouseTrackListener
interface.
+ *
+ * Classes that wish to deal with MouseEvent
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.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addMouseTrackListener
method and removed using
+ * the removeMouseTrackListener
method. When the
+ * mouse pointer passes into or out of the area of the screen
+ * covered by a control or pauses while over a control, the
+ * appropriate method will be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addPaintListener
method and removed using
+ * the removePaintListener
method. When a
+ * paint event occurs, the paintControl method will be
+ * invoked.
+ *
SelectionListener
interface.
+ *
+ * Classes that wish to deal with SelectionEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * Note: The fields that are filled in depend on the widget. + *
+ * + * @see SelectionListener + */ + +public class SelectionEvent extends TypedEvent { + + /** + * the item that was selected + */ + public Widget item; + + /** + * extra detail information about the selection + */ + 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; + + /** + * a flag indicating whether the operation should be allowed + */ + public boolean doit; + +/** + * 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.doit = e.doit; +} + +} + diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java new file mode 100755 index 0000000000..a65a2fc88b --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java @@ -0,0 +1,50 @@ +package org.eclipse.swt.events; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import java.util.EventListener; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when selection + * occurs in a control. + *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addSelectionListener
method and removed using
+ * the removeSelectionListener
method. When
+ * selection occurs in a control the appropriate method
+ * will be invoked.
+ *
+ * For example, on some platforms selection occurs in + * a List when the user selects an item or items. + *
+ * + * @param e an event containing information about the selection + */ +public void widgetSelected(SelectionEvent e); + +/** + * Sent when default selection occurs in the control. + *+ * For example, on some platforms default selection occurs + * in a List when the user double-clicks an item or types + * return in a Text. + *
+ * + * @param e an event containing information about the default selection + */ +public void widgetDefaultSelected(SelectionEvent e); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java new file mode 100755 index 0000000000..567187ff2d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java @@ -0,0 +1,66 @@ +package org.eclipse.swt.events; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +/** + * This adapter class provides default implementations for the + * methods described by theShellListener
interface.
+ *
+ * Classes that wish to deal with ShellEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
Shell
s.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addShellListener
method and removed using
+ * the removeShellListener
method. When the
+ * state of a shell changes, the appropriate method will
+ * be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addTraverseListener
method and removed using
+ * the removeTraverseListener
method. When a
+ * traverse event occurs in a control, the keyTraversed method
+ * will be invoked.
+ *
+ * A traverse event occurs when the user presses a traversal
+ * key. Traversal keys are typically tab and arrow keys, along
+ * with certain other keys on some platforms. Traversal key
+ * constants beginning with TRAVERSE_
are defined
+ * in the SWT
class.
+ *
TreeListener
interface.
+ *
+ * Classes that wish to deal with TreeEvent
s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addTreeListener
method and removed using
+ * the removeTreeListener
method. When a branch
+ * of a tree is expanded or collapsed, the appropriate method
+ * will be invoked.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text widget using the
+ * addVerifyListener
method and removed using
+ * the removeVerifyListener
method. When the
+ * text is about to be modified, the verifyText method
+ * will be invoked.
+ *
+ * A verify event occurs after the user has done something + * to modify the text (typically typed a key), but before + * the text is modified. The doit field in the verify event + * indicates whether or not to modify the text. + *
+ * + * @param e an event containing information about the verify + */ +public void verifyText(VerifyEvent e); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html new file mode 100755 index 0000000000..6cb72031fc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html @@ -0,0 +1,22 @@ + + + + +
+For contrast, see also the untyped listener support provided
+by class org.eclipse.swt.widgets.Event
and interface
+org.eclipse.swt.widgets.Listener
, and the
+addListener
and removeListener
methods in
+class org.eclipse.swt.widgets.Widget
.
+
+ * IMPORTANT: This method is not part of the public
+ * API for Drawable
. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ * IMPORTANT: This method is not part of the public
+ * API for Drawable
. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
Image
.
+ *
+ * Note that the public fields x
, y
,
+ * disposalMethod
and delayTime
are
+ * typically only used when the image is in a set of images used
+ * for animation.
+ *
+ * @see Image
+ * @see ImageLoader
+ */
+
+public final class ImageData implements Cloneable {
+
+ /**
+ * 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
+ */
+ public int depth;
+
+ /**
+ * the scanline padding. If one scanline of the image
+ * is not a multiple of this number, it will be padded
+ * with zeros until it is
+ */
+ public int scanlinePad;
+
+ /**
+ * the number of bytes per scanline. This is a multiple
+ * of the scanline padding
+ */
+ public int bytesPerLine;
+
+ /**
+ * the pixel data of the image
+ */
+ public byte[] data;
+
+ /**
+ * the color table for the image
+ */
+ public PaletteData palette;
+
+ /**
+ * the transparent pixel. Pixels with this value are transparent.
+ * The default is -1 which means 'no transparency'
+ */
+ public int transparentPixel;
+
+ /**
+ * icon-specific field containing the data from the icon mask
+ */
+ public byte[] maskData;
+
+ /**
+ * icon-specific field containing the scanline pad of the mask
+ */
+ public int maskPad;
+
+ /**
+ * the alpha data of the image. Every pixel can have an
+ * alpha blending value that varies from 0, meaning
+ * fully transparent, to 255 meaning fully opaque
+ */
+ public byte[] alphaData;
+
+ /**
+ * the global alpha value to be used for every pixel.
+ * If this value is set the alphaData
field
+ * is ignored. The default is -1 which means 'no global alpha
+ * value'
+ */
+ public int alpha;
+
+ /**
+ * the type of file that the image was read in from,
+ * expressed as one of the following values:
+ *
IMAGE_BMP
IMAGE_BMP_RLE
IMAGE_GIF
IMAGE_ICO
IMAGE_JPEG
IMAGE_PNG
DM_UNSPECIFIED
DM_FILL_NONE
DM_FILL_BACKGROUND
DM_FILL_PREVIOUS
ImageData
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.
+ *
+ * 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
+ * ImageLoader.load()
.
+ *
ImageData
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.
+ *
+ * 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
+ * ImageLoader.load()
.
+ *
+ * This method is for internal use, and is not described further. + *
+ */ +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 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (!(depth == 1 || depth == 2 || depth == 4 || depth == 8 + || depth == 16 || depth == 24 || depth == 32)) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + if (width <= 0 || height <= 0) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1)) + / scanlinePad * scanlinePad; + setAllFields( + width, + height, + depth, + scanlinePad, + bytesPerLine, + data != 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. + *+ * This method is for internal use, and is not described further. + *
+ */ +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 SWT functionality to create a new instance of + * this class. + *
+ * IMPORTANT: This method is not part of the public
+ * API for ImageData
. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is subject
+ * to change without notice, and should never be called from
+ * application code.
+ *
+ * This method is for internal use, and is not described further. + *
+ * + * @private + */ +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(), + Image.DEFAULT_SCANLINE_PAD, null, 0, null, + null, -1, -1, SWT.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 != -1 && row[i] == pixel) { + row[i] = 0; + } else { + row[i] = 1; + } + } + mask.setPixels(0, y, width, row, 0); + } + return mask; +} + +static byte[] checkData(byte [] data) { + if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return data; +} + +/** + * Returns a new instance of the same class as the receiver, + * whose slots have been filled in with copies of + * the values in the slots of the receiver. That is, the + * returned object is a deep copy 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 != null) { + cloneMaskData = new byte[maskData.length]; + System.arraycopy(maskData, 0, cloneMaskData, 0, maskData.length); + } + byte[] cloneAlphaData = null; + if (alphaData != 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 offsetx
in
+ * scanline y
in the receiver's alpha data.
+ *
+ * @param x the x coodinate 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 getWidth
alpha values starting at offset
+ * x
in scanline y
in the receiver's alpha
+ * data starting at startIndex
.
+ *
+ * @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 IllegalArgumentException x
or y
is out of boundsx
in
+ * scanline y
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 getWidth
pixel values starting at offset
+ * x
in scanline y
in the receiver's
+ * data starting at startIndex
.
+ *
+ * @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 IllegalArgumentException getWidth
pixel values starting at offset
+ * x
in scanline y
in the receiver's
+ * data starting at startIndex
.
+ *
+ * @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 IllegalArgumentException RGB
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 ImageData
which specifies the
+ * transparency mask information for the receiver, or null if the
+ * receiver has no transparency and is not an icon.
+ *
+ * @return the transparency mask or null if none exists
+ */
+public ImageData getTransparencyMask() {
+ if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ return new ImageData(width, height, 1, bwPalette(), maskPad, maskData);
+ } else {
+ return colorMaskImage(transparentPixel);
+ }
+}
+
+/**
+ * Returns the image transparency type.
+ *
+ * @return the receiver's transparency type
+ */
+public int getTransparencyType() {
+ if (maskData != null) return SWT.TRANSPARENCY_MASK;
+ if (transparentPixel != -1) return SWT.TRANSPARENCY_PIXEL;
+ if (alphaData != null) return SWT.TRANSPARENCY_ALPHA;
+ return SWT.TRANSPARENCY_NONE;
+}
+
+/**
+ * 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,
+ * and then scale all of the data. */
+ ImageData destImage = new ImageData(
+ width, height, depth, palette,
+ scanlinePad, null, 0, null,
+ null, -1, transparentPixel, type,
+ x, y, disposalMethod, delayTime);
+ scaleImage(destImage, 0, 0, this.width, this.height, 0, 0, width, height);
+ return destImage;
+}
+
+void scaleImage(ImageData destImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ boolean flipX, flipY;
+ /* Flip rects if necessary so that src width and height are positive. */
+ if (srcWidth < 0) {
+ srcWidth = -srcWidth;
+ srcX = srcX - srcWidth;
+ destWidth = -destWidth;
+ destX = destX - destWidth;
+ }
+ if (srcHeight < 0) {
+ srcHeight = -srcHeight;
+ srcY = srcY - srcHeight;
+ destHeight = -destHeight;
+ destY = destY - destHeight;
+ }
+ /* Ensure dest width and height are positive, remembering whether to flip. */
+ flipX = destWidth < 0;
+ if (flipX) {
+ destWidth = -destWidth;
+ destX = destX - destWidth;
+ }
+ flipY = destHeight < 0;
+ if (flipY) {
+ destHeight = -destHeight;
+ destY = destY - destHeight;
+ }
+ /* Check source rect bounds. Succeed with 0 if out of bounds, rather
+ * than failing.
+ */
+ if (srcX < 0 || srcY < 0 || (srcX + srcWidth > width) ||
+ (srcY + srcHeight > height)) {
+ return;
+ }
+ if (destX < 0 || destY < 0 || (destX + destWidth > destImage.width) ||
+ (destY + destHeight > destImage.height)) {
+ return;
+ }
+ /* If dest rect is 0, there is nothing to do. */
+ if (destWidth == 0 || destHeight == 0) {
+ return;
+ }
+ switch (depth) {
+ case 1:
+ stretch1(data, bytesPerLine, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 2:
+ stretch2(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 4:
+ stretch4(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 8:
+ stretch8(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 16:
+ stretch16(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 24:
+ stretch24(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 32:
+ stretch32(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ destImage.maskPad = maskPad;
+ int destBpl = (destWidth + 7) / 8;
+ destBpl = (destBpl + (maskPad - 1)) / maskPad * maskPad;
+ destImage.maskData = new byte[destBpl * destHeight];
+ int srcBpl = (srcWidth + 7) / 8;
+ srcBpl = (srcBpl + (maskPad - 1)) / maskPad * maskPad;
+ stretch1(maskData, srcBpl, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.maskData, destBpl, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);
+ } else if (alpha != -1) {
+ destImage.alpha = alpha;
+ } else if (alphaData != null) {
+ destImage.alphaData = new byte[destImage.width * destImage.height];
+ stretch8(alphaData, width, srcX, srcY, srcWidth, srcHeight, destImage.alphaData, destImage.width, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ }
+}
+
+/**
+ * Sets the alpha value at offset x
in
+ * scanline y
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 x
in
+ * scanline y
in the receiver's alpha data to the
+ * values from the array alphas
starting at
+ * startIndex
.
+ *
+ * @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 IllegalArgumentException x
in
+ * scanline y
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 x
in
+ * scanline y
in the receiver's data to the
+ * values from the array pixels
starting at
+ * startIndex
.
+ *
+ * @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 IllegalArgumentException x
in
+ * scanline y
in the receiver's data to the
+ * values from the array pixels
starting at
+ * startIndex
.
+ *
+ * @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 IllegalArgumentException + * Currently supported image formats are: + *
ImageLoaders
can be used to:
+ * imageLoaderListeners
field.
+ */
+void reset() {
+ data = null;
+ logicalScreenWidth = 0;
+ logicalScreenHeight = 0;
+ backgroundPixel = -1;
+ repeatCount = 1;
+}
+
+/**
+ * Loads an array of ImageData
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 ImageData
objects loaded from the specified input stream
+ *
+ * @exception IllegalArgumentException ImageData
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 ImageData
objects loaded from the specified file
+ *
+ * @exception IllegalArgumentException IMAGE_BMP
IMAGE_BMP_RLE
IMAGE_GIF
IMAGE_ICO
IMAGE_JPEG
IMAGE_PNG
IMAGE_BMP
IMAGE_BMP_RLE
IMAGE_GIF
IMAGE_ICO
IMAGE_JPEG
IMAGE_PNG
+ * An ImageLoaderListener should be added before invoking
+ * one of the receiver's load methods. The listener's
+ * imageDataLoaded
method is called when image
+ * data has been partially loaded, as is supported by interlaced
+ * GIF/PNG or progressive JPEG images.
+ *
+ * @param listener the ImageLoaderListener to add
+ *
+ * @see ImageLoaderListener
+ * @see ImageLoaderEvent
+ */
+public void addImageLoaderListener(ImageLoaderListener listener) {
+ if (imageLoaderListeners == null) {
+ imageLoaderListeners = new Vector();
+ }
+ imageLoaderListeners.addElement(listener);
+}
+
+/**
+ * Removes a listener that was receiving image loader events.
+ *
+ * @param listener the ImageLoaderListener to remove
+ *
+ * @see #addImageLoaderListener
+ */
+public void removeImageLoaderListener(ImageLoaderListener listener) {
+ if (imageLoaderListeners == null) return;
+ imageLoaderListeners.removeElement(listener);
+}
+
+/**
+ * Returns true
if the receiver has image loader
+ * listeners, and false
otherwise.
+ *
+ * @return true
if there are ImageLoaderListener
s, and false
otherwise
+ *
+ * @see #addImageLoaderListener
+ * @see #removeImageLoaderListener
+ */
+public boolean hasListeners() {
+ return imageLoaderListeners != 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 ImageLoaderEvent
to send to each ImageLoaderListener
+ */
+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);
+ }
+}
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java
new file mode 100755
index 0000000000..737582344c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+import java.util.*;
+
+/**
+ * Instances of this class are sent as a result of the incremental
+ * loading of image data.
+ *
+ * Notes: + *
endOfImage
flag in the event will be set to true
+ * after each individual image is loaded.endOfImage
flag is false, then this is a
+ * partially complete copy of the current ImageData
,
+ * otherwise this is a completely loaded ImageData
+ */
+ 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 boolean endOfImage;
+
+/**
+ * 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, boolean 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 point
+ */
+public String toString () {
+ return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}";
+}
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java
new file mode 100755
index 0000000000..a1ba7f2727
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the incremental loading of image data.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to an image loader using the
+ * addImageLoaderListener
method and removed using
+ * the removeImageLoaderListener
method. When
+ * image data is either partially or completely loaded, this
+ * method will be invoked.
+ *
+ * The timing of when this method is called varies depending on + * the format of the image being loaded. + *
+ * + * @param e an event containing information about the image loading operation + */ +public void imageDataLoaded(ImageLoaderEvent e); + +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java new file mode 100755 index 0000000000..91ef2bb4fe --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java @@ -0,0 +1,205 @@ +package org.eclipse.swt.graphics; + +/* + * Licensed Materials - Property of IBM, + * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved + */ + +import org.eclipse.swt.*; + +/** + * Instances of this class describe the color data used by an image. + *+ * Depending on the depth of the image, the PaletteData can take one + * of two forms, indicated by the isDirect field: + *
+ *false
, this palette is an indexed
+ * palette which maps pixel values to RGBs. The actual RGB values
+ * may be retrieved by using the getRGBs() method.
+ * true
, 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.
+ * + * 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. + *
+ *RGB
s for the palette
+ *
+ * @exception IllegalArgumentException RBG
.
+ *
+ * @return the pixel value for the given RGB
+ *
+ * @exception IllegalArgumentException RGB
corresponding to the given pixel value.
+ *
+ * @return the RGB value for the given pixel
+ *
+ * @exception IllegalArgumentException RGB
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) != 0) return 7 - i;
+ }
+ return 32;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
new file mode 100755
index 0000000000..64251fec65
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
@@ -0,0 +1,93 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+
+/**
+ * Instances of this class represent places on the (x, y)
+ * coordinate plane.
+ * + * 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. + *
+ *
+ * Application code does not need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no dispose()
method is provided.
+ *
true
if the object is the same as this object and false
otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Point)) return false;
+ Point p = (Point)object;
+ return (p.x == this.x) && (p.y == this.y);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which return true
when passed to
+ * equals
must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+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 + "}";
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java
new file mode 100755
index 0000000000..7437c7c4d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+import org.eclipse.swt.*;
+
+/**
+ * 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.
+ *
+ * Application code does not need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no dispose()
method is provided.
+ *
true
if the object is the same as this object and false
otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof RGB)) return false;
+ RGB rgb = (RGB)object;
+ return (rgb.red == this.red) && (rgb.green == this.green) && (rgb.blue == this.blue);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which return true
when passed to
+ * equals
must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+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 RGB
+ */
+public String toString () {
+ return "RGB {" + red + ", " + green + ", " + blue + "}";
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
new file mode 100755
index 0000000000..42b2f030cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
@@ -0,0 +1,264 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+import org.eclipse.swt.*;
+
+/**
+ * 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.
+ * + * 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. + *
+ *
+ * Application code does not need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no dispose()
method is provided.
+ *
+ * The union of two rectangles is the smallest single rectangle + * that completely covers both of the areas covered by the two + * given rectangles. + *
+ * + * @param rect the rectangle to merge with the receiver + * + * @exception IllegalArgumentExceptiontrue
if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and false
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 true
if the rectangle contains the point and false
otherwise
+ */
+public boolean contains (int x, int y) {
+ return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height);
+}
+
+/**
+ * Returns true
if the given point is inside the
+ * area specified by the receiver, and false
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return true
if the rectangle contains the point and false
otherwise
+ *
+ * @exception IllegalArgumentException true
if the object is the same as this object and false
otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Rectangle)) return false;
+ Rectangle r = (Rectangle)object;
+ return (r.x == this.x) && (r.y == this.y) && (r.width == this.width) && (r.height == this.height);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which return true
when passed to
+ * equals
must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+ return x ^ y ^ width ^ height;
+}
+
+/**
+ * Returns a new rectangle which represents the intersection
+ * of the receiver and the given rectangle.
+ * + * The intersection of two rectangles is the rectangle that + * covers the area which is contained within both rectangles. + *
+ * + * @param rect the rectangle to intersect with the receiver + * @return the intersection of the receiver and the argument + * + * @exception IllegalArgumentExceptiontrue
if the given rectangle intersects
+ * with the receiver and false
otherwise.
+ * + * Two rectangles intersect if the area of the rectangle + * representing their intersection is not empty. + *
+ * + * @param rect the rectangle to test for intersection + * @returntrue
if the rectangle intersects with the receiver, and false
otherwise
+ *
+ * @exception IllegalArgumentException true
if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and false
if
+ * the receiver does cover some area in the plane.
+ * + * A rectangle is considered to cover area in the + * (x, y) coordinate plane if both its width and height are + * non-zero. + *
+ * + * @returntrue
if the receiver is empty, and false
otherwise
+ */
+public boolean 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 + "}";
+}
+
+/**
+ * Returns a new rectangle which represents the union of
+ * the receiver and the given rectangle.
+ *
+ * @param rect the rectangle to perform union with
+ * @return the union of the receiver and the argument
+ *
+ * @exception IllegalArgumentException GC
s)
+where most of the primitive drawing operations are implemented, and
+images including both the code for displaying them and the public API for
+loading/saving them.
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
new file mode 100755
index 0000000000..3dc9ef89d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
@@ -0,0 +1,270 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent entry points into Java
+ * which can be invoked from operating system level callback
+ * routines.
+ *
+ * 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, address;
+ boolean isStatic, isArrayBased;
+
+ /* SWT Version - Mmmm (M=major, mmm=minor) */
+
+ /**
+ * SWT Major version number (must be >= 0)
+ */
+ public static int MAJOR_VERSION = 0;
+
+ /**
+ * SWT Minor version number (must be in the range 0..999)
+ */
+ public static int MINOR_VERSION = 105;
+
+ /**
+ * SWT revision number (must be >= 0)
+ */
+ public static int REVISION = 0;
+
+ /* Load the SWT library */
+ static {
+ loadLibrary ("swt");
+ }
+
+/**
+ * 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
+ * Note: This should not be called by application code.
+ *
+ * Note: This should not be called by application code.
+ *
+ * WARNING: This operation is extremely dangerous,
+ * and should never be performed by application code.
+ *
+Applications should not need to reference the classes in this package
+directly.
+
+Applications should not need to reference the classes in this package
+directly.
+Class
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 Callback (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 Class
+ * 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 true
if the arguments should be passed in an array and false otherwise
+ */
+public Callback (Object object, String method, int argCount, boolean isArrayBased) {
+
+ /* Set the callback fields */
+ this.object = object;
+ this.method = method;
+ this.argCount = argCount;
+ isStatic = object instanceof Class;
+ this.isArrayBased = isArrayBased;
+
+ /* Inline the common cases */
+ if (isArrayBased) {
+ signature = "([I)I";
+ } else {
+ switch (argCount) {
+ case 0: signature = "()I"; break;
+ case 1: signature = "(I)I"; break;
+ case 2: signature = "(II)I"; break;
+ case 3: signature = "(III)I"; break;
+ case 4: signature = "(IIII)I"; break;
+ default:
+ signature = "(";
+ for (int i=0; iCallback
objects to be invoked. This method is used
+ * to safely shut down SWT when it is run within environments
+ * which can generate spurious events.
+ * Callback
objects to be invoked. This method is used
+ * to safely shut down SWT when it is run within environments
+ * which can generate spurious events.
+ * name
is used to load the library. If this fails,
+ * name
is used in another attempt to load the library,
+ * this time ignoring the SWT version encoding scheme.
+ *
+ * @param name the name of the library to load
+ */
+public static void loadLibrary (String name) {
+ String newName = name + MAJOR_VERSION;
+
+ /* Force 3 digits in minor version number */
+ if (MINOR_VERSION < 10) {
+ newName += "00";
+ } else {
+ if (MINOR_VERSION < 100) newName += "0";
+ }
+ newName += MINOR_VERSION;
+
+ /* No "r" until first revision */
+ if (REVISION > 0) newName += "r" + REVISION;
+ try {
+ System.loadLibrary (newName);
+ } catch (UnsatisfiedLinkError e) {
+ try {
+ System.loadLibrary (name);
+ } catch (UnsatisfiedLinkError e2) {
+ throw e;
+ }
+ }
+}
+
+/**
+ * Immediately wipes out all native level state associated
+ * with all callbacks.
+ *
+Package Specification
+This package contains the classes used by SWT to load and save images
+in the various formats we support, including GIF, JPEG, PNG, BMP, and ICO.
+
+Package Specification
+This package provides the Callback
class which is used to
+map the operating system's callback mechanism to Java message sends, and
+the Converter
class which provides translation between Unicode
+and platform specific character sets.
+
+Package Specification
+Detailed overview will be provided here.
+
+