Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2001-09-06 15:55:01 +0000
committerVeronika Irvine2001-09-06 15:55:01 +0000
commit9db9eaa4c9346279d69887c57d68487acf58fa79 (patch)
tree222d8b89406a7bfe8b83c5e1d4a123ebed3b82a4
parenta21dafc13697c8c030c220103732423749b33e9b (diff)
downloadeclipse.platform.swt-9db9eaa4c9346279d69887c57d68487acf58fa79.tar.gz
eclipse.platform.swt-9db9eaa4c9346279d69887c57d68487acf58fa79.tar.xz
eclipse.platform.swt-9db9eaa4c9346279d69887c57d68487acf58fa79.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/.classpath_motif1
-rwxr-xr-xbundles/org.eclipse.swt/.classpath_photon1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java52
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java190
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java192
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java144
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java83
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java50
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java79
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java125
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java143
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java43
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java1757
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java3827
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/version.txt2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh52
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc461
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c679
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java96
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java241
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java179
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java438
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java64
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java111
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java313
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java367
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java244
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java487
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java250
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java1147
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java243
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java2645
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java415
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java324
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java625
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java206
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java1147
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java168
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java130
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java336
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java280
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java1305
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java667
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java620
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java129
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java258
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java741
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java214
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java2051
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java693
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java468
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java1025
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java353
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java2778
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java495
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java1074
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java1380
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java300
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java627
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java286
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java1661
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java1198
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java156
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java718
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c166
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h43
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c390
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java265
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java68
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java313
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java75
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java44
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java110
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java163
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java263
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java336
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java105
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java65
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java136
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java69
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java2051
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java168
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java2777
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java495
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java1074
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java179
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java84
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java1661
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java1198
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java156
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java65
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c104
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c353
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java60
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java176
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java230
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java178
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java213
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java139
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java34
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java72
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java79
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java69
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java84
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java80
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java72
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java82
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java84
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java140
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java57
-rwxr-xr-xbundles/org.eclipse.swt/build.properties.motif2
-rwxr-xr-xbundles/org.eclipse.swt/build.properties.photon2
-rwxr-xr-xbundles/org.eclipse.swt/buildnotes_swt.html59
-rwxr-xr-xbundles/org.eclipse.swt/ws/motif/libswt-gnome0125.sobin0 -> 4713 bytes
-rwxr-xr-xbundles/org.eclipse.swt/ws/motif/libswt0125.sobin0 -> 366199 bytes
-rwxr-xr-xbundles/org.eclipse.swt/ws/photon/libswt0125.sobin0 -> 385634 bytes
-rwxr-xr-xbundles/org.eclipse.swt/ws/win32/swt0125.dllbin0 -> 237568 bytes
202 files changed, 36142 insertions, 19379 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif
index d89e2d31c2..9446ffe549 100755
--- a/bundles/org.eclipse.swt/.classpath_motif
+++ b/bundles/org.eclipse.swt/.classpath_motif
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="var" path="JRE_LIB"/>
<classpathentry kind="src" path="Eclipse SWT/motif"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated"/>
<classpathentry kind="src" path="Eclipse SWT/common"/>
<classpathentry kind="src" path="Eclipse SWT Printing/motif"/>
<classpathentry kind="src" path="Eclipse SWT Printing/common"/>
diff --git a/bundles/org.eclipse.swt/.classpath_photon b/bundles/org.eclipse.swt/.classpath_photon
index 89aa3ff82e..c061bdbf30 100755
--- a/bundles/org.eclipse.swt/.classpath_photon
+++ b/bundles/org.eclipse.swt/.classpath_photon
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="var" path="JRE_LIB"/>
<classpathentry kind="src" path="Eclipse SWT/photon"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated"/>
<classpathentry kind="src" path="Eclipse SWT/common"/>
<classpathentry kind="src" path="Eclipse SWT Printing/photon"/>
<classpathentry kind="src" path="Eclipse SWT Printing/common"/>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
index d6f26064d6..d6777ad621 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
@@ -25,8 +25,6 @@ import java.awt.Panel;
import java.awt.Dimension;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
-import java.awt.event.WindowEvent;
-import java.awt.event.FocusEvent;
public class SWT_AWT {
@@ -35,18 +33,6 @@ public static Panel new_Panel (final Composite parent) {
final WEmbeddedFrame frame = new WEmbeddedFrame (handle);
Panel panel = new Panel ();
frame.add (panel);
- parent.addListener (SWT.Activate, new Listener () {
- public void handleEvent (Event e) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
- frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
- }
- });
- parent.addListener (SWT.Deactivate, new Listener () {
- public void handleEvent (Event e) {
- frame.dispatchEvent (new WindowEvent(frame, WindowEvent.WINDOW_DEACTIVATED));
- frame.dispatchEvent (new FocusEvent(frame, FocusEvent.FOCUS_LOST));
- }
- });
parent.addListener (SWT.Resize, new Listener () {
public void handleEvent (Event e) {
Rectangle rect = parent.getClientArea ();
@@ -54,11 +40,6 @@ public static Panel new_Panel (final Composite parent) {
frame.validate ();
}
});
- parent.addListener (SWT.Dispose, new Listener () {
- public void handleEvent (Event e) {
- frame.dispose ();
- }
- });
return panel;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
index fc640a5a31..404ff4793f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
@@ -15,6 +15,8 @@ import org.eclipse.swt.widgets.*;
*/
public class BusyIndicator {
+ static Display[] displays = new Display[0];
+ static Cursor[] cursors = new Cursor[0];
static int nextBusyId = 1;
static final String BUSYID_NAME = "SWT BusyIndicator";
@@ -39,15 +41,40 @@ public static void showWhile(Display display, Runnable runnable) {
}
}
+ 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);
+ }
+ });
+
+ Cursor[] newCursors = new Cursor[cursors.length + 1];
+ System.arraycopy(cursors, 0, newCursors, 0, cursors.length);
+ cursors = newCursors;
+ }
+
+ if (cursors[index] == null) {
+ cursors[index] = new Cursor(display, SWT.CURSOR_WAIT);
+ }
+
Integer busyId = new Integer(nextBusyId);
- nextBusyId++;
- Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);
+ nextBusyId = (++nextBusyId) % 65536;
Shell[] shells = display.getShells();
for (int i = 0; i < shells.length; i++) {
Integer id = (Integer)shells[i].getData(BUSYID_NAME);
if (id == null) {
- shells[i].setCursor(cursor);
+ shells[i].setCursor(cursors[index]);
shells[i].setData(BUSYID_NAME, busyId);
}
}
@@ -63,9 +90,22 @@ public static void showWhile(Display display, Runnable runnable) {
shells[i].setData(BUSYID_NAME, null);
}
}
- if (cursor != null && !cursor.isDisposed()) {
- cursor.dispose();
- }
}
}
+
+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;
+ displays[index] = null;
+}
}
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
index de94692db8..ca80b50924 100755
--- 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
@@ -81,19 +81,19 @@ public CCombo (Composite parent, int style) {
}
};
- int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
- for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
-
- int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
+ int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Activate, SWT.Deactivate};
for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
- int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};
+ int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse};
for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut};
+ int [] listEvents = {SWT.MouseUp, SWT.Selection};
for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
- int [] arrowEvents = {SWT.MouseDown, SWT.FocusIn, SWT.FocusOut};
+ int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize, SWT.Activate, SWT.Deactivate};
+ for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
+
+ int [] arrowEvents = {SWT.MouseDown};
for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
}
@@ -185,31 +185,8 @@ public void addSelectionListener(SelectionListener listener) {
addListener (SWT.DefaultSelection,typedListener);
}
void arrowEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- Control focusControl = getDisplay ().getFocusControl();
- if (focusControl == list || focusControl == text) return;
- hasFocus = false;
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusOut, e);
- break;
- }
- case SWT.MouseDown: {
- if (event.button != 1) return;
- dropDown (!isDropped ());
- break;
- }
- }
+ if (event.type != SWT.MouseDown || event.button != 1) return;
+ dropDown (!isDropped ());
}
/**
* Clears the current selection.
@@ -227,18 +204,38 @@ public void clearSelection () {
void comboEvent (Event event) {
switch (event.type) {
case SWT.Dispose:
- if (popup != null && !popup.isDisposed ()) popup.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;
+ case SWT.Activate: {
+ if (hasFocus) return;
+ hasFocus = true;
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.Deactivate: {
+ Control focusControl = getDisplay ().getFocusControl();
+ if (focusControl == list) return;
+ hasFocus = false;
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
}
}
@@ -534,30 +531,9 @@ void internalLayout () {
}
void listEvent (Event event) {
switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- Control focusControl = getDisplay ().getFocusControl();
- if (focusControl == text || focusControl == arrow) return;
- hasFocus = false;
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusOut, e);
- break;
- }
case SWT.MouseUp: {
if (event.button != 1) return;
dropDown (false);
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.DefaultSelection, e);
break;
}
case SWT.Selection: {
@@ -568,63 +544,16 @@ void listEvent (Event event) {
list.setSelection(index);
Event e = new Event();
e.time = event.time;
- e.stateMask = event.stateMask;
- e.doit = event.doit;
- notifyListeners(SWT.Selection, e);
- event.doit = e.doit;
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- event.doit = false;
- break;
- }
- 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;
- e.keyCode = event.keyCode;
- notifyListeners(SWT.Traverse, e);
+ notifyListeners(SWT.Selection, e);
event.doit = e.doit;
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.KeyDown: {
- if (event.character == SWT.ESC) {
- // escape key cancels popup list
- dropDown (false);
- }
- if (event.character == SWT.CR || event.character == '\t') {
- // Enter and Tab cause default selection
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
- }
-
- 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;
-
- }
}
}
void popupEvent(Event event) {
@@ -640,6 +569,14 @@ void popupEvent(Event event) {
event.doit = false;
dropDown (false);
break;
+ case SWT.Activate:
+ if (hasFocus) return;
+ hasFocus = true;
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
case SWT.Deactivate:
dropDown (false);
break;
@@ -944,35 +881,11 @@ public void setVisible (boolean visible) {
}
void textEvent (Event event) {
switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- Control focusControl = getDisplay ().getFocusControl();
- if (focusControl == list || focusControl == arrow) return;
- hasFocus = false;
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusOut, e);
- break;
- }
case SWT.KeyDown: {
if (event.character == SWT.ESC) { // escape key cancels popup list
dropDown (false);
- }
- if (event.character == SWT.CR || event.character == '\t') {
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
+ return;
}
if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
int oldIndex = getSelectionIndex ();
@@ -985,13 +898,11 @@ void textEvent (Event event) {
if (oldIndex != getSelectionIndex ()) {
Event e = new Event();
e.time = event.time;
- e.stateMask = event.stateMask;
notifyListeners(SWT.Selection, e);
}
}
- // Further work : Need to add support for incremental search in
- // pop up list as characters typed in text widget
+ // 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;
@@ -1034,11 +945,18 @@ void textEvent (Event event) {
}
case SWT.Traverse: {
switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
case SWT.TRAVERSE_TAB_NEXT:
+ // allow "return" and "tab" to have their usual effect
+ break;
+ case SWT.TRAVERSE_ESCAPE:
+ // escape key is used to close the list so
+ // do not use it for traversal
+ event.doit = false;
+ break;
case SWT.TRAVERSE_ARROW_PREVIOUS:
case SWT.TRAVERSE_ARROW_NEXT:
- // The tab key causes default selection and
- // the arrow keys are used to manipulate the list contents so
+ // arrow keys are used to manipulate the list contents so
// do not use them for traversal.
event.doit = false;
break;
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
index 799891d8fa..0afada598c 100755
--- 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
@@ -53,6 +53,7 @@ public class CLabel extends Canvas {
private String appToolTipText;
private Image backgroundImage;
+ private Image gradientImage;
private Color[] gradientColors;
private int[] gradientPercents;
@@ -191,6 +192,10 @@ private void paintBorder(GC gc, Rectangle r) {
}
}
private void onDispose(DisposeEvent event) {
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ }
+ gradientImage = null;
gradientColors = null;
gradientPercents = null;
backgroundImage = null;
@@ -204,12 +209,12 @@ private void onPaint(PaintEvent event) {
boolean shortenText = false;
String t = text;
- Image img = image;
+ Image i = image;
int availableWidth = rect.width - 2*hIndent;
- Point extent = getTotalSize(img, t);
+ Point extent = getTotalSize(i, t);
if (extent.x > availableWidth) {
- img = null;
- extent = getTotalSize(img, t);
+ i = null;
+ extent = getTotalSize(i, t);
if (extent.x > availableWidth) {
shortenText = true;
}
@@ -220,7 +225,7 @@ private void onPaint(PaintEvent event) {
// shorten the text
if (shortenText) {
t = shortenText(gc, text, availableWidth);
- extent = getTotalSize(img, t);
+ extent = getTotalSize(i, t);
if (appToolTipText == null) {
super.setToolTipText(text);
}
@@ -238,52 +243,28 @@ private void onPaint(PaintEvent event) {
}
// draw a background image behind the text
- try {
- if (backgroundImage != null) {
- // draw a background image behind the text
- Rectangle imageRect = backgroundImage.getBounds();
+ if (backgroundImage != null) {
+ Rectangle imageRect = backgroundImage.getBounds();
+ try {
gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,
- 0, 0, rect.width, rect.height);
- } else if (gradientColors != null) {
- // draw a gradient behind the text
- final Color oldBackground = gc.getBackground();
- if (gradientColors.length == 1) {
- if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);
- gc.fillRectangle(0, 0, rect.width, rect.height);
- } else {
- final Color oldForeground = gc.getForeground();
- Color lastColor = gradientColors[0];
- if (lastColor == null) lastColor = oldBackground;
- for (int i = 0, pos = 0; i < gradientPercents.length; ++i) {
- gc.setForeground(lastColor);
- lastColor = gradientColors[i + 1];
- if (lastColor == null) lastColor = oldBackground;
- gc.setBackground(lastColor);
- final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
- gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);
- pos += gradientWidth;
- }
- gc.setForeground(oldForeground);
- }
- gc.setBackground(oldBackground);
- } else {
+ 0, 0, rect.width, rect.height);
+ } catch(SWTException e) {
gc.setBackground(getBackground());
gc.fillRectangle(rect);
}
- } catch (SWTException e) {
+ } 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 (img != null) {
- Rectangle imageRect = img.getBounds();
- gc.drawImage(img, 0, 0, imageRect.width, imageRect.height,
+ 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;
}
@@ -327,68 +308,113 @@ public void setAlignment(int align) {
* 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) {
+public void setBackground(Color[] colors, int[] percents) {
if (colors != null) {
- if (percents == null || percents.length != colors.length - 1) {
+ if (percents == null || percents.length != colors.length - 1)
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (getDisplay().getDepth() < 15) {
- // Don't use gradients on low color displays
- colors = new Color[] { colors[0] };
- percents = new int[] { };
- }
for (int i = 0; i < percents.length; i++) {
- if (percents[i] < 0 || percents[i] > 100) {
+ if (percents[i] < 0 || percents[i] > 100)
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (i > 0 && percents[i] < percents[i-1]) {
+ if (i > 0 && percents[i] < percents[i-1])
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
}
}
// Are these settings the same as before?
- final Color background = getBackground();
- if (backgroundImage == null) {
- 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]) ||
- ((gradientColors[i] == null) && (colors[i] == background)) ||
- ((gradientColors[i] == background) && (colors[i] == null));
+ 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) {
- for (int i = 0; i < gradientPercents.length; i++) {
- same = gradientPercents[i] == percents[i];
- if (!same) break;
- }
- }
- if (same) return;
}
- } else {
- backgroundImage = null;
+ if (same) return;
}
- // Store the new settings
- if (colors == null) {
- gradientColors = null;
- gradientPercents = null;
- } else {
- gradientColors = new Color[colors.length];
- for (int i = 0; i < colors.length; ++i)
- gradientColors[i] = (colors[i] != null) ? colors[i] : background;
- gradientPercents = new int[percents.length];
- for (int i = 0; i < percents.length; ++i)
- gradientPercents[i] = percents[i];
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
}
- // Refresh with the new settings
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ Color[] colorsCopy = null;
+ Display display = getDisplay();
+ if (display.getDepth() < 15) {
+ colorsCopy = new Color[]{colors[0]};
+ } else {
+ colorsCopy = colors;
+ }
+
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ if (colorsCopy.length == 1) {
+ gc.setBackground(colorsCopy[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ int start = 0;
+ int end = 0;
+ for (int j = 0; j < colorsCopy.length - 1; j++) {
+ Color startColor = colorsCopy[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colorsCopy[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 = colorsCopy;
+ gradientPercents = percents;
+ backgroundImage = temp;
+ }
+
redraw();
}
public void setBackground(Image image) {
- if (image == backgroundImage) return;
- gradientColors = null;
- gradientPercents = null;
+ if (image == backgroundImage) return;
+
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ }
backgroundImage = image;
redraw();
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
index ce891077a4..2d10a97655 100755
--- 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
@@ -88,8 +88,9 @@ public class CTabFolder extends Composite {
/* Color appearance */
Image backgroundImage;
- Color[] gradientColors;
- int[] gradientPercents;
+ private Image gradientImage;
+ private Color[] gradientColors;
+ private int[] gradientPercents;
Color selectionForeground;
// internal constants
@@ -458,6 +459,10 @@ private void onDispose() {
tip = null;
}
+ if (gradientImage != null){
+ gradientImage.dispose();
+ gradientImage = null;
+ }
gradientColors = null;
gradientPercents = null;
backgroundImage = null;
@@ -659,10 +664,8 @@ private void handleEvents (Event event){
inactiveItem = null;
}
if (event.widget == inactiveCloseBar) {
- if (inactiveItem != null) {
- Rectangle itemBounds = inactiveItem.getBounds();
- if (itemBounds.contains(event.x, event.y)) return;
- }
+ Rectangle bounds = getBounds();
+ if (bounds.contains(event.x, event.y)) return;
inactiveCloseBar.setVisible(false);
inactiveItem = null;
}
@@ -952,7 +955,7 @@ private void redrawTabArea(int index) {
y = item.y;
Rectangle area = super.getClientArea();
width = area.x + area.width - x;
- height = item.height;
+ height = area.y + area.height - y;
}
redraw(x, y, width, height, false);
}
@@ -1102,11 +1105,6 @@ public void setSelectionBackground(Color[] colors, int[] percents) {
if (percents == null || percents.length != colors.length - 1) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
- if (getDisplay().getDepth() < 15) {
- // Don't use gradients on low color displays
- colors = new Color[] { colors[0] };
- percents = new int[] { };
- }
for (int i = 0; i < percents.length; i++) {
if (percents[i] < 0 || percents[i] > 100) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
@@ -1118,49 +1116,105 @@ public void setSelectionBackground(Color[] colors, int[] percents) {
}
// Are these settings the same as before?
- final Color background = getBackground();
- if (backgroundImage == null) {
- 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]) ||
- ((gradientColors[i] == null) && (colors[i] == background)) ||
- ((gradientColors[i] == background) && (colors[i] == null));
+ 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) {
- for (int i = 0; i < gradientPercents.length; i++) {
- same = gradientPercents[i] == percents[i];
- if (!same) break;
- }
- }
- if (same) return;
}
- } else {
- backgroundImage = null;
+ if (same) return;
+ }
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
}
- // Store the new settings
- if (colors == null) {
- gradientColors = null;
- gradientPercents = null;
- closeBar.setBackground(background);
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ Color[] colorsCopy = null;
+ Display display = getDisplay();
+ if (display.getDepth() < 15) {
+ colorsCopy = new Color[]{colors[0]};
+ } else {
+ colorsCopy = colors;
+ }
+
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ int start = 0;
+ int end = 0;
+ Color background = getBackground();
+ if (colorsCopy.length == 1) {
+ gc.setBackground(colorsCopy[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ for (int j = 0; j < colorsCopy.length - 1; j++) {
+ Color startColor = colorsCopy[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colorsCopy[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 = colorsCopy;
+ gradientPercents = percents;
+ backgroundImage = temp;
+
+ Color closeBackground = colorsCopy[colorsCopy.length - 1];
+ if (closeBackground == null || display.getDepth() < 15){
+ closeBackground = background;
+ }
+ closeBar.setBackground(closeBackground);
} else {
- gradientColors = new Color[colors.length];
- for (int i = 0; i < colors.length; ++i)
- gradientColors[i] = (colors[i] != null) ? colors[i] : background;
- gradientPercents = new int[percents.length];
- for (int i = 0; i < percents.length; ++i)
- gradientPercents[i] = percents[i];
- if (getDisplay().getDepth() < 15) closeBar.setBackground(background);
- else closeBar.setBackground(gradientColors[gradientColors.length - 1]);
+ closeBar.setBackground(getBackground());
}
-
- // Refresh with the new settings
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;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
index 5a20b6622b..db93a6b6d1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
@@ -134,39 +134,17 @@ void onPaint(GC gc, boolean isSelected) {
int index = parent.indexOf(this);
if (isSelected) {
- final Rectangle bounds;
- if (index == parent.topTabIndex) {
- bounds = new Rectangle(x + 1, y, width - 2, height);
- } else {
- bounds = new Rectangle(x + 2, y, width - 3, height);
- }
+ // draw a background image behind the text
if (parent.backgroundImage != null) {
- // draw a background image behind the text
- Rectangle imageRect = parent.backgroundImage.getBounds();
- gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
- bounds.x, bounds.y, bounds.width, bounds.height);
- } else if (parent.gradientColors != null) {
- // draw a gradient behind the text
- final Color oldBackground = gc.getBackground();
- if (parent.gradientColors.length == 1) {
- if (parent.gradientColors[0] != null) gc.setBackground(parent.gradientColors[0]);
- gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+ 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 {
- final Color oldForeground = gc.getForeground();
- Color lastColor = parent.gradientColors[0];
- if (lastColor == null) lastColor = oldBackground;
- for (int i = 0, pos = 0; i < parent.gradientPercents.length; ++i) {
- gc.setForeground(lastColor);
- lastColor = parent.gradientColors[i + 1];
- if (lastColor == null) lastColor = oldBackground;
- gc.setBackground(lastColor);
- final int gradientWidth = (parent.gradientPercents[i] * bounds.width / 100) - pos;
- gc.fillGradientRectangle(bounds.x + pos, bounds.y, gradientWidth, bounds.height, false);
- pos += gradientWidth;
- }
- gc.setForeground(oldForeground);
+ Rectangle imageRect = parent.backgroundImage.getBounds();
+ gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ x + 2, y, width - 4, height);
}
- gc.setBackground(oldBackground);
}
// draw tab lines
@@ -177,9 +155,9 @@ void onPaint(GC gc, boolean isSelected) {
gc.drawLine(x, y + 1, x, y + height - 2);
gc.drawLine(x, y + height - 1, x, y + height - 1);
}
- gc.drawLine(x + width - 1, y, x + width - 1, y);
- gc.drawLine(x + width, y + 1, x + width, y + height - 2);
- gc.drawLine(x + width, y + height - 1, x + width, 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) {
@@ -190,15 +168,15 @@ void onPaint(GC gc, boolean isSelected) {
gc.drawLine(x, y, 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.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 - 3, y);
+ gc.drawLine(x + 3, y, x + width - 4, y);
} else {
- gc.drawLine(x + 1, y, x + width - 3, y);
+ gc.drawLine(x + 1, y, x + width - 4, y);
}
} else {
gc.setForeground(normalShadow);
@@ -207,9 +185,9 @@ void onPaint(GC gc, boolean isSelected) {
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, y, x + width, y);
- gc.drawLine(x + width, y + 1, x + width, y + height - 2);
- gc.drawLine(x + width - 1, y + height - 1, x + width - 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) {
@@ -220,32 +198,19 @@ void onPaint(GC gc, boolean isSelected) {
gc.drawLine(x, y, x, 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.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 - 3, y + height - 1);
+ 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 - 3, y + height - 1);
+ gc.drawLine(x + 1, y + height - 1, x + width - 4, y + height - 1);
}
}
- } else {
- // draw tab lines for unselected items
- gc.setForeground(normalShadow);
- if (!parent.onBottom) {
- if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
- gc.drawLine(x, y, x, y + (height / 2));
- }
- } else {
- if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
- gc.drawLine(x, y + (height / 2), x, y + height - 1);
- }
- }
-
}
// draw Image
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
index 9dfd02a16d..0d6cd7af99 100755
--- 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
@@ -168,6 +168,7 @@ Rectangle computeBounds (){
* composite and the editor Control are <b>not</b> disposed.
*/
public void dispose () {
+
if (!parent.isDisposed()) {
parent.removeListener (SWT.Resize, internalListener);
ScrollBar hBar = parent.getHorizontalBar ();
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
index 509256691c..51b9066831 100755
--- 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
@@ -162,46 +162,6 @@ boolean isDelimiter(char ch) {
return false;
}
/**
- * Determine whether or not the replace operation is valid. DefaultContent will not allow
- * the /r/n line delimiter to be split or partially deleted.
- * <p>
- *
- * @param start start offset of text to replace
- * @param replaceLength start offset of text to replace
- * @param newText start offset of text to replace
- */
-protected boolean isValidReplace(int start, int replaceLength, String newText){
- if (replaceLength == 0) {
- // inserting text, see if the \r\n line delimiter is being split
- if (start == 0) return true;
- if (start == getCharCount()) return true;
- char before = getTextRange(start - 1, 1).charAt(0);
- if (before == '\r') {
- char after = getTextRange(start, 1).charAt(0);
- if (after == '\n') return false;
- }
- } else {
- // deleting text, see if part of a \r\n line delimiter is being deleted
- char startChar = getTextRange(start, 1).charAt(0);
- if (startChar == '\n') {
- // see if char before delete position is \r
- if (start != 0) {
- char before = getTextRange(start - 1, 1).charAt(0);
- if (before == '\r') return false;
- }
- }
- char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);
- if (endChar == '\r') {
- // see if char after delete position is \n
- if (start + replaceLength != getCharCount()) {
- char after = getTextRange(start + replaceLength, 1).charAt(0);
- if (after == '\n') return false;
- }
- }
- }
- return true;
-}
-/**
* Calculates the indexes of each line of text in the given range.
* <p>
*
@@ -753,18 +713,8 @@ public void removeTextChangeListener(TextChangeListener listener){
* @param start start offset of text to replace
* @param replaceLength start offset of text to replace
* @param newText start offset of text to replace
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte
- * line delimiter being split or partially deleted. Splitting a line
- * delimiter by inserting text between the CR and LF characters of the
- * \r\n delimiter or deleting part of this line delimiter is not supported</li>
- * </ul>
*/
public void replaceTextRange(int start, int replaceLength, String newText){
- // check for invalid replace operations
- if (!isValidReplace(start, replaceLength, newText)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
// inform listeners
StyledTextEvent event = new StyledTextEvent(this);
event.type = StyledText.TextChanging;
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
index daadb8facb..fced63b944 100755
--- 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
@@ -33,8 +33,6 @@ public class ScrolledComposite extends Composite {
private int minWidth = 0;
private boolean expandHorizontal = false;
private boolean expandVertical = false;
- private boolean alwaysShowScroll = false;
- private boolean inResize = false;
public ScrolledComposite(Composite parent, int style) {
super(parent, checkStyle(style));
@@ -88,76 +86,9 @@ private void hScroll() {
int hSelection = hBar.getSelection ();
content.setLocation (-hSelection, location.y);
}
-private boolean needHScroll(Rectangle contentRect, boolean vVisible) {
- ScrollBar hBar = getHorizontalBar();
- if (hBar == null) return false;
-
- Rectangle hostRect = getBounds();
- int border = getBorderWidth();
- hostRect.width -= 2*border;
- ScrollBar vBar = getVerticalBar();
- if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x;
-
- if (!expandHorizontal && contentRect.width > hostRect.width) return true;
- if (expandHorizontal && minWidth > hostRect.width) return true;
- return false;
-}
-private boolean needVScroll(Rectangle contentRect, boolean hVisible) {
- ScrollBar vBar = getVerticalBar();
- if (vBar == null) return false;
-
- Rectangle hostRect = getBounds();
- int border = getBorderWidth();
- hostRect.height -= 2*border;
- ScrollBar hBar = getHorizontalBar();
- if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y;
-
- if (!expandHorizontal && contentRect.height > hostRect.height) return true;
- if (expandHorizontal && minHeight > hostRect.height) return true;
- return false;
-}
-
-/**
- * Returns the Always Show Scrollbars flag. True if the scrollbars are
- * always shown even if they are not required. False if the scrollbars are only
- * visible when some part of the composite needs to be scrolled to be seen.
- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
- * horizontal and vertical directions.
- *
- * @return the Always Show Scrollbars flag value
- */
-public boolean getAlwaysShowScrollBars() {
- return alwaysShowScroll;
-}
-
-/**
- * Set the Always Show Scrollbars flag. True if the scrollbars are
- * always shown even if they are not required. False if the scrollbars are only
- * visible when some part of the composite needs to be scrolled to be seen.
- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
- * horizontal and vertical directions.
- */
-public void setAlwaysShowScrollBars(boolean show) {
- alwaysShowScroll = show;
- resize();
-}
-
private void resize() {
- if (content == null || inResize) return;
- inResize = true;
- ScrollBar hBar = getHorizontalBar ();
- ScrollBar vBar = getVerticalBar ();
+ if (content == null) return;
Rectangle contentRect = content.getBounds();
- contentRect.x = contentRect.y = 0;
-
- if (!alwaysShowScroll) {
- boolean hVisible = needHScroll(contentRect, false);
- boolean vVisible = needVScroll(contentRect, hVisible);
- if (!hVisible && vVisible) hVisible = needHScroll(contentRect, vVisible);
- if (hBar != null) hBar.setVisible(hVisible);
- if (vBar != null) vBar.setVisible(vVisible);
- }
-
Rectangle hostRect = getClientArea();
if (expandHorizontal) {
contentRect.width = Math.max(minWidth, hostRect.width);
@@ -165,7 +96,8 @@ private void resize() {
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));
@@ -176,7 +108,8 @@ private void resize() {
contentRect.x = -hSelection;
}
}
-
+
+ ScrollBar vBar = getVerticalBar ();
if (vBar != null) {
vBar.setMaximum (contentRect.height);
vBar.setThumb (Math.min (contentRect.height, hostRect.height));
@@ -189,9 +122,7 @@ private void resize() {
}
content.setBounds (contentRect);
- inResize = false;
}
-
/**
* Set the content that will be scrolled.
*/
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
index 5487dcef0a..c65cfd471a 100755
--- 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
@@ -9,7 +9,6 @@ import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.printing.*;
import java.util.*;
/**
@@ -3385,33 +3384,16 @@ public void paste(){
}
/**
* Prints the widget's text to the default printer.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void print() {
- checkWidget();
- StyledTextPrinter.print(this);
-}
-
-/**
- * Returns a runnable that will print the widget's text
- * to the specified printer.
* <p>
- * The runnable may be run in a non-UI thread.
- * </p>
- *
- * @param printer the printer to print to
+ *
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Runnable print(Printer printer) {
- checkWidget();
- return new StyledTextPrinter(this, printer);
+public void print() {
+ checkWidget();
+ new StyledTextPrinter(this).print();
}
/**
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
index bc90308868..27e67857e7 100755
--- 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
@@ -15,7 +15,7 @@ import org.eclipse.swt.layout.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.printing.*;
-class StyledTextPrinter implements Runnable {
+class StyledTextPrinter {
class RTFState {
int fontStyle;
int foreground;
@@ -23,20 +23,17 @@ class StyledTextPrinter implements Runnable {
}
Vector savedState = new Vector();
+ StyledText styledText;
Printer printer;
GC gc;
+
String rtf;
- StringBuffer wordBuffer;
int index, end;
- String tabs = "";
- int tabWidth = 0;
- int lineHeight = 0;
- int leftMargin, rightMargin, topMargin, bottomMargin;
- int x, y;
+ 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.
+ * Fonts for the following styles: normal, bold, italic, and bold italic.
*/
Font fontTable[][] = new Font[1][4];
boolean creatingFontTable = false;
@@ -52,27 +49,19 @@ class StyledTextPrinter implements Runnable {
int currentForeground = -1;
int currentBackground = -1;
- static void print(StyledText styledText) {
- Printer printer = new Printer();
- new StyledTextPrinter(styledText, printer).run();
- printer.dispose();
- }
-
- StyledTextPrinter(StyledText styledText, Printer printer) {
- this.printer = printer;
-
- /* 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();
+ String tabs = "";
+ int lineHeight = 0;
+ int tabWidth = 0;
+ int leftMargin, rightMargin, topMargin, bottomMargin;
+ int x, y;
- /* Get RTF from the StyledText.*/
- rtf = styledText.getRtf();
+ public StyledTextPrinter(StyledText styledText) {
+ this.styledText = styledText;
}
- public void run() {
- if (printer.startJob("Printing")) {
+ 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();
@@ -81,41 +70,17 @@ class StyledTextPrinter implements Runnable {
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 printer GC and print the RTF to it. */
+ /* 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;
- printer.startPage();
- 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);
- }
- }
- if (y + lineHeight <= bottomMargin) {
- printer.endPage();
- }
+ printStyledTextRTF();
printer.endJob();
/* Cleanup */
@@ -127,6 +92,38 @@ class StyledTextPrinter implements Runnable {
((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() {
@@ -217,12 +214,12 @@ class StyledTextPrinter implements Runnable {
}
void handleControlSymbol(char c) {
- switch (c) {
- case '\\':
- case '{':
- case '}':
- parseChar(c);
- }
+ switch (c) {
+ case '\\':
+ case '{':
+ case '}':
+ parseChar(c);
+ }
}
void handleControlWord(String controlWord) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
index 4bf7a126ff..424a799cc3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
@@ -95,7 +95,6 @@ public Object getContents(Transfer transfer) {
// Pass data to transfer agent for conversion to a Java Object
// Memory is allocated here to emulate the way Drag and Drop transfers data.
TransferData transferData = new TransferData();
- /* Use the character encoding for the default locale */
byte[] bName = Converter.wcsToMbcs (null, type, false);
transferData.type = OS.XmInternAtom (xDisplay, bName, false);
transferData.pValue = OS.XtMalloc(data.length);
@@ -146,7 +145,6 @@ public void setContents(Object[] data, Transfer[] transferAgents){
for (int j = 0; j < names.length; j++) {
TransferData transferData = new TransferData();
- /* Use the character encoding for the default locale */
byte[] bName = Converter.wcsToMbcs (null, names[j], false);
transferData.type = OS.XmInternAtom (xDisplay, bName, false);
transferAgents[i].javaToNative(data[i], transferData);
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
index adfd307815..9de9048d0e 100755
--- 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
@@ -54,7 +54,6 @@ 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
- /* Use the character encoding for the default locale */
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/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
index 0786eb51db..63f1eb6159 100755
--- 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
@@ -30,19 +30,19 @@ protected void javaToNative (Object object, TransferData transferData){
return;
}
byte[] buffer = (byte[])object;
- transferData.pData = OS.malloc(buffer.length);
- OS.memmove(transferData.pData, buffer, buffer.length);
+// 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.pData == 0 || !(isSupportedType(transferData))) return null;
+ if (transferData.pValue == 0 || !(isSupportedType(transferData))) return null;
- int size = transferData.length;
- if (size == 0) return null;
+ int size = transferData.format * transferData.length / 8;
byte[] buffer = new byte[size];
- OS.memmove(buffer, transferData.pData, 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
index 217166c841..bd8b75d483 100755
--- 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
@@ -19,6 +19,7 @@ public class Clipboard {
private Display display;
private final int MAX_RETRIES = 10;
+ private int shellHandle;
public Clipboard(Display display) {
@@ -33,6 +34,11 @@ public Clipboard(Display display) {
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 ();
@@ -42,92 +48,15 @@ protected void checkSubclass () {
}
}
public void dispose () {
+// if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+// shellHandle = 0;
display = null;
}
public Object getContents(Transfer transfer) {
if (display.isDisposed() ) return null;
-
- Object result = null;
-
- int ig = OS.PhInputGroup(0);
- int cbdata = OS.PhClipboardPasteStart((short)ig);
- if (cbdata == 0) return result;
- try {
- String[] types = transfer.getTypeNames();
- int[] ids = transfer.getTypeIds();
- for (int i = 0; i < types.length; i++) {
- byte[] type = Converter.wcsToMbcs(null, types[i], true);
- int pClipHeader = OS.PhClipboardPasteType(cbdata, type);
- if (pClipHeader != 0) {
- PhClipHeader clipHeader = new PhClipHeader();
- OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
- TransferData data = new TransferData();
- data.pData = clipHeader.data;
- data.length = clipHeader.length;
- data.type = ids[i];
- result = transfer.nativeToJava(data);
- break;
- }
- }
- } finally {
- OS.PhClipboardPasteFinish(cbdata);
- }
-
- return result;
+ return null;
}
public void setContents(Object[] data, Transfer[] transferAgents){
- if (display.isDisposed() ) return;
-
- if (data == null) {
- int ig = OS.PhInputGroup(0);
- if (OS.PhClipboardCopy((short)ig, 0, null) != 0) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
- }
- return;
- }
- if (transferAgents == null || data.length != transferAgents.length) {
- DND.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- byte[] clips = new byte[0];
- int count = 0;
- for (int i = 0; i < transferAgents.length; i++) {
- String[] names = transferAgents[i].getTypeNames();
- int[] ids = transferAgents[i].getTypeIds();
- for (int j = 0; j < names.length; j++) {
- TransferData transferData = new TransferData();
- transferData.type = ids[j];
- transferAgents[i].javaToNative(data[i], transferData);
- PhClipHeader clip = new PhClipHeader();
- clip.data = transferData.pData;
- clip.length = (short)transferData.length;
- byte[] temp = Converter.wcsToMbcs(null, names[j], false);
- byte[] type = new byte[8];
- System.arraycopy(temp, 0, type, 0, Math.min(type.length, temp.length));
- clip.type_0 = type[0];
- clip.type_1 = type[1];
- clip.type_2 = type[2];
- clip.type_3 = type[3];
- clip.type_4 = type[4];
- clip.type_5 = type[5];
- clip.type_6 = type[6];
- clip.type_7 = type[7];
- byte[] buffer = new byte[PhClipHeader.sizeof];
- OS.memmove(buffer, clip, PhClipHeader.sizeof);
- byte[] newClips = new byte[clips.length + buffer.length];
- System.arraycopy(clips, 0, newClips, 0, clips.length);
- System.arraycopy(buffer, 0, newClips, clips.length, buffer.length);
- clips = newClips;
- count++;
- }
- }
-
- if (count > 0){
- int ig = OS.PhInputGroup(0);
- if (OS.PhClipboardCopy((short)ig, count, clips) != 0) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
- }
- }
}
/*
* Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
@@ -135,35 +64,31 @@ public void setContents(Object[] data, Transfer[] transferAgents){
* information.
*/
public String[] getAvailableTypeNames() {
- String[] types = new String[0];
- int ig = OS.PhInputGroup(0);
- int cbdata = OS.PhClipboardPasteStart((short)ig);
- if (cbdata == 0) return types;
- try {
- int pClipHeader = 0;
- int n = 0;
- while ((pClipHeader = OS.PhClipboardPasteTypeN(cbdata, n++)) != 0) {
- PhClipHeader clipHeader = new PhClipHeader();
- OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
- byte[] buffer = new byte[8];
- buffer[0] = clipHeader.type_0;
- buffer[1] = clipHeader.type_1;
- buffer[2] = clipHeader.type_2;
- buffer[3] = clipHeader.type_3;
- buffer[4] = clipHeader.type_4;
- buffer[5] = clipHeader.type_5;
- buffer[6] = clipHeader.type_6;
- buffer[7] = clipHeader.type_7;
- char [] unicode = Converter.mbcsToWcs (null, buffer);
-
- String[] newTypes = new String[types.length + 1];
- System.arraycopy(types, 0, newTypes, 0, types.length);
- newTypes[types.length] = new String (unicode).trim();
- types = newTypes;
- }
- } finally {
- OS.PhClipboardPasteFinish(cbdata);
- }
+ 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;
}
}
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
index f311c62182..54044a03f1 100755
--- 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
@@ -8,7 +8,7 @@ package org.eclipse.swt.dnd;
public class FileTransfer extends ByteArrayTransfer {
private static FileTransfer _instance = new FileTransfer();
- private static final String TYPENAME = "files";
+ private static final String TYPENAME = "text/uri-list\0";
private static final int TYPEID = registerType(TYPENAME);
private FileTransfer() {}
@@ -16,11 +16,46 @@ public static FileTransfer getInstance () {
return _instance;
}
public void javaToNative(Object object, TransferData transferData) {
- DND.error(org.eclipse.swt.SWT.ERROR_NOT_IMPLEMENTED);
+
+ 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) {
- DND.error(org.eclipse.swt.SWT.ERROR_NOT_IMPLEMENTED);
- return null;
+
+ 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};
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
index 4092a3fbc0..d36e6562b0 100755
--- 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
@@ -1,6 +1,5 @@
package org.eclipse.swt.dnd;
-import org.eclipse.swt.internal.Converter;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved
@@ -9,8 +8,12 @@ import org.eclipse.swt.internal.Converter;
public class RTFTransfer extends ByteArrayTransfer {
private static RTFTransfer _instance = new RTFTransfer();
- private static final String TYPENAME = "RTF";
- private static final int TYPEID = registerType(TYPENAME);
+ 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() {
}
@@ -19,21 +22,21 @@ public static RTFTransfer getInstance () {
}
public void javaToNative (Object object, TransferData transferData){
if (object == null || !(object instanceof String)) return;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, false);
- super.javaToNative(buffer, transferData);
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
}
public Object nativeToJava(TransferData transferData){
- /// get byte array from super
+ // get byte array from super
byte[] buffer = (byte[])super.nativeToJava(transferData);
if (buffer == null) return null;
// convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- return new String (unicode);
+ return new String(buffer);
}
protected String[] getTypeNames(){
- return new String[]{TYPENAME};
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
}
protected int[] getTypeIds(){
- return new int[]{TYPEID};
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
}
}
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
index 685aabce78..e6587940bc 100755
--- 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
@@ -1,8 +1,5 @@
package org.eclipse.swt.dnd;
-import org.eclipse.swt.internal.Converter;
-import org.eclipse.swt.internal.photon.OS;
-
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved
@@ -11,8 +8,12 @@ import org.eclipse.swt.internal.photon.OS;
public class TextTransfer extends ByteArrayTransfer {
private static TextTransfer _instance = new TextTransfer();
- private static final String TYPENAME = "TEXT";
- private static final int TYPEID = registerType(TYPENAME);
+ 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() {
}
@@ -21,21 +22,21 @@ public static TextTransfer getInstance () {
}
public void javaToNative (Object object, TransferData transferData){
if (object == null || !(object instanceof String)) return;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, false);
- super.javaToNative(buffer, transferData);
+
+ 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
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- return new String (unicode);
+ return new String(buffer);
}
protected String[] getTypeNames(){
- return new String[]{TYPENAME};
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
}
protected int[] getTypeIds(){
- return new int[]{TYPEID};
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
}
}
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
index 95d9283f6b..3634d3576d 100755
--- 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
@@ -13,9 +13,6 @@ abstract protected int[] getTypeIds();
abstract protected void javaToNative (Object object, TransferData transferData);
abstract protected Object nativeToJava(TransferData transferData);
public static int registerType(String formatName){
- if (formatName == "TEXT") return 10;
- if (formatName == "files") return 11;
- if (formatName == "RTF") return 12;
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
index ae75ee6293..50eabd10e9 100755
--- 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
@@ -9,7 +9,10 @@ public class TransferData {
public int type;
// attributes specific to set/get
- int pData;
int length;
+ int format;
+ int pValue;
+
int result;
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
index 63c3318a85..dd6d8e87d8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
@@ -359,7 +359,6 @@ public static String findProgramID (String extension) {
if (extension.charAt (0) != '.') extension = "." + extension;
- /* Use the character encoding for the default locale */
byte[] extensionKey = Converter.wcsToMbcs(0, extension, true);
String result = getKeyValue(extensionKey);
if (result != null) {
@@ -386,7 +385,6 @@ private static String getKeyValue (byte [] key) {
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
byte [] lpData = new byte [lpcbData [0]];
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- /* Use the character encoding for the default locale */
char[] charArray = Converter.mbcsToWcs (0, lpData);
result = new String(charArray, 0, charArray.length - 1);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
index ed6c4987c8..87d4432ebc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
@@ -199,9 +199,6 @@ static int getMsgProc(int code, int wParam, int lParam) {
if (site.handle == hwnd) {
OleFrame frame = site.frame;
if (frame.translateOleAccelerator(msg)) {
- // In order to prevent this message from also being processed
- // by the application, zero out message, wParam and lParam
- OS.MoveMemory(lParam + 4, new int[] {OS.WM_NULL, 0, 0}, 12);
return 0;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
index 8153f26afd..b3685e7048 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
@@ -77,7 +77,6 @@ public static PrinterData[] getPrinterList() {
int length = OS.strlen(address);
byte[] buffer = new byte [length];
OS.memmove(buffer, address, length);
- /* Use the character encoding for the default locale */
name = new String(Converter.mbcsToWcs(null, buffer));
}
printerList[i] = new PrinterData(Device.XDefaultPrintServer, name);
@@ -151,7 +150,6 @@ protected void init() {
super.init();
/* Create the printContext for the printer */
- /* Use the character encoding for the default locale */
byte[] name = Converter.wcsToMbcs(null, data.name, true);
printContext = OS.XpCreateContext(xDisplay, name);
if (printContext == OS.None) {
@@ -172,7 +170,6 @@ protected void init() {
OS.XtDestroyWidget(shellHandle);
/* Initialize the default font */
- /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(null, "-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*", true);
int fontListEntry = OS.XmFontListEntryLoad(xDisplay, buffer, 0, OS.XmFONTLIST_DEFAULT_TAG);
if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);
@@ -254,7 +251,6 @@ public void internal_dispose_GC(int xGC, GCData data) {
*/
public boolean startJob(String jobName) {
checkDevice();
- /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(null, "*job-name: " + jobName, true);
OS.XpSetAttributes(xDisplay, printContext, OS.XPJobAttr, buffer, OS.XPAttrMerge);
OS.XpStartJob(xDisplay, OS.XPSpool);
@@ -352,7 +348,6 @@ public void endPage() {
*/
public Point getDPI() {
checkDevice();
- /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(null, "default-printer-resolution", true);
int pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPDocAttr, buffer);
int length = OS.strlen(pool);
@@ -363,7 +358,6 @@ public Point getDPI() {
int res = 300; // default
if (resolution.length() == 0) {
/* If we can't get the info from the DocAttrs, ask the printer. */
- /* Use the character encoding for the default locale */
buffer = Converter.wcsToMbcs(null, "printer-resolutions-supported", true);
pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPPrinterAttr, buffer);
length = OS.strlen(pool);
@@ -463,12 +457,14 @@ public Rectangle computeTrim(int x, int y, int width, int height) {
return new Rectangle(x - rect.x, y - rect.y, width + hTrim, height + vTrim);
}
-/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
- */
+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however,
+ * a <code>Font</code> object <em>may</em> be composed of multiple X
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ */
public PrinterData getPrinterData() {
return data;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
index 9e19c3c43a..5e4b1952e0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
@@ -79,12 +79,6 @@ public Rectangle computeTrim(int x, int y, int width, int height) {
return new Rectangle(0,0,0,0);
}
-/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
- */
public PrinterData getPrinterData() {
return data;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
index a59c5d6b84..4554b3c30f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
@@ -186,7 +186,6 @@ public Printer(PrinterData data) {
*/
protected void create(DeviceData deviceData) {
data = (PrinterData)deviceData;
- /* Use the character encoding for the default locale */
byte[] driver = Converter.wcsToMbcs(0, data.driver, true);
byte[] device = Converter.wcsToMbcs(0, data.name, true);
int lpInitData = 0;
@@ -273,7 +272,6 @@ public boolean startJob(String jobName) {
int hHeap = OS.GetProcessHeap();
int lpszDocName = 0;
if (jobName != null && jobName.length() != 0) {
- /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(0, jobName, true);
lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
OS.MoveMemory(lpszDocName, buffer, buffer.length);
@@ -281,7 +279,6 @@ public boolean startJob(String jobName) {
}
int lpszOutput = 0;
if (data.printToFile && data.fileName != null) {
- /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(0, data.fileName, true);
lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
OS.MoveMemory(lpszOutput, buffer, buffer.length);
@@ -462,10 +459,12 @@ public Rectangle computeTrim(int x, int y, int width, int height) {
}
/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however,
+ * a <code>Font</code> object <em>may</em> be composed of multiple X
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
*/
public PrinterData getPrinterData() {
return data;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
index 5f58b97556..52f5f9b5f4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
@@ -1,1065 +1,700 @@
-package org.eclipse.swt.program;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-import org.eclipse.swt.widgets.Display;
-
-import java.io.*;
-import java.util.Iterator;
-import java.util.Hashtable;
-import java.util.Vector;
-
+package org.eclipse.swt.program;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+import org.eclipse.swt.widgets.Display;
+
+import java.io.*;
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.Vector;
+
/**
* Instances of this class represent programs and
* their assoicated file extensions in the operating
* system.
- */
-public final class Program {
- String name;
- String extension;
- String command;
- Display display;
-
- static private final String cdeShell = "Program_CDE_SHELL"; // hidden shell used for DtAppInitialize and DtActionInvoke
- static private final String[] cdeIconExt = { ".m.pm", ".l.pm", ".s.pm", ".t.pm" };
- static private final String[] cdeMaskExt = { ".m_m.bm", ".l_m.bm", ".s_m.bm", ".t_m.bm" };
- static private final String desktopData = "Program_DESKTOP";
-
- static final int DESKTOP_UNKNOWN = 0;
- static final int DESKTOP_KDE = 1;
- static final int DESKTOP_GNOME = 2;
- static final int DESKTOP_CDE = 3;
-
-/**
- * Prevents uninitialized instances from being created outside the package.
- */
-Program () {
-}
-
-/* Determine the desktop for the given display. */
-static int getDesktop( Display display ) {
- if (display == null) return DESKTOP_UNKNOWN;
-
- // If the desktop type for this display is already known, return it.
- Integer desktopValue = (Integer) display.getData( desktopData );
- if (desktopValue != null) {
- return desktopValue.intValue();
- }
-
- // Obtain the atoms for the various window manager signature properties.
- int desktop = DESKTOP_UNKNOWN;
- int xDisplay = display.xDisplay;
- /* Use the character encoding for the default locale */
- byte[] gnomeName = Converter.wcsToMbcs (null, "GNOME_NAME_SERVER", true);
- byte[] cdeName = Converter.wcsToMbcs (null, "DTWM_IS_RUNNING", true);
- byte[] kdeName = Converter.wcsToMbcs (null, "KWIN_RUNNING", true);
- int gnome = OS.XInternAtom( xDisplay, gnomeName, true );
- int cde = OS.XInternAtom( xDisplay, cdeName, true );
- int kde = OS.XInternAtom( xDisplay, kdeName, true );
-
- // Get the list of properties on the root window.
- int rootWindow = OS.XDefaultRootWindow( xDisplay );
- int[] numProp = new int[1];
- int propList = OS.XListProperties( xDisplay, rootWindow, numProp );
- if (propList == 0) return DESKTOP_UNKNOWN;
- int[] property = new int[ numProp[0] ];
- OS.memmove( property, propList, (property.length * 4) );
- OS.XFree( propList );
-
- // A given WM (desktop) is active if the property exists on the root window.
- for (int index = 0; desktop == DESKTOP_UNKNOWN && index < property.length; index++) {
- if (property[ index ] == OS.None) continue; // do not match atoms that do not exist
- if (property[ index ] == gnome) {
- if (gnome_init()) desktop = DESKTOP_GNOME;
- }
- if (property[ index ] == cde) {
- if (cde_init( display )) desktop = DESKTOP_CDE;
- }
- if (property[ index ] == kde) {
- if (kde_init()) desktop = DESKTOP_KDE;
- }
- }
-
- // Save the desktop type on the display itself.
- display.setData( desktopData, new Integer(desktop) );
- return desktop;
-}
-
-/**
- * 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 <ul>
- * <li>ERROR_NULL_ARGUMENT when extension is null</li>
- * </ul>
- */
-public static Program findProgram (String extension) {
- return findProgram( Display.getCurrent(), extension );
-}
-
-/*
- * API: When support for multiple displays is added, this method will
- * become public and the original method above can be deprecated.
- */
-private static Program findProgram( Display display, String extension ) {
- if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (extension.length () == 0) return null;
- if (extension.charAt (0) != '.') extension = "." + extension;
- String command = null;
- String name = null;
- int desktop = getDesktop( display );
- Hashtable mimeInfo = null;
- if (desktop == DESKTOP_KDE) mimeInfo = kde_getMimeInfo();
- if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
- if (desktop == DESKTOP_CDE) mimeInfo = cde_getDataTypeInfo();
- if (mimeInfo == null) return null;
-
- // Find the data type matching the extension.
- Iterator keys = mimeInfo.keySet().iterator();
- while (name == null && keys.hasNext()) {
- String mimeType = (String) keys.next();
- Vector mimeExts = (Vector) mimeInfo.get( mimeType );
- for (int index = 0; index < mimeExts.size(); index++){
- if (extension.equals( mimeExts.elementAt( index ) )) {
- name = mimeType;
- }
- }
- }
- if (name == null) return null;
-
- // Get the corresponding command for the mime type.
- if (desktop == DESKTOP_KDE) command = kde_getMimeTypeCommand( name );
- if (desktop == DESKTOP_GNOME) command = gnome_getMimeValue( name, "open" );
- if (desktop == DESKTOP_CDE) command = cde_getAction( name );
- if (command == null) return null;
-
- // Return the corresponding program.
- Program program = new Program ();
- program.name = name;
- program.command = command;
- program.extension = extension;
- program.display = display;
- return program;
-}
-
-/**
- * Answer all program extensions in the operating system.
- *
- * @return an array of extensions
- */
-public static String [] getExtensions () {
- return getExtensions( Display.getCurrent() );
-}
-
-/*
- * API: When support for multiple displays is added, this method will
- * become public and the original method above can be deprecated.
- */
-private static String[] getExtensions( Display display ) {
- int desktop = getDesktop( display );
- Hashtable mimeInfo = null;
- if (desktop == DESKTOP_KDE) mimeInfo = kde_getMimeInfo();
- if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
- if (desktop == DESKTOP_CDE) mimeInfo = cde_getDataTypeInfo();
- if (mimeInfo == null) return new String[0];
-
-
- // Create a unique set of the file extensions.
- Vector extensions = new Vector();
- Iterator keys = mimeInfo.keySet().iterator();
- while (keys.hasNext()) {
- String mimeType = (String) keys.next();
- Vector mimeExts = (Vector) mimeInfo.get( mimeType );
- for (int index = 0; index < mimeExts.size(); index++){
- if (!extensions.contains( mimeExts.elementAt( index ) )) {
- extensions.add( mimeExts.elementAt( index ) );
- }
- }
- }
-
- // Return the list of extensions.
- String[] extStrings = new String[ extensions.size() ];
- for (int index = 0; index < extensions.size(); index++) {
- extStrings[ index ] = (String) extensions.elementAt( index );
- }
- return extStrings;
-}
-
-/**
- * Answers all available programs in the operating system.
- *
- * @return an array of programs
- */
-public static Program [] getPrograms () {
- return getPrograms( Display.getCurrent() );
-}
-
-/*
- * API: When support for multiple displays is added, this method will
- * become public and the original method above can be deprecated.
- */
-private static Program[] getPrograms( Display display ) {
- int desktop = getDesktop( display );
- Hashtable mimeInfo = null;
- if (desktop == DESKTOP_KDE) mimeInfo = kde_getMimeInfo();
- if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
- if (desktop == DESKTOP_CDE) mimeInfo = cde_getDataTypeInfo();
- if (mimeInfo == null) return new Program[0];
-
- // Create a list of programs with commands.
- Vector programs = new Vector();
- Iterator keys = mimeInfo.keySet().iterator();
- while (keys.hasNext()) {
- String mimeType = (String) keys.next();
- Vector mimeExts = (Vector) mimeInfo.get( mimeType );
- String extension = "";
- if (mimeExts.size() > 0){
- extension = (String) mimeExts.elementAt( 0 );
- }
- String command = null;
- if (desktop == DESKTOP_KDE) command = kde_getMimeTypeCommand( mimeType );
- if (desktop == DESKTOP_GNOME) command = gnome_getMimeValue( mimeType, "open" );
- if (desktop == DESKTOP_CDE) command = cde_getAction( mimeType );
- if (command != null) {
- Program program = new Program ();
- program.name = mimeType;
- program.command = command;
- program.extension = extension;
- program.display = display;
- programs.add( program );
- }
- }
-
- // Return the list of programs to the user.
- Program[] programList = new Program[ programs.size() ];
- for (int index = 0; index < programList.length; index++) {
- programList[ index ] = (Program) programs.elementAt( index );
- }
- return programList;
-}
-
-/*
- * Obtain the registered mime type information and
- * return it in a map. The key of each entry
- * in the map is the mime type name. The value is
- * a vector of the associated file extensions.
- */
-
-private static Hashtable gnome_getMimeInfo() {
- Hashtable mimeInfo = new Hashtable();
-
- // Extract the mime info from the system directory.
- String mimeDirectory = gnome_getDataDirectory ("mime-info");
- gnome_getMimeInfoFromDirectory( mimeInfo, new File( mimeDirectory ) );
-
- // Append the mime info from the user's directory (if it exists).
- String userDirectory = gnome_getHomeDirectory();
- if (userDirectory != null) {
- userDirectory = userDirectory + File.separator + ".gnome" + File.separator + "mime-info";
- gnome_getMimeInfoFromDirectory( mimeInfo, new File( userDirectory ) );
- }
-
- return mimeInfo;
-}
-
-// Given a map and a directory, find all of the
-// mime information files (*.mime) and parse them for
-// relavent mime type information. Each entry in the
-// map corresponds to one mime type, and its
-// associated file extensions.
-
-private static void gnome_getMimeInfoFromDirectory( Hashtable info, File directory ) {
- // For each entry in the given directory (if it exists)
- if (directory.exists()) {
- File[] files = directory.listFiles();
- for (int i = 0; i < files.length; i++) {
-
- // If the entry is a subdirectory, process it and
- // merge the mime type into the given map.
- if (files[i].isDirectory()) {
- gnome_getMimeInfoFromDirectory( info, files[i] );
- }
-
- // else if the entry is a mime info file (*.mime)
- else if (files[i].getName().endsWith(".mime")) {
- try {
- // Parse the mime file and merge the info
- // into the given map.
- FileReader in = new FileReader( files[i] );
- BufferedReader reader = new BufferedReader( in );
- gnome_parseMimeFile( info, reader );
- reader.close();
- in.close();
- }
- catch (IOException e) {
- // Ignore file exceptions silently. If we
- // can't read it, the info is not available.
- }
- }
- }
- }
-}
-
-private static void gnome_parseMimeFile( Hashtable info, BufferedReader reader ) {
- Vector mimeExts = null;
- String mimeType = null;
- boolean saveType = false;
- String line = "#";
- while (line != null) {
-
- // Determine if the line contains a mime type name.
- boolean newType = (line.length() > 0 && Character.isLetter( line.charAt(0) ));
-
- // If there is valid data on this line to be processed
- String data = line.trim();
- if (data.length() > 0 && data.charAt(0) != '#') {
-
- // If this line defines a new mime type
- if (newType) {
-
- // If a previous mime type has not be saved yet
- if (mimeType != null) {
- // Save the type and process this line again.
- saveType = true;
- }
- // else initialize the mime type info
- else {
- int colon = data.indexOf( ':' );
- if (colon != -1) {
- mimeType = data.substring( 0, colon );
- }
- else {
- mimeType = data;
- }
- mimeExts = new Vector();
- }
- }
-
- // else if the line defines a list of extensions
- else if (data.indexOf( "ext" ) == 0 && mimeType != null) {
-
- // Get the extensions defined on the line
- String exts = "";
- int colon = data.indexOf( ':' );
- if ((colon != -1) && ((colon+1) < data.length())) {
- exts = data.substring( (colon+1) ).trim();
- }
-
- // While there are extensions to be processed (use space as separator)
- exts = exts.replace( '\t', ' ' );
- exts = exts.replace( ',', ' ' );
- while (exts.length() != 0) {
- // Extract the next entension from the list
- String newExt;
- int space = exts.indexOf( ' ' );
- if (space != -1) {
- newExt = exts.substring( 0, space );
- exts = exts.substring( space ).trim();
- }
- else {
- newExt = exts;
- exts = "";
- }
-
- // Prefix an extension with a period.
- if (newExt.charAt(0) != '.') {
- newExt = "." + newExt;
- }
- mimeExts.add( newExt );
- }
- }
-
- // else if the line defines a list of regular expressions
- else if (data.indexOf( "regex" ) == 0 && mimeType != null) {
- // Do nothing with these right now.
- }
- }
-
-
- // If the current mime type is still being processed
- if (!saveType) {
- // Get the next line
- try {
- line = reader.readLine();
- }
- catch (IOException e) {
- line = null;
- }
- }
-
- // If the current type should be saved or if the end
- // of the file was reached
- if (saveType || (line == null)) {
- // If there is a mime type to be saved
- if (mimeType != null) {
-
- // If the mime type does not exist in the map, add it.
- Vector prevExts = (Vector) info.get( mimeType );
- if (prevExts == null) {
- info.put( mimeType, mimeExts );
- }
-
- // else append the new list of extensions.
- else {
- for (int i = 0; i < mimeExts.size(); i++) {
- prevExts.add( mimeExts.elementAt( i ) );
- }
- }
- }
- mimeType = null;
- mimeExts = null;
- saveType = false;
- }
- }
-}
-
-// Private method for parsing a command line into its arguments.
-private static String[] parseCommand( String cmd ) {
- Vector args = new Vector();
- int sIndex = 0;
- int eIndex;
- while (sIndex < cmd.length()) {
- // Trim initial white space of argument.
- while (sIndex < cmd.length() && Character.isWhitespace( cmd.charAt(sIndex) )) {
- sIndex++;
- }
- if (sIndex < cmd.length()) {
- // If the command is a quoted string
- if (cmd.charAt(sIndex) == '"' || cmd.charAt(sIndex) == '\''){
- // Find the terminating quote (or end of line).
- // This code currently does not handle escaped characters (e.g., " a\"b").
- eIndex = sIndex + 1;
- while (eIndex < cmd.length() && cmd.charAt(eIndex) != cmd.charAt(sIndex)) {
- eIndex++;
- }
- if (eIndex >= cmd.length()) { // the terminating quote was not found
- // Add the argument as is with only one initial quote.
- args.add( cmd.substring( sIndex, eIndex ) );
- }
- // else add the argument, trimming off the quotes.
- else {
- args.add( cmd.substring( sIndex+1, eIndex ) );
- }
- sIndex = eIndex + 1;
- }
-
- // else use white space for the delimiters.
- else {
- eIndex = sIndex;
- while (eIndex < cmd.length() && !Character.isWhitespace( cmd.charAt(eIndex) )) {
- eIndex++;
- }
- args.add( cmd.substring( sIndex, eIndex ) );
- sIndex = eIndex + 1;
- }
- }
- }
-
- String[] strings = new String[ args.size() ];
- for (int index =0; index < args.size(); index++) {
- strings[ index ] = (String) args.elementAt( index );
- }
- return strings;
-}
-
-
-static String gnome_getDataDirectory(String dirName) {
- /* Use the character encoding for the default locale */
- byte [] nameBuffer = Converter.wcsToMbcs (null, dirName, true);
- int ptr = GNOME.gnome_datadir_file(nameBuffer);
- if (ptr == 0) return null;
- int length = OS.strlen(ptr);
- byte[] dirBuffer = new byte[length];
- OS.memmove(dirBuffer, ptr, length);
- /* Use the character encoding for the default locale */
- return new String(Converter.mbcsToWcs(null, dirBuffer));
-}
-
-static String gnome_getHomeDirectory() {
- int ptr = GNOME.g_get_home_dir();
- if (ptr == 0) return null;
- int length = OS.strlen(ptr);
- byte[] homeDirBuffer = new byte[length];
- OS.memmove(homeDirBuffer, ptr, length);
- /* Use the character encoding for the default locale */
- return new String(Converter.mbcsToWcs(null, homeDirBuffer));
-}
-
-static String gnome_getMimeType(String name) {
- /* Use the character encoding for the default locale */
- byte [] nameBuffer = Converter.wcsToMbcs (null, name, true);
- int ptr = GNOME.gnome_mime_type(nameBuffer);
- if (ptr == 0) return null;
- int length = OS.strlen(ptr);
- byte[] mimeBuffer = new byte[length];
- OS.memmove(mimeBuffer, ptr, length);
- /* Use the character encoding for the default locale */
- return new String(Converter.mbcsToWcs(null, mimeBuffer));
-}
-
-static String gnome_getMimeValue(String mimeType, String key) {
- /* Use the character encoding for the default locale */
- byte [] typeBuffer = Converter.wcsToMbcs (null, mimeType, true);
- byte [] keyBuffer = Converter.wcsToMbcs (null, key, true);
- int ptr = GNOME.gnome_mime_get_value(typeBuffer, keyBuffer);
- if (ptr == 0) return null;
-
- StringBuffer stringBuffer = new StringBuffer();
- int length = OS.strlen(ptr);
- byte[] valueBuffer = new byte[length];
- OS.memmove(valueBuffer, ptr, length);
- /* Use the character encoding for the default locale */
- return new String(Converter.mbcsToWcs(null, valueBuffer));
-}
-
-static boolean kde_init () {
- try {
- Callback.loadLibrary("swt-kde");
- } catch (UnsatisfiedLinkError e) {
- return false;
- }
-
- /* Use the character encoding for the default locale */
- byte [] nameBuffer = Converter.wcsToMbcs( null, "SWT", true );
- int qcString = KDE.QCString_new( nameBuffer );
- KDE.KApplication_new( qcString );
- KDE.QCString_delete( qcString );
- return true;
-}
-
-private static String kde_getMimeTypeCommand( String mimeType ) {
- /* Use the character encoding for the default locale */
- byte [] buffer = Converter.wcsToMbcs (null, mimeType, true);
- int qMimeType = KDE.QString_new( buffer );
- int serviceList = KDE.KMimeType_offers( qMimeType );
- KDE.QString_delete( qMimeType );
- if (serviceList == 0) return null;
- KDE.KServiceList_delete( serviceList );
- return "KRun::runURL(url,mimeType)";
-}
-/*
- * Obtain the registered mime type information and
- * return it in a map. The key of each entry
- * in the map is the mime type name. The value is
- * a vector of the associated file extensions.
- */
-
-private static Hashtable kde_getMimeInfo() {
- Hashtable mimeInfo = new Hashtable();
- Vector mimeExts = null;
- String mimeType;
-
- // Get the list of all mime types available.
- int mimeTypeList = KDE.KMimeType_allMimeTypes();
- int iterator = KDE.KMimeTypeList_begin( mimeTypeList );
- int listEnd = KDE.KMimeTypeList_end( mimeTypeList );
- while (KDE.KMimeTypeListIterator_equals( iterator, listEnd ) == 0) {
- // Get the next KMimeType from the list.
- int kMimeType = KDE.KMimeTypeListIterator_dereference( iterator );
-
- // Get the mime type name.
- int mimeName = KDE.KMimeType_name( kMimeType );
- mimeType = kde_convertQStringAndFree( mimeName );
-
- // Get the list of extension patterns.
- mimeExts = new Vector();
- String extension;
-
- // Add the mime type to the hash table with its extensions.
- int patternList = KDE.KMimeType_patterns( kMimeType );
- int patIterator = KDE.QStringList_begin( patternList );
- int patListEnd = KDE.QStringList_end( patternList );
- while (KDE.QStringListIterator_equals( patIterator, patListEnd ) == 0) {
- // Get the next extension pattern from the list.
- int patString = KDE.QStringListIterator_dereference( patIterator );
- extension = kde_convertQStringAndFree( patString );
- int period = extension.indexOf( '.' );
- if (period != -1) {
- mimeExts.add( extension.substring( period ) );
- }
-
- // Advance to the next pattern.
- KDE.QStringListIterator_increment( patIterator );
- }
- KDE.QStringListIterator_delete( patIterator );
- KDE.QStringListIterator_delete( patListEnd );
- KDE.QStringList_delete( patternList );
-
- // If there is at least one extension, save the mime type.
- if (mimeExts.size() > 0) {
- mimeInfo.put( mimeType, mimeExts );
- }
-
- // Advance to the next mime type.
- KDE.KMimeTypeListIterator_increment( iterator );
- }
- KDE.KMimeTypeListIterator_delete( iterator );
- KDE.KMimeTypeListIterator_delete( listEnd );
- KDE.KMimeTypeList_delete( mimeTypeList );
-
- return mimeInfo;
-}
-
-static String kde_convertQStringAndFree (int qString) {
- int qCString = KDE.QString_utf8 (qString);
- int charString = KDE.QCString_data (qCString);
-
- StringBuffer stringBuffer = new StringBuffer ();
- int length = KDE.strlen (charString);
- byte[] buffer = new byte [length];
- KDE.memmove (buffer, charString, length);
- /* Use the character encoding for the default locale */
- String answer = new String (Converter.mbcsToWcs (null, buffer));
-
- KDE.QCString_delete (qCString);
- KDE.QString_delete (qString);
- return answer;
-}
-
-/**
- * Launches the executable associated with the file in
- * the operating system. If the file is an executable,
- * then the executable is launched.
- *
- * @param fileName the file or program name
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- *
- * @exception SWTError <ul>
- * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
- * </ul>
- */
-public static boolean launch (String fileName) {
- return launch( Display.getCurrent(), fileName );
-}
-
-/*
- * API: When support for multiple displays is added, this method will
- * become public and the original method above can be deprecated.
- */
-private static boolean launch( Display display, String fileName ) {
- if (fileName == null) SWT.error( SWT.ERROR_NULL_ARGUMENT );
-
- // If the argument appears to be a data file (it has an extension)
- int index = fileName.lastIndexOf(".");
- if (index > 0) {
-
- // Find the associated program, if one is defined.
- String extension = fileName.substring( index );
- Program program = Program.findProgram( display, extension );
-
- // If the associated program is defined and can be executed, return.
- if (program != null && program.execute( fileName )) return true;
- }
-
- // Otherwise, the argument was the program itself.
- try {
- Runtime.getRuntime().exec( fileName );
- return true;
- } catch (IOException e) {
- return false;
- }
-}
-
-/**
- * Executes the program with the file as the single argument
- * in the operating system. It is the responsibility of the
- * programmer to ensure that the file contains valid data for
- * this program.
- *
- * @param fileName is the argument (typically a file) for the program
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- *
- * @exception SWTError <ul>
- * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
- * </ul>
- */
-public boolean execute (String fileName) {
- if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- switch (getDesktop( display )) {
- case DESKTOP_KDE: {
- String urlString = "file://" + fileName;
- /* Use the character encoding for the default locale */
- byte[] buffer = Converter.wcsToMbcs( null, urlString, true );
- int qString = KDE.QString_new( buffer );
- int url = KDE.KURL_new( qString );
- KDE.QString_delete( qString );
- /* Use the character encoding for the default locale */
- buffer = Converter.wcsToMbcs (null, name, true);
- int mimeTypeName = KDE.QString_new( buffer );
- int pid = KDE.KRun_runURL( url, mimeTypeName );
- KDE.KURL_delete( url );
- KDE.QString_delete( mimeTypeName );
- return (pid != 0);
- }
-
- case DESKTOP_GNOME: {
- // Parse the command into its individual arguments.
- String[] args = parseCommand( command );
- int fileArg = -1;
- int index;
- for (index=0; index < args.length; index++) {
- int j = args[ index ].indexOf( "%f" );
- if (j != -1) {
- String value = args[ index ];
- fileArg = index;
- args[ index ] = value.substring(0,j) + fileName + value.substring(j+2);
- }
- }
-
- // If a file name was given but the command did not have "%f"
- if ((fileName.length() > 0) && (fileArg < 0)) {
- String[] newArgs = new String[ args.length + 1 ];
- for (index=0; index < args.length; index++)
- newArgs[ index ] = args[ index ];
- newArgs[ args.length ] = fileName;
- args = newArgs;
- }
-
- // Execute the command.
- try {
- Runtime.getRuntime().exec( args );
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- case DESKTOP_CDE: {
- /* Use the character encoding for the default locale */
- byte[] action = Converter.wcsToMbcs( null, command, true );
- byte[] fileArg = Converter.wcsToMbcs( null, fileName, true );
- Integer shell = (Integer) display.getData( cdeShell );
- int actionID = 0;
- if (shell != null) {
- actionID = CDE.DtActionInvoke( shell.intValue(), action, fileArg, 1, null, null, null, 1, 0, 0 );
- }
- return (actionID != 0);
- }
- }
-
- return false;
-}
-
-/**
- * Returns the receiver's image data. This is the icon
- * that is associated with the reciever in the operating
- * system.
- *
- * @return the image data for the program, may be null
- */
-public ImageData getImageData () {
- String iconPath = null;
- switch (getDesktop( display )) {
- case DESKTOP_KDE: {
- /* Use the character encoding for the default locale */
- byte [] buffer = Converter.wcsToMbcs (null, name, true);
- int mimeTypeName = KDE.QString_new( buffer );
- int mimeType = KDE.KMimeType_mimeType( mimeTypeName );
- KDE.QString_delete( mimeTypeName );
- if (mimeType == 0) return null;
- int mimeIcon = KDE.KMimeType_icon(mimeType, 0, 0);
- int loader = KDE.KGlobal_iconLoader();
- int path = KDE.KIconLoader_iconPath(loader, mimeIcon, KDE.KICON_SMALL, 1);
- if (path == 0) return null;
- iconPath = kde_convertQStringAndFree(path);
- break;
- }
-
- case DESKTOP_GNOME: {
- String fakeFileName = "file" + extension;
- String mime = gnome_getMimeType(fakeFileName);
- if (mime == null) return null;
- iconPath = gnome_getMimeValue(mime, "icon-filename");
- if (iconPath == null) return null;
- break;
- }
-
- case DESKTOP_CDE: {
- return cde_getImageData();
- }
-
- case DESKTOP_UNKNOWN: {
- return null;
- }
- }
- if (iconPath.endsWith ("xpm")) {
- int xDisplay = display.xDisplay;
- int screen = OS.XDefaultScreenOfDisplay( xDisplay );
- int fgPixel = OS.XWhitePixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
- int bgPixel = OS.XBlackPixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
- /* Use the character encoding for the default locale */
- byte [] iconName = Converter.wcsToMbcs (null, iconPath, true);
- int pixmap = OS.XmGetPixmap( screen, iconName, fgPixel, bgPixel );
- if (pixmap == OS.XmUNSPECIFIED_PIXMAP) return null;
- Image image = Image.motif_new (display, SWT.BITMAP, pixmap, 0);
- ImageData imageData = image.getImageData ();
-
- // The pixmap returned from XmGetPixmap is cached by Motif
- // and must be deleted by XmDestroyPixmap. Because it cannot
- // be deleted directly by XFreePixmap, image.dispose() must not
- // be called. The following code should do an equivalent image.dispose().
- OS.XmDestroyPixmap( screen, pixmap );
- return imageData;
- }
- try {
- return new ImageData (iconPath);
- } catch (Exception e) {
- return null;
- }
-}
-
-/**
- * Returns the receiver's name. This is as short and
- * descriptive a name as possible for the program. If
- * the program has no descriptive name, this string may
- * be the executable name, path or empty.
- *
- * @return an the name of the program
- */
-public String getName () {
- return name;
-}
-
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- *
- * @return true if the programs are the same
- */
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return display == program.display && extension.equals(program.extension) &&
- name.equals(program.name) && command.equals(program.command);
- }
- return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- *
- * @return a hash code
- */
-public int hashCode() {
- return extension.hashCode() ^ name.hashCode() ^ command.hashCode() ^ display.hashCode();
-}
-
-public String toString () {
- return "Program {" + name + "}";
-}
-static boolean gnome_init () {
- try {
- Callback.loadLibrary("swt-gnome");
- } catch (UnsatisfiedLinkError e) {
- return false;
- }
- return true;
-}
-
-/* CDE - Get Attribute Value
- *
- * This method takes a data type name and an attribute name, and returns
- * the corresponding attribute value.
- */
-
-static String cde_getAttribute(String dataType, String attrName) {
- /* Use the character encoding for the default locale */
- byte [] dataTypeBuf = Converter.wcsToMbcs (null, dataType, true);
- byte [] attrNameBuf = Converter.wcsToMbcs (null, attrName, true);
- byte [] optNameBuf = null;
- int attrValue = CDE.DtDtsDataTypeToAttributeValue( dataTypeBuf, attrNameBuf, optNameBuf );
- if (attrValue == 0) return null;
- int length = OS.strlen(attrValue);
- byte[] attrValueBuf = new byte[length];
- OS.memmove(attrValueBuf, attrValue, length);
- CDE.DtDtsFreeAttributeValue( attrValue );
- /* Use the character encoding for the default locale */
- return new String(Converter.mbcsToWcs(null, attrValueBuf));
-}
-
-/* CDE - Get Default Action of Data Type
- *
- * This method takes a data type and returns the corresponding default action.
- * By default, the "Open" action is used if it is available. If it is not
- * available, the first action in the list is used. Typically, if Open is not
- * available, there is usually only one action anyways.
- */
-
-static String cde_getAction(String dataType) {
- String action = null;
- String actions = cde_getAttribute( dataType, CDE.DtDTS_DA_ACTION_LIST );
- if (actions != null) {
- int index = actions.indexOf( "Open" );
- if (index != -1) {
- action = actions.substring( index, index+4 );
- }
- else {
- index = actions.indexOf( "," );
- if (index != -1) {
- action = actions.substring( 0, index );
- }
- else {
- action = actions;
- }
- }
- }
- return action;
-}
-
-/* CDE - Get Extension of Data Type
- *
- * This method takes a data type and returns the corresponding extension.
- * The extension is obtained from the NAME TEMPLATE attribute.
- */
-
-static String cde_getExtension(String dataType) {
- String fileExt = cde_getAttribute( dataType, CDE.DtDTS_DA_NAME_TEMPLATE );
- if (fileExt == null || fileExt.indexOf( "%s." ) == -1) return null;
- int dot = fileExt.indexOf( "." );
- return fileExt.substring( dot );
-}
-
-/* CDE - Get Data Types
- *
- * This method returns the list of data type names available.
- * Each data type returned is valid, meaning it has an action and
- * an extension.
- */
-
-static Hashtable cde_getDataTypeInfo() {
- Hashtable dataTypeInfo = new Hashtable();
- int index;
- int dataTypeList = CDE.DtDtsDataTypeNames();
- if (dataTypeList != 0) {
- // For each data type name in the list
- index = 0;
- int dataType = CDE.listElementAt( dataTypeList, index++ );
- while (dataType != 0) {
- int length = OS.strlen(dataType);
- byte[] dataTypeBuf = new byte[length];
- OS.memmove(dataTypeBuf, dataType, length);
- /* Use the character encoding for the default locale */
- String dataTypeName = new String(Converter.mbcsToWcs(null, dataTypeBuf));
-
- // The data type is valid if it is not an action, and it has an extension and an action.
- String extension = cde_getExtension( dataTypeName );
- if (!CDE.DtDtsDataTypeIsAction( dataTypeBuf ) &&
- extension != null && cde_getAction( dataTypeName ) != null) {
- Vector exts = new Vector();
- exts.add( extension );
- dataTypeInfo.put( dataTypeName, exts );
- }
- dataType = CDE.listElementAt( dataTypeList, index++ );
- }
- CDE.DtDtsFreeDataTypeNames( dataTypeList );
- }
-
- return dataTypeInfo;
-}
-
-/* CDE - Get Image Data
- *
- * This method returns the image data of the icon associated with
- * the data type. Since CDE supports multiple sizes of icons, several
- * attempts are made to locate an icon of the desired size and format.
- * CDE supports the sizes: tiny, small, medium and large. The best
- * search order is medium, large, small and then tiny. Althoug CDE supports
- * colour and monochrome bitmaps, only colour icons are tried. (The order is
- * defined by the cdeIconExt and cdeMaskExt arrays above.)
- */
-
-ImageData cde_getImageData() {
- int xDisplay = display.xDisplay;
- int screen = OS.XDefaultScreenOfDisplay( xDisplay );
- int fgPixel = OS.XWhitePixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
- int bgPixel = OS.XBlackPixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
-
- String icon = cde_getAttribute( name, CDE.DtDTS_DA_ICON );
- byte [] iconName;
- byte [] maskName = null;
- int pixmap = 0;
- for (int index = 0; index < cdeIconExt.length && pixmap == 0; index++) {
- /* Use the character encoding for the default locale */
- iconName = Converter.wcsToMbcs (null, icon + cdeIconExt[ index ], true);
- maskName = Converter.wcsToMbcs (null, icon + cdeMaskExt[ index ], true);
- pixmap = OS.XmGetPixmap( screen, iconName, fgPixel, bgPixel );
- if (pixmap == OS.XmUNSPECIFIED_PIXMAP) pixmap = 0;
- }
-
- if (pixmap != 0) {
- int type = SWT.ICON;
- // When creating the mask pixmap, do not use the screen's white and black
- // pixel for the foreground and background respectively, because on some
- // X servers (e.g., Solaris) pixel 0 is white and pixel 1 is black. Passing
- // (screen, name, whitePixel, blackPixel, 1) to get the mask pixmap will
- // result in an inverted mask. Instead explicitly use 1 (FG) and 0 (BG).
- int mask = OS.XmGetPixmapByDepth( screen, maskName, 1, 0, 1 );
- if (mask == OS.XmUNSPECIFIED_PIXMAP) {
- type = SWT.BITMAP;
- mask = 0;
- }
- Image image = Image.motif_new (display, type, pixmap, mask );
- ImageData imageData = image.getImageData();
-
- // The pixmaps returned from XmGetPixmap... are cached by Motif
- // and must be deleted by XmDestroyPixmap. Because they cannot
- // be deleted directly by XFreePixmap, image.dispose() must not
- // be called. The following code should do an equivalent image.dispose().
- OS.XmDestroyPixmap( screen, pixmap );
- if (mask != 0) OS.XmDestroyPixmap( screen, mask );
- return imageData;
- }
- return null;
-}
-
-/* CDE - Initialize
- *
- * This method loads the swt-cde library and initializes CDE itself.
- * The shell created fo DtAppInitialize is kept for DtActionInvoke calls.
- */
-static boolean cde_init( Display display ) {
- try {
- Callback.loadLibrary("swt-cde");
- } catch (UnsatisfiedLinkError e) {
- return false;
- }
-
- /* Use the character encoding for the default locale */
- byte[] appName = Converter.wcsToMbcs( null, "SWT", true );
- int xtContext = OS.XtDisplayToApplicationContext( display.xDisplay );
- int widgetClass = OS.TopLevelShellWidgetClass();
- int shell = OS.XtAppCreateShell( appName, appName, widgetClass, display.xDisplay, null, 0 );
- boolean initOK = CDE.DtAppInitialize( xtContext, display.xDisplay, shell, appName, appName );
- if (!initOK) {
- OS.XtDestroyWidget( shell );
- }
- else {
- CDE.DtDbLoad();
- display.setData( cdeShell, new Integer(shell) );
- display.disposeExec( new Runnable() {
- public void run() {
- // This logic assumes that when the corresponding display is
- // being disposed, it must be the current one.
- Integer shell = (Integer) Display.getCurrent().getData( cdeShell );
- if (shell != null) {
- OS.XtDestroyWidget( shell.intValue() );
- }
- }
- });
- }
- return initOK;
-}
-}
+ */
+public final class Program {
+ String name;
+ String extension;
+ String command;
+
+ static final int DESKTOP_UNKNOWN = 0;
+ static final int DESKTOP_KDE = 1;
+ static final int DESKTOP_GNOME = 2;
+ static final int Desktop = getDesktop ();
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program () {
+}
+
+static int getDesktop () {
+ File root = new File ("/proc");
+ if (!root.exists () || !root.isDirectory ()) return DESKTOP_UNKNOWN;
+ File [] procDirs = root.listFiles ();
+ for (int i=0; i<procDirs.length; i++) {
+ String directory = procDirs [i].getAbsolutePath ();
+ File file = new File (directory + "/stat");
+ if (file.exists ()) {
+ String procName = getProcName (file);
+ if (procName.indexOf ("gnome") >= 0) {
+ return gnome_init() ? DESKTOP_GNOME : DESKTOP_UNKNOWN;
+ }
+ if (procName.indexOf ("kdeinit") >= 0) {
+ return kde_init () ? DESKTOP_KDE : DESKTOP_UNKNOWN;
+ }
+ }
+ }
+ return DESKTOP_UNKNOWN;
+}
+
+static String getProcName (File file) {
+ try {
+ FileInputStream stream = new FileInputStream (file);
+ while (true) {
+ char ch = (char) stream.read ();
+ if (ch < 0 || ch == 0xFF) return null;
+ if (ch == '(') break;
+ }
+ String name = "";
+ while (true) {
+ char ch = (char) stream.read ();
+ if (ch < 0 || ch == 0xFF) return null;
+ if (ch == ')') break;
+ name += ch;
+ }
+ stream.close ();
+ return name;
+ } catch (IOException e) {
+ return null;
+ }
+}
+/*
+ * 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 <ul>
+ * <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ * </ul>
+ */
+public static Program findProgram (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return null;
+ if (extension.charAt (0) != '.') extension = "." + extension;
+ String command = null;
+ String name = "";
+ switch (Desktop) {
+ case DESKTOP_KDE: {
+ String urlString = "file://any." + extension;
+ byte [] buffer = Converter.wcsToMbcs (null, urlString, true);
+ int qString = KDE.QString_new (buffer);
+ int url = KDE.KURL_new (qString);
+ KDE.QString_delete (qString);
+ int mimeType = KDE.KMimeType_findByURL (url);
+ int mimeName = KDE.KMimeType_name (mimeType);
+ int service = KDE.KServiceTypeProfile_preferredService (mimeName, 1);
+ if (service == 0) return null;
+ int execQString = KDE.KService_exec (service);
+ command = kde_convertQStringAndFree (execQString);
+ break;
+ }
+
+ case DESKTOP_GNOME: {
+ String fileName = "file" + extension;
+ String mimeType = gnome_getMimeType (fileName);
+ if (mimeType == null) return null;
+ command = gnome_getMimeValue (mimeType, "open");
+ if (command == null) return null;
+ name = mimeType;
+ break;
+ }
+
+ case DESKTOP_UNKNOWN:
+ return null;
+ }
+ Program program = new Program ();
+ program.name = name;
+ program.command = command;
+ program.extension = extension;
+ return program;
+}
+
+/*
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ Vector names = new Vector ();
+ int serviceList = KDE.KService_allServices ();
+ int listBeginning = KDE.KServiceList_begin (serviceList);
+ int listEnd = KDE.KServiceList_end (serviceList);
+ int iterator = KDE.KServiceListIterator_new (listBeginning);
+ while (true) {
+ if (KDE.KServiceListIterator_equals (iterator, listEnd) != 0) break;
+ int kService = KDE.KServiceListIterator_dereference (iterator);
+ int serviceType = KDE.KService_type (kService);
+ byte [] applicationType = Converter.wcsToMbcs (null, "Application", true);
+ int appString = KDE.QString_new (applicationType);
+ if (KDE.QString_equals (serviceType, appString) != 0) {
+ int appName = KDE.KService_name (kService);
+ names.addElement (kde_convertQStringAndFree (appName));
+ }
+ KDE.QString_delete (appString);
+ KDE.KServiceListIterator_increment (iterator);
+ }
+ KDE.KServiceListIterator_delete (iterator);
+ KDE.KServiceList_delete (serviceList);
+ String[] appNames = new String [names.size ()];
+ for (int i=0; i <names.size (); i++) {
+ appNames [i] = (String) names.elementAt (i);
+ }
+ return appNames;
+
+ case DESKTOP_GNOME:
+ // Obtain the mime type/extension information.
+ Hashtable mimeInfo = gnome_getMimeInfo();
+ int index;
+
+ // Create a sorted set of the file extensions.
+ Vector extensions = new Vector();
+ Iterator keys = mimeInfo.keySet().iterator();
+ while (keys.hasNext()) {
+ String mimeType = (String) keys.next();
+ Vector mimeExts = (Vector) mimeInfo.get( mimeType );
+ for (index = 0; index < mimeExts.size(); index++){
+ if (!extensions.contains( mimeExts.elementAt( index ) )) {
+ extensions.add( mimeExts.elementAt( index ) );
+ }
+ }
+ }
+
+ // Return the list of extensions.
+ String[] extStrings = new String[ extensions.size() ];
+ for (index = 0; index < extensions.size(); index++) {
+ extStrings[ index ] = (String) extensions.elementAt( index );
+ }
+
+ return extStrings;
+ }
+ return new String[0];
+}
+
+/*
+ * Answers all available programs in the operating system.
+ *
+ * @return an array of programs
+ */
+public static Program [] getPrograms () {
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ return new Program[0]; // TBD
+
+ case DESKTOP_GNOME:
+ // Obtain the mime type/extension information.
+ Hashtable mimeInfo = gnome_getMimeInfo();
+ Vector programs = new Vector();
+
+ // Create a list of programs with commands.
+ Iterator keys = mimeInfo.keySet().iterator();
+ while (keys.hasNext()) {
+ String mimeType = (String) keys.next();
+ String extension = "";
+ Vector mimeExts = (Vector) mimeInfo.get( mimeType );
+ if (mimeExts.size() > 0){
+ extension = (String) mimeExts.elementAt( 0 );
+ }
+ String command = gnome_getMimeValue( mimeType, "open" );
+ if (command != null) {
+ Program program = new Program ();
+ program.name = mimeType;
+ program.command = command;
+ program.extension = extension;
+ programs.add( program );
+ }
+ }
+
+ // Return the list of programs to the user.
+ Program[] programList = new Program[ programs.size() ];
+ for (int index = 0; index < programList.length; index++) {
+ programList[ index ] = (Program) programs.elementAt( index );
+ }
+ return programList;
+ }
+ return new Program[0];
+}
+
+/*
+ * Obtain the registered mime type information and
+ * return it in a map. The key of each entry
+ * in the map is the mime type name. The value is
+ * a vector of the associated file extensions.
+ */
+
+private static Hashtable gnome_getMimeInfo() {
+ Hashtable mimeInfo = new Hashtable();
+
+ // Extract the mime info from the system directory.
+ String mimeDirectory = gnome_getDataDirectory ("mime-info");
+ gnome_getMimeInfoFromDirectory( mimeInfo, new File( mimeDirectory ) );
+
+ // Append the mime info from the user's directory (if it exists).
+ String userDirectory = gnome_getHomeDirectory();
+ if (userDirectory != null) {
+ userDirectory = userDirectory + File.separator + ".gnome" + File.separator + "mime-info";
+ gnome_getMimeInfoFromDirectory( mimeInfo, new File( userDirectory ) );
+ }
+
+ return mimeInfo;
+}
+
+// Given a map and a directory, find all of the
+// mime information files (*.mime) and parse them for
+// relavent mime type information. Each entry in the
+// map corresponds to one mime type, and its
+// associated file extensions.
+
+private static void gnome_getMimeInfoFromDirectory( Hashtable info, File directory ) {
+ // For each entry in the given directory (if it exists)
+ if (directory.exists()) {
+ File[] files = directory.listFiles();
+ for (int i = 0; i < files.length; i++) {
+
+ // If the entry is a subdirectory, process it and
+ // merge the mime type into the given map.
+ if (files[i].isDirectory()) {
+ gnome_getMimeInfoFromDirectory( info, files[i] );
+ }
+
+ // else if the entry is a mime info file (*.mime)
+ else if (files[i].getName().endsWith(".mime")) {
+ try {
+ // Parse the mime file and merge the info
+ // into the given map.
+ FileReader in = new FileReader( files[i] );
+ BufferedReader reader = new BufferedReader( in );
+ gnome_parseMimeFile( info, reader );
+ reader.close();
+ in.close();
+ }
+ catch (IOException e) {
+ // Ignore file exceptions silently. If we
+ // can't read it, the info is not available.
+ }
+ }
+ }
+ }
+}
+
+private static void gnome_parseMimeFile( Hashtable info, BufferedReader reader ) {
+ Vector mimeExts = null;
+ String mimeType = null;
+ boolean saveType = false;
+ String line = "#";
+ while (line != null) {
+
+ // Determine if the line contains a mime type name.
+ boolean newType = (line.length() > 0 && Character.isLetter( line.charAt(0) ));
+
+ // If there is valid data on this line to be processed
+ String data = line.trim();
+ if (data.length() > 0 && data.charAt(0) != '#') {
+
+ // If this line defines a new mime type
+ if (newType) {
+
+ // If a previous mime type has not be saved yet
+ if (mimeType != null) {
+ // Save the type and process this line again.
+ saveType = true;
+ }
+ // else initialize the mime type info
+ else {
+ int colon = data.indexOf( ':' );
+ if (colon != -1) {
+ mimeType = data.substring( 0, colon );
+ }
+ else {
+ mimeType = data;
+ }
+ mimeExts = new Vector();
+ }
+ }
+
+ // else if the line defines a list of extensions
+ else if (data.indexOf( "ext" ) == 0 && mimeType != null) {
+
+ // Get the extensions defined on the line
+ String exts = "";
+ int colon = data.indexOf( ':' );
+ if ((colon != -1) && ((colon+1) < data.length())) {
+ exts = data.substring( (colon+1) ).trim();
+ }
+
+ // While there are extensions to be processed
+ exts = exts.replace( '\t', ' ' );
+ while (exts.length() != 0) {
+ // Extract the next entension from the list
+ String newExt;
+ int space = exts.indexOf( ' ' );
+ if (space != -1) {
+ newExt = exts.substring( 0, space );
+ exts = exts.substring( space ).trim();
+ }
+ else {
+ newExt = exts;
+ exts = "";
+ }
+
+ // Prefix an extension with a period.
+ if (newExt.charAt(0) != '.') {
+ newExt = "." + newExt;
+ }
+ mimeExts.add( newExt );
+ }
+ }
+
+ // else if the line defines a list of regular expressions
+ else if (data.indexOf( "regex" ) == 0 && mimeType != null) {
+ // Do nothing with these right now.
+ }
+ }
+
+
+ // If the current mime type is still being processed
+ if (!saveType) {
+ // Get the next line
+ try {
+ line = reader.readLine();
+ }
+ catch (IOException e) {
+ line = null;
+ }
+ }
+
+ // If the current type should be saved or if the end
+ // of the file was reached
+ if (saveType || (line == null)) {
+
+ // If there is a mime type to be saved
+ if (mimeType != null) {
+
+ // If the mime type does not exist in the map, add it.
+ Vector prevExts = (Vector) info.get( mimeType );
+ if (prevExts == null) {
+ info.put( mimeType, mimeExts );
+ }
+
+ // else append the new list of extensions.
+ else {
+ for (int i = 0; i < mimeExts.size(); i++) {
+ prevExts.add( mimeExts.elementAt( i ) );
+ }
+ }
+ mimeType = null;
+ mimeExts = null;
+ saveType = false;
+ }
+ }
+ }
+}
+
+// Private method for parsing a command line into its arguments.
+private static String[] parseCommand( String cmd ) {
+ Vector args = new Vector();
+ int sIndex = 0;
+ int eIndex;
+ while (sIndex < cmd.length()) {
+ // Trim initial white space of argument.
+ while (sIndex < cmd.length() && Character.isWhitespace( cmd.charAt(sIndex) )) {
+ sIndex++;
+ }
+ if (sIndex < cmd.length()) {
+ // If the command is a quoted string
+ if (cmd.charAt(sIndex) == '"' || cmd.charAt(sIndex) == '\''){
+ // Find the terminating quote (or end of line).
+ // This code currently does not handle escaped characters (e.g., " a\"b").
+ eIndex = sIndex + 1;
+ while (eIndex < cmd.length() && cmd.charAt(eIndex) != cmd.charAt(sIndex)) {
+ eIndex++;
+ }
+ if (eIndex >= cmd.length()) { // the terminating quote was not found
+ // Add the argument as is with only one initial quote.
+ args.add( cmd.substring( sIndex, eIndex ) );
+ }
+ // else add the argument, trimming off the quotes.
+ else {
+ args.add( cmd.substring( sIndex+1, eIndex ) );
+ }
+ sIndex = eIndex + 1;
+ }
+
+ // else use white space for the delimiters.
+ else {
+ eIndex = sIndex;
+ while (eIndex < cmd.length() && !Character.isWhitespace( cmd.charAt(eIndex) )) {
+ eIndex++;
+ }
+ args.add( cmd.substring( sIndex, eIndex ) );
+ sIndex = eIndex + 1;
+ }
+ }
+ }
+
+ String[] strings = new String[ args.size() ];
+ for (int index =0; index < args.size(); index++) {
+ strings[ index ] = (String) args.elementAt( index );
+ }
+ return strings;
+}
+
+
+static String gnome_getDataDirectory(String dirName) {
+ byte [] nameBuffer = Converter.wcsToMbcs (null, dirName, true);
+ int ptr = GNOME.gnome_datadir_file(nameBuffer);
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] dirBuffer = new byte[length];
+ OS.memmove(dirBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, dirBuffer));
+}
+
+static String gnome_getHomeDirectory() {
+ int ptr = GNOME.g_get_home_dir();
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] homeDirBuffer = new byte[length];
+ OS.memmove(homeDirBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, homeDirBuffer));
+}
+
+static String gnome_getMimeType(String name) {
+ byte [] nameBuffer = Converter.wcsToMbcs (null, name, true);
+ int ptr = GNOME.gnome_mime_type(nameBuffer);
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] mimeBuffer = new byte[length];
+ OS.memmove(mimeBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, mimeBuffer));
+}
+
+static String gnome_getMimeValue(String mimeType, String key) {
+ byte [] typeBuffer = Converter.wcsToMbcs (null, mimeType, true);
+ byte [] keyBuffer = Converter.wcsToMbcs (null, key, true);
+ int ptr = GNOME.gnome_mime_get_value(typeBuffer, keyBuffer);
+ if (ptr == 0) return null;
+
+ StringBuffer stringBuffer = new StringBuffer();
+ int length = OS.strlen(ptr);
+ byte[] valueBuffer = new byte[length];
+ OS.memmove(valueBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, valueBuffer));
+}
+
+static boolean kde_init () {
+ try {
+ Callback.loadLibrary("swt-kde");
+ } catch (UnsatisfiedLinkError e) {
+ return false;
+ }
+ String appName = "KDE Platform Support";
+ byte [] nameBuffer = Converter.wcsToMbcs (null, appName, true);
+ int qcString = KDE.QCString_new (nameBuffer);
+ KDE.KApplication_new (qcString);
+ KDE.QCString_delete (qcString);
+ return true;
+}
+
+static String kde_convertQStringAndFree (int qString) {
+ int qCString = KDE.QString_utf8 (qString);
+ int charString = KDE.QCString_data (qCString);
+
+ StringBuffer stringBuffer = new StringBuffer ();
+ int length = KDE.strlen (charString);
+ byte[] buffer = new byte [length];
+ KDE.memmove (buffer, charString, length);
+ String answer = new String (Converter.mbcsToWcs (null, buffer));
+
+ KDE.QCString_delete (qCString);
+ KDE.QString_delete (qString);
+ return answer;
+}
+
+/*
+ * Launches the executable associated with the file in
+ * the operating system. If the file is an executable,
+ * then the executable is launched.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static boolean launch (String fileName) {
+ if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+
+ // If the argument appears to be a data file (it has an extension)
+ int index = fileName.lastIndexOf (".");
+ if (index > 0) {
+
+ // Find the associated program, if one is defined.
+ String extension = fileName.substring (index);
+ Program program = Program.findProgram (extension);
+
+ // If the associated program is defined and can be executed, return.
+ if (program != null && program.execute (fileName)) return true;
+ }
+
+ // Otherwise, the argument was the program itself.
+ try {
+ Runtime.getRuntime().exec (fileName);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+}
+
+/*
+ * Executes the program with the file as the single argument
+ * in the operating system. It is the responsibility of the
+ * programmer to ensure that the file contains valid data for
+ * this program.
+ *
+ * @param fileName is the argument (typically a file) for the program
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public boolean execute (String fileName) {
+ if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ // Parse the command into its individual arguments.
+ String[] args = parseCommand( command );
+ int fileArg = -1;
+ int index;
+ for (index=0; index < args.length; index++) {
+ int j = args[ index ].indexOf( "%f" );
+ if (j != -1) {
+ String value = args[ index ];
+ fileArg = index;
+ args[ index ] = value.substring(0,j) + fileName + value.substring(j+2);
+ }
+ }
+
+ // If a file name was given but the command did not have "%f"
+ if ((fileName.length() > 0) && (fileArg < 0)) {
+ String[] newArgs = new String[ args.length + 1 ];
+ for (index=0; index < args.length; index++)
+ newArgs[ index ] = args[ index ];
+ newArgs[ args.length ] = fileName;
+ args = newArgs;
+ }
+
+ // Execute the command.
+ try {
+ Runtime.getRuntime().exec( args );
+ } catch (IOException e) {
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Returns the receiver's image data. This is the icon
+ * that is associated with the reciever in the operating
+ * system.
+ *
+ * @return the image data for the program
+ */
+public ImageData getImageData () {
+ String iconPath = null;
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ String urlString = "file://any." + extension;
+ byte [] buffer = Converter.wcsToMbcs (null, urlString, true);
+ int qString = KDE.QString_new(buffer);
+ int url = KDE.KURL_new(qString);
+ KDE.QString_delete(qString);
+ int mimeType = KDE.KMimeType_findByURL(url);
+ if (mimeType == 0) return null;
+ int mimeIcon = KDE.KMimeType_icon(mimeType, 0, 0);
+ int loader = KDE.KGlobal_iconLoader();
+ int path = KDE.KIconLoader_iconPath(loader, mimeIcon, KDE.KICON_SMALL, 1);
+ iconPath = kde_convertQStringAndFree(path);
+ break;
+ case DESKTOP_GNOME:
+ String fakeFileName = "file." + extension;
+ String mime = gnome_getMimeType(fakeFileName);
+ if (mime == null) return null;
+ iconPath = gnome_getMimeValue(mime, "icon-filename");
+ if (iconPath == null) return null;
+ break;
+ case DESKTOP_UNKNOWN:
+ return null;
+ }
+ if (iconPath.endsWith ("xpm")) {
+ //BAD
+ Display display = Display.getCurrent ();
+ int xDisplay = display.xDisplay;
+ int drawable = OS.XDefaultRootWindow (xDisplay);
+ int [] pixmap_ptr = new int [1], mask_ptr = new int [1];
+ byte [] buffer = Converter.wcsToMbcs (null, iconPath, true);
+ int result = OS.XpmReadFileToPixmap (xDisplay, drawable, buffer, pixmap_ptr, mask_ptr, 0);
+ if (result < 0) return null;
+ Image image = Image.motif_new (display, SWT.BITMAP, pixmap_ptr[0], mask_ptr [0]);
+ ImageData imageData = image.getImageData ();
+ image.dispose ();
+ return imageData;
+ }
+ try {
+ return new ImageData (iconPath);
+ } catch (Exception e) {
+ return null;
+ }
+}
+
+/*
+ * Returns the receiver's name. This is as short and
+ * descriptive a name as possible for the program. If
+ * the program has no descriptive name, this string may
+ * be the executable name, path or empty.
+ *
+ * @return an the name of the program
+ */
+public String getName () {
+ return name;
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+static boolean gnome_init () {
+ try {
+ Callback.loadLibrary("swt-gnome");
+ } catch (UnsatisfiedLinkError e) {
+ return false;
+ }
+ return true;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
index 07e458932d..319ecc5547 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
@@ -31,7 +31,7 @@ public final class Program {
Program () {
}
-/**
+/*
* Finds the program that is associated with an extension.
* The extension may or may not begin with a '.'.
*
@@ -48,7 +48,7 @@ public static Program findProgram (String extension) {
return null;
}
-/**
+/*
* Answer all program extensions in the operating system.
*
* @return an array of extensions
@@ -57,7 +57,7 @@ public static String [] getExtensions () {
return new String[0];
}
-/**
+/*
* Answers all available programs in the operating system.
*
* @return an array of programs
@@ -86,7 +86,7 @@ public static Program [] getPrograms () {
return programs;
}
-/**
+/*
* Launches the executable associated with the file in
* the operating system. If the file is an executable,
* then the executable is launched.
@@ -113,7 +113,7 @@ public static boolean launch (String fileName) {
}
}
-/**
+/*
* Executes the program with the file as the single argument
* in the operating system. It is the responsibility of the
* programmer to ensure that the file
@@ -139,18 +139,18 @@ public boolean execute (String fileName) {
return true;
}
-/**
+/*
* Returns the receiver's image data. This is the icon
* that is associated with the reciever in the operating
* system.
*
- * @return the image data for the program, may be null
+ * @return the image data for the program
*/
public ImageData getImageData () {
return null;
}
-/**
+/*
* Returns the receiver's name. This is as short and
* descriptive a name as possible for the program. If
* the program has no descriptive name, this string may
@@ -162,31 +162,6 @@ public String getName () {
return name;
}
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- *
- * @return true if the programs are the same
- */
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return extension.equals(program.extension) && name.equals(program.name) &&
- command.equals(program.command);
- }
- return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- *
- * @return a hash code
- */
-public int hashCode() {
- return extension.hashCode() ^ name.hashCode() ^ command.hashCode();
-}
-
public String toString () {
return "Program {" + name + "}";
}
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
index ce917ea12f..46925c3dc7 100755
--- 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
@@ -28,7 +28,7 @@ public final class Program {
Program () {
}
-/**
+/*
* Finds the program that is associated with an extension.
* The extension may or may not begin with a '.'.
*
@@ -43,7 +43,6 @@ public static Program findProgram (String extension) {
if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (extension.length () == 0) return null;
if (extension.charAt (0) != '.') extension = "." + extension;
- /* Use the character encoding for the default locale */
byte [] key = Converter.wcsToMbcs (0, extension, true);
int [] phkResult = new int [1];
if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
@@ -57,7 +56,7 @@ public static Program findProgram (String extension) {
return getProgram (lpData);
}
-/**
+/*
* Answer all program extensions in the operating system.
*
* @return an array of extensions
@@ -72,7 +71,6 @@ public static String [] getExtensions () {
while (length < key.length && key [length] != 0) length++;
byte [] buffer = new byte [length];
System.arraycopy (key, 0, buffer, 0, length);
- /* Use the character encoding for the default locale */
String extension = new String (Converter.mbcsToWcs (0, buffer));
if (count == extensions.length) {
String [] newExtensions = new String [extensions.length + 1024];
@@ -101,7 +99,6 @@ static String getKeyValue (byte [] key) {
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
byte [] lpData = new byte [lpcbData [0]];
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- /* Use the character encoding for the default locale */
char [] charArray = Converter.mbcsToWcs (0, lpData);
result = new String (charArray, 0, charArray.length - 1);
}
@@ -113,7 +110,6 @@ static String getKeyValue (byte [] key) {
static Program getProgram (byte [] key) {
/* Command */
- /* Use the character encoding for the default locale */
byte [] COMMAND = Converter.wcsToMbcs (0, "\\shell\\open\\command", true);
int length = 0;
while (length < key.length && key [length] != 0) length++;
@@ -128,7 +124,6 @@ static Program getProgram (byte [] key) {
if (name == null || name.length () == 0) return null;
/* Icon */
- /* Use the character encoding for the default locale */
byte [] DEFAULT_ICON = Converter.wcsToMbcs (0, "\\DefaultIcon", true);
for (int i=0; i<DEFAULT_ICON.length; i++) key [length + i] = DEFAULT_ICON [i];
key [length + DEFAULT_ICON.length] = 0;
@@ -142,7 +137,7 @@ static Program getProgram (byte [] key) {
return program;
}
-/**
+/*
* Answers all available programs in the operating system.
*
* @return an array of programs
@@ -171,7 +166,7 @@ public static Program [] getPrograms () {
return programs;
}
-/**
+/*
* Launches the executable associated with the file in
* the operating system. If the file is an executable,
* then the executable is launched.
@@ -185,13 +180,12 @@ public static Program [] getPrograms () {
*/
public static boolean launch (String fileName) {
if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- /* Use the character encoding for the default locale */
byte [] OPEN = Converter.wcsToMbcs (0, "open", true);
byte [] lpFile = Converter.wcsToMbcs (0, fileName, true);
return OS.ShellExecute (0, OPEN, lpFile, null, null, OS.SW_SHOW) > 32;
}
-/**
+/*
* Executes the program with the file as the single argument
* in the operating system. It is the responsibility of the
* programmer to ensure that the file contains valid data for
@@ -229,12 +223,12 @@ public boolean execute (String fileName) {
return true;
}
-/**
+/*
* Returns the receiver's image data. This is the icon
* that is associated with the reciever in the operating
* system.
*
- * @return the image data for the program, may be null
+ * @return the image data for the program
*/
public ImageData getImageData () {
int nIconIndex = 0;
@@ -247,7 +241,6 @@ public ImageData getImageData () {
nIconIndex = Integer.parseInt (iconIndex);
} catch (NumberFormatException e) {};
}
- /* Use the character encoding for the default locale */
byte [] lpszFile = Converter.wcsToMbcs (0, fileName, true);
int [] phiconSmall = new int[1], phiconLarge = null;
OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
@@ -258,7 +251,7 @@ public ImageData getImageData () {
return imageData;
}
-/**
+/*
* Returns the receiver's name. This is as short and
* descriptive a name as possible for the program. If
* the program has no descriptive name, this string may
@@ -270,31 +263,6 @@ public String getName () {
return name;
}
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- *
- * @return true if the programs are the same
- */
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return name.equals(program.name) && command.equals(program.command)
- && iconName.equals(program.iconName);
- }
- return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- *
- * @return a hash code
- */
-public int hashCode() {
- return name.hashCode() ^ command.hashCode() ^ iconName.hashCode();
-}
-
public String toString () {
return "Program {" + name + "}";
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
index d1bdfd6013..5e98e3ca6a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
@@ -152,8 +152,8 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_Callback_bind
isStatic = (*env)->GetBooleanField(env,lpCallback,PGLOB(isStaticID));
argCount = (*env)->GetIntField(env,lpCallback,PGLOB(argCountID));
isArrayBased = (*env)->GetBooleanField(env,lpCallback,PGLOB(isArrayBasedID));
- methodString = (const char *) (*env)->GetStringUTFChars(env, javaMethod, NULL);
- sigString = (const char *) (*env)->GetStringUTFChars(env, javaSignature, NULL);
+ methodString = (*env)->GetStringUTFChars(env, javaMethod, NULL);
+ sigString = (*env)->GetStringUTFChars(env, javaSignature, NULL);
if (isStatic) {
mid = (*env)->GetStaticMethodID(env, javaObject, methodString, sigString);
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index b7b1e8c927..b8747c68bd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -20,7 +20,6 @@ import org.eclipse.swt.internal.image.*;
* <code>disposalMethod</code> and <code>delayTime</code> are
* typically only used when the image is in a set of images used
* for animation.
- * </p>
*
* @see Image
* @see ImageLoader
@@ -40,40 +39,24 @@ public final class ImageData implements Cloneable {
/**
* the color depth of the image, in bits per pixel
- * <p>
- * Note that a depth of 8 or less does not necessary
- * mean that the image is palette indexed, or
- * conversely that a depth greater than 8 means that
- * the image is direct color. Check the associated
- * PaletteData's isDirect field for such determinations.
*/
public int depth;
/**
- * the scanline padding
- * <p>
- * If one scanline of the image is not a multiple of
- * this number, it will be padded with zeros until it is.
- * </p>
+ * 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
- * <p>
- * This is a multiple of the scanline padding.
- * </p>
+ * the number of bytes per scanline. This is a multiple
+ * of the scanline padding
*/
public int bytesPerLine;
/**
* the pixel data of the image
- * <p>
- * Note that for 16 bit depth images the pixel data is stored
- * in least significant byte order; however, for 24bit and
- * 32bit depth images the pixel data is stored in most
- * significant byte order.
- * </p>
*/
public byte[] data;
@@ -83,58 +66,33 @@ public final class ImageData implements Cloneable {
public PaletteData palette;
/**
- * the transparent pixel
- * <p>
- * Pixels with this value are transparent.
- * </p><p>
- * The default is -1 which means 'no transparent pixel'.
- * </p>
+ * 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
- * <p>
- * This is a 1 bit bitmap stored with the most significant
- * bit first. The number of bytes per scanline is
- * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.
- * </p><p>
- * The default is null which means 'no transparency mask'.
- * </p>
*/
public byte[] maskData;
/**
* icon-specific field containing the scanline pad of the mask
- * <p>
- * If one scanline of the transparency mask is not a
- * multiple of this number, it will be padded with zeros until
- * it is.
- * </p>
*/
public int maskPad;
/**
- * the alpha data of the image
- * <p>
- * Every pixel can have an <em>alpha blending</em> value that
- * varies from 0, meaning fully transparent, to 255 meaning
- * fully opaque. The number of bytes per scanline is
- * 'width'.
- * </p>
+ * the alpha data of the image. Every pixel can have an
+ * <em>alpha blending</em> 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
- * <p>
- * If this value is set, the <code>alphaData</code> field
- * is ignored and when the image is rendered each pixel
- * will be blended with the background an amount
- * proportional to this value.
- * </p><p>
- * The default is -1 which means 'no global alpha value'
- * </p>
+ * the global alpha value to be used for every pixel.
+ * If this value is set the <code>alphaData</code> field
+ * is ignored. The default is -1 which means 'no global alpha
+ * value'
*/
public int alpha;
@@ -196,36 +154,7 @@ public final class ImageData implements Cloneable {
* Delay Time value)
*/
public int delayTime;
-
- /**
- * Arbitrary channel width data to 8-bit conversion table
- */
- static final byte[][] ANY_TO_EIGHT = new byte[9][];
- static {
- for (int b = 0; b < 9; ++b) {
- byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
- if (b == 0) continue;
- int inc = 0;
- for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
- for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);
- }
- }
- static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
-
- /**
- * Scaled 8x8 Bayer dither matrix
- */
- static final int[][] DITHER_MATRIX = {
- { 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },
- { 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },
- { 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },
- { 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },
- { 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },
- { 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },
- { 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },
- { 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }
- };
-
+
/**
* Constructs a new, empty ImageData with the given width, height,
* depth and palette. The data will be initialized to an (all zero)
@@ -556,7 +485,7 @@ public Object clone() {
* </ul>
*/
public int getAlpha(int x, int y) {
- if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (alphaData == null) return 255;
return alphaData[y * width + x] & 0xFF;
@@ -573,17 +502,15 @@ public int getAlpha(int x, int y) {
* @param alphas the buffer in which to put the alpha values
* @param startIndex the offset into the image to begin getting alpha values
*
- * @exception IndexOutOfBoundsException if getWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * <li>ERROR_INVALID_ARGUMENT - if <code>x</code> or <code>y</code> is out of bounds</li>
* </ul>
*/
public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {
if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
+ if (getWidth <= 0) return;
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (alphaData == null) {
int endIndex = startIndex + getWidth;
@@ -592,7 +519,6 @@ public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex)
}
return;
}
- // may throw an IndexOutOfBoundsException
System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);
}
@@ -612,7 +538,7 @@ public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex)
* </ul>
*/
public int getPixel(int x, int y) {
- if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
int theByte;
int mask;
@@ -675,11 +601,9 @@ public int getPixel(int x, int y) {
* @param pixels the buffer in which to put the pixels
* @param startIndex the offset into the byte array to begin storing pixels
*
- * @exception IndexOutOfBoundsException if getWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
* <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8
@@ -688,8 +612,8 @@ public int getPixel(int x, int y) {
*/
public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {
if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
+ if (getWidth <= 0) return;
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
int theByte;
int mask = 0;
@@ -824,11 +748,9 @@ public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex)
* @param pixels the buffer in which to put the pixels
* @param startIndex the offset into the buffer to begin storing pixels
*
- * @exception IndexOutOfBoundsException if getWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
* <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
@@ -836,8 +758,8 @@ public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex)
*/
public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
+ if (getWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
int theByte;
int mask;
@@ -1053,15 +975,6 @@ public int getTransparencyType() {
}
/**
- * Returns the byte order of the receiver.
- *
- * @return MSB_FIRST or LSB_FIRST
- */
-int getByteOrder() {
- return (depth != 16) ? MSB_FIRST : LSB_FIRST;
-}
-
-/**
* Returns a copy of the receiver which has been stretched or
* shrunk to the specified size. If either the width or height
* is negative, the resulting image will be inverted in the
@@ -1072,54 +985,97 @@ int getByteOrder() {
* @return a scaled copy of the image
*/
public ImageData scaledTo(int width, int height) {
- /* Create a destination image with no data */
- final boolean flipX = (width < 0);
- if (flipX) width = - width;
- final boolean flipY = (height < 0);
- if (flipY) height = - height;
-
- ImageData dest = new ImageData(
+ /* 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;
+}
- /* Scale the image contents */
- if (palette.isDirect) blit(BLIT_SRC,
- this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,
- ALPHA_OPAQUE, null, 0,
- dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,
- flipX, flipY);
- else blit(BLIT_SRC,
- this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0,
- dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
-
- /* Scale the image mask or alpha */
- if (maskData != null) {
- dest.maskPad = this.maskPad;
- int destBpl = (dest.width + 7) / 8;
- destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;
- dest.maskData = new byte[destBpl * dest.height];
- int srcBpl = (this.width + 7) / 8;
- srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;
- blit(BLIT_SRC,
- this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0,
- dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
+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) {
- dest.alpha = this.alpha;
+ destImage.alpha = alpha;
} else if (alphaData != null) {
- dest.alphaData = new byte[dest.width * dest.height];
- blit(BLIT_SRC,
- this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0,
- dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
- }
- return dest;
+ 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);
+ }
}
/**
@@ -1135,7 +1091,7 @@ public ImageData scaledTo(int width, int height) {
* </ul>
*/
public void setAlpha(int x, int y, int alpha) {
- if (x >= width || y >= height || x < 0 || y < 0 || alpha < 0 || alpha > 255)
+ if (x > width || y > height || x < 0 || y < 0 || alpha < 0 || alpha > 255)
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (alphaData == null) alphaData = new byte[width * height];
@@ -1154,20 +1110,17 @@ public void setAlpha(int x, int y, int alpha) {
* @param alphas the alpha values to set
* @param startIndex the index at which to begin setting
*
- * @exception IndexOutOfBoundsException if putWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
* <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
* </ul>
*/
public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {
if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
+ if (putWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (alphaData == null) alphaData = new byte[width * height];
- // may throw an IndexOutOfBoundsException
System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);
}
@@ -1187,7 +1140,7 @@ public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex)
* </ul>
*/
public void setPixel(int x, int y, int pixelValue) {
- if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
byte theByte;
int mask;
@@ -1260,11 +1213,9 @@ public void setPixel(int x, int y, int pixelValue) {
* @param pixels the pixels to set
* @param startIndex the index at which to begin setting
*
- * @exception IndexOutOfBoundsException if putWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
* <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8
@@ -1273,8 +1224,8 @@ public void setPixel(int x, int y, int pixelValue) {
*/
public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {
if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
+ if (putWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
int theByte;
int mask;
@@ -1388,11 +1339,9 @@ public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex)
* @param pixels the pixels to set
* @param startIndex the index at which to begin setting
*
- * @exception IndexOutOfBoundsException if putWidth is too large
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
* <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
@@ -1400,8 +1349,8 @@ public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex)
*/
public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
+ if (putWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int index;
int theByte;
int mask;
@@ -1569,6 +1518,43 @@ static PaletteData bwPalette() {
}
/**
+ * Blit operations.
+ */
+static final int BLIT_SRC = 1;
+static final int BLIT_ALPHA = 2;
+/**
+ * Byte and bit order constants.
+ */
+static final int MSB_FIRST = 1;
+static final int LSB_FIRST = 2;
+
+/**
+ * Masks for blitting.
+ */
+static final byte[] msbMasks1 = {
+ (byte)0x80, (byte)0x40, (byte)0x20, (byte)0x10,
+ (byte)0x08, (byte)0x04, (byte)0x02, (byte)0x01
+};
+static final byte[] lsbMasks1 = {
+ (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x08,
+ (byte)0x10, (byte)0x20, (byte)0x40, (byte)0x80
+};
+static final byte[] msbInverseMasks1 = {
+ (byte)0x7F, (byte)0xBF, (byte)0xDF, (byte)0xEF,
+ (byte)0xF7, (byte)0xFB, (byte)0xFD, (byte)0xFE
+};
+static final byte[] lsbInverseMasks1 = {
+ (byte)0xFE, (byte)0xFD, (byte)0xFB, (byte)0xF7,
+ (byte)0xEF, (byte)0xDF, (byte)0xBF, (byte)0x7F
+};
+static final byte[] masks2 = {
+ (byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0
+};
+static final byte[] inverseMasks2 = {
+ (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F
+};
+
+/**
* Gets the offset of the most significant bit for
* the given mask.
*/
@@ -1610,1931 +1596,1856 @@ static int closestMatch(int depth, byte red, byte green, byte blue, int redMask,
}
/**
- * Blit operation bits to be OR'ed together to specify the desired operation.
- */
-static final int
- BLIT_SRC = 1, // copy source directly, else applies logic operations
- BLIT_ALPHA = 2, // enable alpha blending
- BLIT_DITHER = 4; // enable dithering in low color modes
-
-/**
- * Alpha mode, values 0 - 255 specify global alpha level
- */
-static final int
- ALPHA_OPAQUE = 255, // Fully opaque (ignores any alpha data)
- ALPHA_TRANSPARENT = 0, // Fully transparent (ignores any alpha data)
- ALPHA_CHANNEL_SEPARATE = -1, // Use alpha channel from separate alphaData
- ALPHA_CHANNEL_SOURCE = -2, // Use alpha channel embedded in sourceData
- ALPHA_MASK_UNPACKED = -3, // Use transparency mask formed by bytes in alphaData (non-zero is opaque)
- ALPHA_MASK_PACKED = -4, // Use transparency mask formed by packed bits in alphaData
- ALPHA_MASK_INDEX = -5, // Consider source palette indices transparent if in alphaData array
- ALPHA_MASK_RGB = -6; // Consider source RGBs transparent if in RGB888 format alphaData array
-
-/**
- * Byte and bit order constants.
- */
-static final int MSB_FIRST = 1;
-static final int LSB_FIRST = 2;
-
-/**
- * Data types (internal)
- */
-private static final int
- // direct / true color formats with arbitrary masks & shifts
- TYPE_GENERIC_8 = 0,
- TYPE_GENERIC_16_MSB = 1,
- TYPE_GENERIC_16_LSB = 2,
- TYPE_GENERIC_24 = 3,
- TYPE_GENERIC_32_MSB = 4,
- TYPE_GENERIC_32_LSB = 5,
- // palette indexed color formats
- TYPE_INDEX_8 = 6,
- TYPE_INDEX_4 = 7,
- TYPE_INDEX_2 = 8,
- TYPE_INDEX_1_MSB = 9,
- TYPE_INDEX_1_LSB = 10;
-
-/**
* Blits a direct palette image into a direct palette image.
- * <p>
- * Note: When the source and destination depth, order and masks
- * are pairwise equal and the blitter operation is BLIT_SRC,
- * the masks are ignored. Hence when not changing the image
- * data format, 0 may be specified for the masks.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 8, 16, 24, 32
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 16 or 32
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcRedMask the source red channel mask
- * @param srcGreenMask the source green channel mask
- * @param srcBlueMask the source blue channel mask
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 8, 16, 24, 32
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 16 or 32
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destRedMask the destination red channel mask
- * @param destGreenMask the destination green channel mask
- * @param destBlueMask the destination blue channel mask
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
*/
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- int srcRedMask, int srcGreenMask, int srcBlueMask,
- int alphaMode, byte[] alphaData, int alphaStride,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- int destRedMask, int destGreenMask, int destBlueMask,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int srcAlphaMask = 0, destAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;
-
- /*** Prepare source-related data ***/
- final int sbpp, stype;
- switch (srcDepth) {
- case 8:
- sbpp = 1;
- stype = TYPE_GENERIC_8;
- break;
- case 16:
- sbpp = 2;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- sbpp = 3;
- stype = TYPE_GENERIC_24;
- break;
- case 32:
- sbpp = 4;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX * sbpp;
-
- /*** Prepare destination-related data ***/
- final int dbpp, dtype;
- switch (destDepth) {
- case 8:
- dbpp = 1;
- dtype = TYPE_GENERIC_8;
- break;
- case 16:
- dbpp = 2;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- dbpp = 3;
- dtype = TYPE_GENERIC_24;
- break;
- case 32:
- dbpp = 4;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid destination type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
- final int dprxi = (flipX) ? -dbpp : dbpp;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = srcY * alphaStride + srcX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = srcY * alphaStride + srcX;
+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, int srcRedMask, int srcGreenMask, int srcBlueMask, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, int destRedMask, int destGreenMask, int destBlueMask, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short so0 = 0, so1 = 1, so2 = 2, so3 = 3;
+ short do0 = 0, do1 = 1, do2 = 2, do3 = 3;
+ int srcRedShift, srcGreenShift, srcBlueShift;
+ int destRedShift, destGreenShift, destBlueShift;
+
+ if (op == BLIT_SRC && srcDepth == destDepth &&
+ srcRedMask == destRedMask &&
+ srcGreenMask == destGreenMask &&
+ srcBlueMask == destBlueMask)
+ {
+ switch (srcDepth) {
+ case 16:
+ stretch16(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
break;
- case ALPHA_MASK_INDEX:
- //throw new IllegalArgumentException("Invalid alpha type");
- return;
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
+ case 24:
+ stretch24(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
+ case 32:
+ stretch32(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
break;
}
+ return;
+ }
+
+ srcRedShift = 32 - getMSBOffset(srcRedMask);
+ srcGreenShift = 32 - getMSBOffset(srcGreenMask);
+ srcBlueShift = 32 - getMSBOffset(srcBlueMask);
+ destRedShift = 32 - getMSBOffset(destRedMask);
+ destGreenShift = 32 - getMSBOffset(destGreenMask);
+ destBlueShift = 32 - getMSBOffset(destBlueMask);
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 16: so0 = 1; so1 = 0; break;
+ case 24: so0 = 2; so1 = 1; so2 = 0; break;
+ case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 16: do0 = 1; do1 = 0; break;
+ case 24: do0 = 2; do1 = 1; do2 = 0; break;
+ case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- alphaMode = 0x10000;
- apr = 0;
- }
-
- /*** Blit ***/
- int dp = dpr;
- int sp = spr;
- if ((alphaMode == 0x10000) && (stype == dtype) &&
- (srcRedMask == destRedMask) && (srcGreenMask == destGreenMask) &&
- (srcBlueMask == destBlueMask) && (srcAlphaMask == destAlphaMask)) {
- /*** Fast blit (straight copy) ***/
- switch (sbpp) {
- case 1:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- sp += (sfx >>> 16);
- }
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxs *= srcDepth / 8;
+ xs1 *= srcDepth / 8;
+ sxd *= destDepth / 8;
+ xd1 *= destDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
+ break;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
+ break;
}
- break;
- case 2:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- sp += (sfx >>> 16) * 2;
- }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
}
+ }
+ destPixel =
+ (((dr << 24) >> destRedShift) & destRedMask) |
+ (((dg << 24) >> destGreenShift) & destGreenMask) |
+ (((db << 24) >> destBlueShift) & destBlueMask);
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ dp += sxd;
+ ex += dxs2;
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
break;
- case 3:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- destData[dp + 2] = srcData[sp + 2];
- sp += (sfx >>> 16) * 3;
- }
- }
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
break;
- case 4:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- destData[dp + 2] = srcData[sp + 2];
- destData[dp + 3] = srcData[sp + 3];
- sp += (sfx >>> 16) * 4;
- }
- }
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
break;
}
- return;
- }
- /*** Comprehensive blit (apply transformations) ***/
- final int srcRedShift = getChannelShift(srcRedMask);
- final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
- final int srcGreenShift = getChannelShift(srcGreenMask);
- final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
- final int srcBlueShift = getChannelShift(srcBlueMask);
- final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
- final int srcAlphaShift = getChannelShift(srcAlphaMask);
- final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
-
- final int destRedShift = getChannelShift(destRedMask);
- final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
- final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
- final int destRedPreShift = 8 - destRedWidth;
- final int destGreenShift = getChannelShift(destGreenMask);
- final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
- final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
- final int destGreenPreShift = 8 - destGreenWidth;
- final int destBlueShift = getChannelShift(destBlueMask);
- final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
- final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
- final int destBluePreShift = 8 - destBlueWidth;
- final int destAlphaShift = getChannelShift(destAlphaMask);
- final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
- final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
- final int destAlphaPreShift = 8 - destAlphaWidth;
-
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0;
- int rq = 0, gq = 0, bq = 0, aq = 0;
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_GENERIC_8: {
- final int data = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff);
- sp += (sfx >>> 16) * 3;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 3] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
break;
- case ALPHA_CHANNEL_SOURCE:
- alpha = (a << 16) / 255;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_RGB:
- alpha = 0x10000;
- for (int i = 0; i < alphaData.length; i += 3) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
- alpha = 0x0000;
- break;
- }
- }
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
break;
}
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_GENERIC_8: {
- final int data = destData[dp] & 0xff;
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 3] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- }
- // Perform alpha blending
- a = aq + ((a - aq) * alpha >> 16);
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** WRITE NEXT PIXEL ***/
- final int data =
- (r >>> destRedPreShift << destRedShift) |
- (g >>> destGreenPreShift << destGreenShift) |
- (b >>> destBluePreShift << destBlueShift) |
- (a >>> destAlphaPreShift << destAlphaShift);
- switch (dtype) {
- case TYPE_GENERIC_8: {
- destData[dp] = (byte) data;
- } break;
- case TYPE_GENERIC_16_MSB: {
- destData[dp] = (byte) (data >>> 8);
- destData[dp + 1] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_16_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- } break;
- case TYPE_GENERIC_24: {
- destData[dp] = (byte) (data >>> 16);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_MSB: {
- destData[dp] = (byte) (data >>> 24);
- destData[dp + 1] = (byte) (data >>> 16);
- destData[dp + 2] = (byte) (data >>> 8);
- destData[dp + 3] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data >>> 16);
- destData[dp + 3] = (byte) (data >>> 24);
- } break;
- }
- }
- }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ destPixel =
+ (((dr << 24) >> destRedShift) & destRedMask) |
+ (((dg << 24) >> destGreenShift) & destGreenMask) |
+ (((db << 24) >> destBlueShift) & destBlueMask);
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
}
/**
- * Blits an index palette image into an index palette image.
- * <p>
- * Note: The source and destination red, green, and blue
- * arrays may be null if no alpha blending or dither is to be
- * performed.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 1, 2, 4, 8
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 1
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcReds the source palette red component intensities
- * @param srcGreens the source palette green component intensities
- * @param srcBlues the source palette blue component intensities
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 1, 2, 4, 8
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 1
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destReds the destination palette red component intensities
- * @param destGreens the destination palette green component intensities
- * @param destBlues the destination palette blue component intensities
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
+ * Blits an index palette image into a direct palette image.
*/
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
- int alphaMode, byte[] alphaData, int alphaStride,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- byte[] destReds, byte[] destGreens, byte[] destBlues,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;
-
- /*** Prepare source-related data ***/
- final int stype;
+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] srcReds, byte[] srcGreens, byte[] srcBlues, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, int destRedMask, int destGreenMask, int destBlueMask, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short do0 = 0, do1 = 1, do2 = 2, do3 = 3;
+ int destRedShift, destGreenShift, destBlueShift;
+ int i, offset = 0;
+ byte[] srcMasks = null;
+ int srcN = 1 << srcDepth;
+ int[] mapping = null;
+
+ destRedShift = 32 - getMSBOffset(destRedMask);
+ destGreenShift = 32 - getMSBOffset(destGreenMask);
+ destBlueShift = 32 - getMSBOffset(destBlueMask);
+ if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;
+ if (op == BLIT_SRC) {
+ mapping = new int[srcN];
+ for (i = 0; i < srcN; i++) {
+ dr = srcReds[i] & 0xFF;
+ dg = srcGreens[i] & 0xFF;
+ db = srcBlues[i] & 0xFF;
+ mapping[i] =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
+ }
+ }
switch (srcDepth) {
- case 8:
- stype = TYPE_INDEX_8;
- break;
- case 4:
- srcStride <<= 1;
- stype = TYPE_INDEX_4;
- break;
- case 2:
- srcStride <<= 2;
- stype = TYPE_INDEX_2;
- break;
- case 1:
- srcStride <<= 3;
- stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX;
-
- /*** Prepare destination-related data ***/
- final int dtype;
- switch (destDepth) {
- case 8:
- dtype = TYPE_INDEX_8;
- break;
- case 4:
- destStride <<= 1;
- dtype = TYPE_INDEX_4;
- break;
- case 2:
- destStride <<= 2;
- dtype = TYPE_INDEX_2;
- break;
- case 1:
- destStride <<= 3;
- dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
- final int dprxi = (flipX) ? -1 : 1;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = srcY * alphaStride + srcX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = srcY * alphaStride + srcX;
- break;
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
+ case 1: srcMasks = msbMasks1; break;
+ case 2: srcMasks = masks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 1: srcMasks = lsbMasks1; break;
}
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 16: do0 = 1; do1 = 0; break;
+ case 24: do0 = 2; do1 = 1; do2 = 0; break;
+ case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- alphaMode = 0x10000;
- apr = 0;
- }
- final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
-
- /*** Blit ***/
- int dp = dpr;
- int sp = spr;
- int ap = apr;
- int destPaletteSize = 1 << destDepth;
- if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
- byte[] paletteMapping = null;
- boolean isExactPaletteMapping = true;
- switch (alphaMode) {
- case 0x10000:
- /*** If the palettes and formats are equivalent use a one-to-one mapping ***/
- if ((stype == dtype) &&
- (srcReds == destReds) && (srcGreens == destGreens) && (srcBlues == destBlues)) {
- paletteMapping = ONE_TO_ONE_MAPPING;
- break;
- /*** If palettes have not been supplied, supply a suitable mapping ***/
- } else if ((srcReds == null) || (destReds == null)) {
- if (srcDepth <= destDepth) {
- paletteMapping = ONE_TO_ONE_MAPPING;
- } else {
- paletteMapping = new byte[1 << srcDepth];
- int mask = (0xff << destDepth) >>> 8;
- for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);
- }
- break;
- }
- case ALPHA_MASK_UNPACKED:
- case ALPHA_MASK_PACKED:
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- /*** Generate a palette mapping ***/
- int srcPaletteSize = 1 << srcDepth;
- paletteMapping = new byte[srcPaletteSize];
- if ((srcReds != null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;
- for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {
- r = srcReds[i] & 0xff;
- g = srcGreens[i] & 0xff;
- b = srcBlues[i] & 0xff;
- index = 0;
- int minDistance = 0x7fffffff;
- for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
- if (distance < minDistance) {
- index = j;
- if (distance == 0) break;
- minDistance = distance;
- }
- }
- paletteMapping[i] = (byte)index;
- if (minDistance != 0) isExactPaletteMapping = false;
- }
- break;
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
}
- if ((paletteMapping != null) && (isExactPaletteMapping || ! ditherEnabled)) {
- if ((stype == dtype) && (alphaMode == 0x10000)) {
- /*** Fast blit (copy w/ mapping) ***/
- switch (stype) {
- case TYPE_INDEX_8:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = paletteMapping[srcData[sp] & 0xff];
- sp += (sfx >>> 16);
- }
- }
- break;
- case TYPE_INDEX_4:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int v;
- if ((sp & 1) != 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];
- else v = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));
- }
- }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxd *= destDepth / 8;
+ xd1 *= destDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ sp = ys * srcStride;
+ dp = yd * destStride + xd1;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
break;
- case TYPE_INDEX_2:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];
- sp += (sfx >>> 16);
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
- }
- }
- break;
- case TYPE_INDEX_1_MSB:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];
- sp += (sfx >>> 16);
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- }
- }
- break;
- case TYPE_INDEX_1_LSB:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];
- sp += (sfx >>> 16);
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- }
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
}
break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
}
- } else {
- /*** Convert between indexed modes using mapping and mask ***/
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- int index;
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
break;
- default:
- return;
- }
- /*** APPLY MASK ***/
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED: {
- final byte mask = alphaData[ap];
- ap += (sfx >> 16);
- if (mask == 0) continue;
- } break;
- case ALPHA_MASK_PACKED: {
- final int mask = alphaData[ap >> 3] & (1 << (ap & 7));
- ap += (sfx >> 16);
- if (mask == 0) continue;
- } break;
- case ALPHA_MASK_INDEX: {
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
- }
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];
- int i = 0;
- while (i < alphaData.length) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) break;
- i += 3;
- }
- if (i < alphaData.length) continue;
- } break;
- }
- index = paletteMapping[index] & 0xff;
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) index;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));
- break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- } break;
+ }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
}
}
- }
- }
- return;
- }
-
- /*** Comprehensive blit (apply transformations) ***/
- int alpha = alphaMode;
- int index = 0;
- int indexq = 0;
- int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
- final int[] rerr, gerr, berr;
- if (ditherEnabled) {
- rerr = new int[destWidth + 2];
- gerr = new int[destWidth + 2];
- berr = new int[destWidth + 2];
- } else {
- rerr = null; gerr = null; berr = null;
- }
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- int lrerr = 0, lgerr = 0, lberr = 0;
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
+ destPixel =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
+ }
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
break;
}
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
- }
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- int i = 0;
- while (i < alphaData.length) {
- if ((r == (alphaData[i] & 0xff)) &&
- (g == (alphaData[i + 1] & 0xff)) &&
- (b == (alphaData[i + 2] & 0xff))) break;
- i += 3;
- }
- if (i < alphaData.length) continue;
- } break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_INDEX_8:
- indexq = destData[dp] & 0xff;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
- else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
- break;
- case TYPE_INDEX_2:
- indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+ while (ex >= 0) {
+ xs += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ dp += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
break;
- case TYPE_INDEX_1_MSB:
- indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
break;
- case TYPE_INDEX_1_LSB:
- indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
break;
}
- // Perform alpha blending
- final int rq = destReds[indexq] & 0xff;
- final int gq = destGreens[indexq] & 0xff;
- final int bq = destBlues[indexq] & 0xff;
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** MAP COLOR TO THE PALETTE ***/
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion
- r += rerr[dx] >> 4;
- if (r < 0) r = 0; else if (r > 255) r = 255;
- g += gerr[dx] >> 4;
- if (g < 0) g = 0; else if (g > 255) g = 255;
- b += berr[dx] >> 4;
- if (b < 0) b = 0; else if (b > 255) b = 255;
- rerr[dx] = lrerr;
- gerr[dx] = lgerr;
- berr[dx] = lberr;
- }
- if (r != lastr || g != lastg || b != lastb) {
- // moving the variable declarations out seems to make the JDK JIT happier...
- for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
- if (distance < minDistance) {
- lastindex = j;
- if (distance == 0) break;
- minDistance = distance;
- }
- }
- lastr = r; lastg = g; lastb = b;
- }
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion, cont'd...
- final int dxm1 = dx - 1, dxp1 = dx + 1;
- int acc;
- rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
- rerr[dx] += acc += lrerr + lrerr;
- rerr[dxm1] += acc + lrerr + lrerr;
- gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
- gerr[dx] += acc += lgerr + lgerr;
- gerr[dxm1] += acc + lgerr + lgerr;
- berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
- berr[dx] += acc += lberr + lberr;
- berr[dxm1] += acc + lberr + lberr;
- }
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) lastindex;
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
- break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
+ }
}
+ destPixel =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
}
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
}
}
/**
- * Blits an index palette image into a direct palette image.
- * <p>
- * Note: The source and destination masks and palettes must
- * always be fully specified.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 1, 2, 4, 8
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 1
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcReds the source palette red component intensities
- * @param srcGreens the source palette green component intensities
- * @param srcBlues the source palette blue component intensities
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 8, 16, 24, 32
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 16 or 32
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destRedMask the destination red channel mask
- * @param destGreenMask the destination green channel mask
- * @param destBlueMask the destination blue channel mask
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
+ * Blits an index palette image into an index palette image.
*/
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
- int alphaMode, byte[] alphaData, int alphaStride,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- int destRedMask, int destGreenMask, int destBlueMask,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int destAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;
-
- /*** Prepare source-related data ***/
- final int stype;
- switch (srcDepth) {
- case 8:
- stype = TYPE_INDEX_8;
- break;
- case 4:
- srcStride <<= 1;
- stype = TYPE_INDEX_4;
- break;
- case 2:
- srcStride <<= 2;
- stype = TYPE_INDEX_2;
- break;
- case 1:
- srcStride <<= 3;
- stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX;
-
- /*** Prepare destination-related data ***/
- final int dbpp, dtype;
- switch (destDepth) {
- case 8:
- dbpp = 1;
- dtype = TYPE_GENERIC_8;
- break;
- case 16:
- dbpp = 2;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- dbpp = 3;
- dtype = TYPE_GENERIC_24;
- break;
- case 32:
- dbpp = 4;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid destination type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
- final int dprxi = (flipX) ? -dbpp : dbpp;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = srcY * alphaStride + srcX;
+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] srcReds, byte[] srcGreens, byte[] srcBlues, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, byte[] destReds, byte[] destGreens, byte[] destBlues, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ int i, j, offset = 0;
+ byte[] srcMasks = null, destMasks = null, destInverseMasks = null;
+ int destN = 1 << destDepth, srcN = 1 << srcDepth;
+ int r, g, b, nearestPixel = 0, lastPixel = -1;
+ int distance, minDistance;
+ int[] mapping = null;
+ boolean samePalette = srcReds == destReds && srcGreens == destGreens && srcBlues == srcBlues;
+ boolean sameAsSrc = op == BLIT_SRC && samePalette && srcDepth <= destDepth;
+
+ if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;
+ if (destReds != null && destN > destReds.length) destN = destReds.length;
+ if (op == BLIT_SRC && srcReds != null) {
+ mapping = new int[srcN];
+ for (i = 0; i < srcN; i++) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - (srcReds[i] & 0xFF);
+ g = (destGreens[j] & 0xFF) - (srcGreens[i] & 0xFF);
+ b = (destBlues[j] & 0xFF) - (srcBlues[i] & 0xFF);
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ mapping[i] = nearestPixel;
+ }
+ }
+ if (op == BLIT_SRC && srcDepth == destDepth && (mapping != null || samePalette))
+ {
+ switch (srcDepth) {
+ case 1:
+ stretch1(srcData, srcStride, srcOrder, srcX, srcY, srcWidth, srcHeight, destData, destStride, destOrder, destX, destY, destWidth, destHeight, flipX, flipY);
break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = srcY * alphaStride + srcX;
+ case 2:
+ stretch2(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
break;
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
+ case 4:
+ stretch4(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
+ case 8:
+ stretch8(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
break;
}
+ return;
+ }
+ switch (srcDepth) {
+ case 1: srcMasks = msbMasks1; break;
+ case 2: srcMasks = masks2; break;
+ }
+ switch (destDepth) {
+ case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;
+ case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 1: srcMasks = lsbMasks1; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- alphaMode = 0x10000;
- apr = 0;
- }
-
- /*** Comprehensive blit (apply transformations) ***/
- final int destRedShift = getChannelShift(destRedMask);
- final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
- final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
- final int destRedPreShift = 8 - destRedWidth;
- final int destGreenShift = getChannelShift(destGreenMask);
- final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
- final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
- final int destGreenPreShift = 8 - destGreenWidth;
- final int destBlueShift = getChannelShift(destBlueMask);
- final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
- final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
- final int destBluePreShift = 8 - destBlueWidth;
- final int destAlphaShift = getChannelShift(destAlphaMask);
- final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
- final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
- final int destAlphaPreShift = 8 - destAlphaWidth;
-
- int dp = dpr;
- int sp = spr;
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0, index = 0;
- int rq = 0, gq = 0, bq = 0, aq = 0;
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- int lrerr = 0, lgerr = 0, lberr = 0;
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
break;
}
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- r = srcReds[index] & 0xff;
- g = srcGreens[index] & 0xff;
- b = srcBlues[index] & 0xff;
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else if (sameAsSrc) {
+ destPixel = srcPixel;
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ }
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
break;
- case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
}
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- int i = 0;
- while (i < alphaData.length) {
- if ((r == (alphaData[i] & 0xff)) &&
- (g == (alphaData[i + 1] & 0xff)) &&
- (b == (alphaData[i + 2] & 0xff))) break;
- i += 3;
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ xs += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else if (sameAsSrc) {
+ destPixel = srcPixel;
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
}
- if (i < alphaData.length) continue;
- } break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_GENERIC_8: {
- final int data = destData[dp] & 0xff;
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 3] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
}
- // Perform alpha blending
- a = aq + ((a - aq) * alpha >> 16);
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** WRITE NEXT PIXEL ***/
- final int data =
- (r >>> destRedPreShift << destRedShift) |
- (g >>> destGreenPreShift << destGreenShift) |
- (b >>> destBluePreShift << destBlueShift) |
- (a >>> destAlphaPreShift << destAlphaShift);
- switch (dtype) {
- case TYPE_GENERIC_8: {
- destData[dp] = (byte) data;
- } break;
- case TYPE_GENERIC_16_MSB: {
- destData[dp] = (byte) (data >>> 8);
- destData[dp + 1] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_16_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- } break;
- case TYPE_GENERIC_24: {
- destData[dp] = (byte) (data >>> 16);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_MSB: {
- destData[dp] = (byte) (data >>> 24);
- destData[dp + 1] = (byte) (data >>> 16);
- destData[dp + 2] = (byte) (data >>> 8);
- destData[dp + 3] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data >>> 16);
- destData[dp + 3] = (byte) (data >>> 24);
- } break;
- }
- }
- }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ }
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
}
/**
* Blits a direct palette image into an index palette image.
- * <p>
- * Note: The source and destination masks and palettes must
- * always be fully specified.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 8, 16, 24, 32
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 16 or 32
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcRedMask the source red channel mask
- * @param srcGreenMask the source green channel mask
- * @param srcBlueMask the source blue channel mask
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 1, 2, 4, 8
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 1
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destReds the destination palette red component intensities
- * @param destGreens the destination palette green component intensities
- * @param destBlues the destination palette blue component intensities
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
*/
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- int srcRedMask, int srcGreenMask, int srcBlueMask,
- int alphaMode, byte[] alphaData, int alphaStride,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- byte[] destReds, byte[] destGreens, byte[] destBlues,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int srcAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;
-
- /*** Prepare source-related data ***/
- final int sbpp, stype;
- switch (srcDepth) {
- case 8:
- sbpp = 1;
- stype = TYPE_GENERIC_8;
- break;
- case 16:
- sbpp = 2;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- sbpp = 3;
- stype = TYPE_GENERIC_24;
- break;
- case 32:
- sbpp = 4;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX * sbpp;
-
- /*** Prepare destination-related data ***/
- final int dtype;
+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, int srcRedMask, int srcGreenMask, int srcBlueMask, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, byte[] destReds, byte[] destGreens, byte[] destBlues, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xd;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short so0 = 0, so1 = 1, so2 = 2, so3 = 3;
+ int srcRedShift, srcGreenShift, srcBlueShift;
+ int j, offset = 0;
+ byte[] destMasks = null, destInverseMasks = null;
+ int destN = 1 << destDepth;
+ int r, g, b, nearestPixel = 0, lastPixel = -1;
+ int distance, minDistance;
+
+ srcRedShift = 32 - getMSBOffset(srcRedMask);
+ srcGreenShift = 32 - getMSBOffset(srcGreenMask);
+ srcBlueShift = 32 - getMSBOffset(srcBlueMask);
+ if (destReds != null && destN > destReds.length) destN = destReds.length;
switch (destDepth) {
- case 8:
- dtype = TYPE_INDEX_8;
- break;
- case 4:
- destStride <<= 1;
- dtype = TYPE_INDEX_4;
- break;
- case 2:
- destStride <<= 2;
- dtype = TYPE_INDEX_2;
- break;
- case 1:
- destStride <<= 3;
- dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
- final int dprxi = (flipX) ? -1 : 1;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = srcY * alphaStride + srcX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = srcY * alphaStride + srcX;
- break;
- case ALPHA_MASK_INDEX:
- //throw new IllegalArgumentException("Invalid alpha type");
- return;
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
+ case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;
+ case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 16: so0 = 1; so1 = 0; break;
+ case 24: so0 = 2; so1 = 1; so2 = 0; break;
+ case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;
}
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- alphaMode = 0x10000;
- apr = 0;
- }
- final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
-
- /*** Comprehensive blit (apply transformations) ***/
- final int srcRedShift = getChannelShift(srcRedMask);
- final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
- final int srcGreenShift = getChannelShift(srcGreenMask);
- final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
- final int srcBlueShift = getChannelShift(srcBlueMask);
- final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
- final int srcAlphaShift = getChannelShift(srcAlphaMask);
- final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
-
- int dp = dpr;
- int sp = spr;
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0;
- int indexq = 0;
- int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
- final int[] rerr, gerr, berr;
- int destPaletteSize = 1 << destDepth;
- if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
- if (ditherEnabled) {
- rerr = new int[destWidth + 2];
- gerr = new int[destWidth + 2];
- berr = new int[destWidth + 2];
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
} else {
- rerr = null; gerr = null; berr = null;
- }
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- int lrerr = 0, lgerr = 0, lberr = 0;
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_GENERIC_8: {
- final int data = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff);
- sp += (sfx >>> 16) * 3;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 3] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_CHANNEL_SOURCE:
- alpha = (a << 16) / 255;
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxs *= srcDepth / 8;
+ xs1 *= srcDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xd = xd1;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
break;
- case ALPHA_MASK_RGB:
- alpha = 0x10000;
- for (int i = 0; i < alphaData.length; i += 3) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
- alpha = 0x0000;
- break;
- }
- }
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
break;
}
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_INDEX_8:
- indexq = destData[dp] & 0xff;
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
- else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
break;
- case TYPE_INDEX_2:
- indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
- break;
- case TYPE_INDEX_1_MSB:
- indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xd & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
break;
- case TYPE_INDEX_1_LSB:
- indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
break;
}
- // Perform alpha blending
- final int rq = destReds[indexq] & 0xff;
- final int gq = destGreens[indexq] & 0xff;
- final int bq = destBlues[indexq] & 0xff;
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** MAP COLOR TO THE PALETTE ***/
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion
- r += rerr[dx] >> 4;
- if (r < 0) r = 0; else if (r > 255) r = 255;
- g += gerr[dx] >> 4;
- if (g < 0) g = 0; else if (g > 255) g = 255;
- b += berr[dx] >> 4;
- if (b < 0) b = 0; else if (b > 255) b = 255;
- rerr[dx] = lrerr;
- gerr[dx] = lgerr;
- berr[dx] = lberr;
- }
- if (r != lastr || g != lastg || b != lastb) {
- // moving the variable declarations out seems to make the JDK JIT happier...
- for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
if (distance < minDistance) {
- lastindex = j;
+ nearestPixel = j;
if (distance == 0) break;
minDistance = distance;
}
}
- lastr = r; lastg = g; lastb = b;
- }
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion, cont'd...
- final int dxm1 = dx - 1, dxp1 = dx + 1;
- int acc;
- rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
- rerr[dx] += acc += lrerr + lrerr;
- rerr[dxm1] += acc + lrerr + lrerr;
- gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
- gerr[dx] += acc += lgerr + lgerr;
- gerr[dxm1] += acc + lgerr + lgerr;
- berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
- berr[dx] += acc += lberr + lberr;
- berr[dxm1] += acc + lberr + lberr;
- }
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) lastindex;
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
}
}
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xd & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
}
}
/**
- * Computes the required channel shift from a mask.
+ * Stretches the source, a 1-bit image, into the destination, a 1-bit image.
*/
-static int getChannelShift(int mask) {
- if (mask == 0) return 0;
- int i;
- for (i = 0; ((mask & 1) == 0) && (i < 32); ++i) {
- mask >>>= 1;
+static void stretch1(byte[] srcData, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp;
+ byte[] masks, inverseMasks;
+
+ if (srcOrder == LSB_FIRST) {
+ masks = lsbMasks1;
+ } else {
+ masks = msbMasks1;
+ }
+ if (destOrder == LSB_FIRST) {
+ inverseMasks = lsbInverseMasks1;
+ } else {
+ inverseMasks = msbInverseMasks1;
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);
+ for (dx = 0; dx < dxd; dx++) {
+ if (pixel != 0)
+ destData[dp + (xd >> 3)] |= masks[xd & 7];
+ else
+ destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);
+ }
+ xd += sxd;
+ ex += dxs2;
+ }
+ if (pixel != 0)
+ destData[dp + (xd >> 3)] |= masks[xd & 7];
+ else
+ destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
}
- return i;
}
/**
- * Computes the required channel width (depth) from a mask.
+ * Stretches the source, a 16-bit image, into the destination, a 16-bit image.
+ * The images are assumed to have the same red, green, and blue masks.
+ *
+ * Untested - would need an X server with the same red, green and blue
+ * masks as the file has, namely, 0x7C00, 0x3E0, 0x1F. Most 16-bit X servers
+ * have masks of 0xF800, 0x7E0, 0x1F.
*/
-static int getChannelWidth(int mask, int shift) {
- if (mask == 0) return 0;
- int i;
- mask >>>= shift;
- for (i = shift; ((mask & 1) != 0) && (i < 32); ++i) {
- mask >>>= 1;
- }
- return i - shift;
+static void stretch16(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel0, pixel1;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ pixel0 = srcData[sp + xs];
+ pixel1 = srcData[sp + xs + 1];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + xd] = pixel0;
+ destData[dp + xd + 1] = pixel1;
+ if (ex >= 0) {
+ do {
+ xs += (sxs << 1);
+ ex -= dxd2;
+ } while (ex >= 0);
+ pixel0 = srcData[sp + xs];
+ pixel1 = srcData[sp + xs + 1];
+ }
+ xd += (sxd << 1);
+ ex += dxs2;
+ }
+ destData[dp + xd] = pixel0;
+ destData[dp + xd + 1] = pixel1;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
}
/**
- * Extracts a field from packed RGB data given a mask for that field.
+ * Stretches the source, a 2-bit image, into the destination, a 2-bit image.
*/
-static byte getChannelField(int data, int mask) {
- final int shift = getChannelShift(mask);
- return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
+static void stretch2(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp, x;
+ byte [] masks = { (byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0 };
+ byte [] inverseMasks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ int offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
}
/**
- * Creates an ImageData containing one band's worth of a gradient filled
- * block. If <code>vertical</code> is true, the band must be tiled
- * horizontally to fill a region, otherwise it must be tiled vertically.
+ * Stretches the source, a 24-bit image, into the destination, a 24-bit image.
+ * The images must have the same red, green, and blue masks.
+ * The image are assumed to have 24 bits per pixel; many 24-bit images
+ * use 32 bits per pixel.
*
- * @param width the width of the region to be filled
- * @param height the height of the region to be filled
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- * @param fromRGB the color to start with
- * @param toRGB the color to end with
- * @param redBits the number of significant red bits, 0 for palette modes
- * @param greenBits the number of significant green bits, 0 for palette modes
- * @param blueBits the number of significant blue bits, 0 for palette modes
- * @return the new ImageData
+ * Untested. Would require an X server with a depth of 24 which has 24 bits per
+ * pixel. Most X servers with depth 24 actually have 32 bits per pixel.
*/
-static ImageData createGradientBand(
- int width, int height, boolean vertical,
- RGB fromRGB, RGB toRGB,
- int redBits, int greenBits, int blueBits) {
- /* Gradients are drawn as tiled bands */
- final int bandWidth, bandHeight, bitmapDepth;
- final byte[] bitmapData;
- final PaletteData paletteData;
- /* Select an algorithm depending on the depth of the screen */
- if (redBits != 0 && greenBits != 0 && blueBits != 0) {
- paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);
- bitmapDepth = 32;
- if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {
- /* Precise color */
- final int steps;
- if (vertical) {
- bandWidth = 1;
- bandHeight = height;
- steps = bandHeight > 1 ? bandHeight - 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = 1;
- steps = bandWidth > 1 ? bandWidth - 1 : 1;
- }
- final int bytesPerLine = bandWidth * 4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);
- buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);
- buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);
- } else {
- /* Dithered color */
- final int steps;
- if (vertical) {
- bandWidth = (width < 8) ? width : 8;
- bandHeight = height;
- steps = bandHeight > 1 ? bandHeight - 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = (height < 8) ? height : 8;
- steps = bandWidth > 1 ? bandWidth - 1 : 1;
- }
- final int bytesPerLine = bandWidth * 4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);
- buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);
- buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);
- }
+static void stretch24(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs;
+ byte r, g, b;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- /* Dithered two tone */
- paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });
- bitmapDepth = 8;
- final int blendi;
- if (vertical) {
- bandWidth = (width < 8) ? width : 8;
- bandHeight = height;
- blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = (height < 8) ? height : 8;
- blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;
- }
- final int bytesPerLine = (bandWidth + 3) & -4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- if (vertical) {
- for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;
- ++dy, blend += blendi, dp += bytesPerLine) {
- for (int dx = 0; dx < bandWidth; ++dx) {
- bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <
- 0x1000000 ? (byte)0 : (byte)1;
- }
- }
- } else {
- for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {
- for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {
- bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <
- 0x1000000 ? (byte)0 : (byte)1;
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 3 : -3);
+ sxs = (short)((xs2 - xs1) > 0 ? 3 : -3);
+ xs1 *= 3;
+ xd1 *= 3;
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ if (ex >= 0) {
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
}
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
}
+ dp += sxd;
+ ex += dxs2;
+ }
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
}
+ yd += syd;
+ ey += dys2;
}
- return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);
}
-/*
- * Fill in gradated values for a color channel
+/**
+ * Stretches the source, a 32-bit image, into the destination, a 32-bit image.
+ * The images must have the same red, green, and blue masks.
*/
-static final void buildPreciseGradientChannel(int from, int to, int steps,
- int bandWidth, int bandHeight, boolean vertical,
- byte[] bitmapData, int dp, int bytesPerLine) {
- int val = from << 16;
- final int inc = ((to << 16) - val) / steps + 1;
- if (vertical) {
- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
- bitmapData[dp] = (byte)(val >>> 16);
- val += inc;
- }
+static void stretch32(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs;
+ byte r, g, b, a;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
} else {
- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
- bitmapData[dp] = (byte)(val >>> 16);
- val += inc;
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 4 : -4);
+ sxs = (short)((xs2 - xs1) > 0 ? 4 : -4);
+ xs1 *= 4;
+ xd1 *= 4;
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ a = srcData[sp + 3];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ destData[dp + 3] = a;
+ if (ex >= 0) {
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ }
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ a = srcData[sp + 3];
+ }
+ dp += sxd;
+ ex += dxs2;
}
- }
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ destData[dp + 3] = a;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
}
-/*
- * Fill in dithered gradated values for a color channel
+/**
+ * Stretches the source, a 4-bit image, into the destination, a 4-bit image.
*/
-static final void buildDitheredGradientChannel(int from, int to, int steps,
- int bandWidth, int bandHeight, boolean vertical,
- byte[] bitmapData, int dp, int bytesPerLine, int bits) {
- final int mask = 0xff00 >>> bits;
- int val = from << 16;
- final int inc = ((to << 16) - val) / steps + 1;
- if (vertical) {
- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
- for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {
- final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;
- int temp = val + thresh;
- if (temp > 0xffffff) bitmapData[dptr] = -1;
- else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
- }
- val += inc;
- }
+static void stretch4(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
} else {
- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
- for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {
- final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;
- int temp = val + thresh;
- if (temp > 0xffffff) bitmapData[dptr] = -1;
- else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ int x = srcData[sp + (xs >> 1)];
+ if ((xs & 1) != 0) {
+ pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));
+ } else {
+ pixel = (byte)((mapping == null) ? (x >> 4) : (mapping[x >> 4] & 0x0F));
+ }
+ for (dx = 0; dx < dxd; dx++) {
+ if ((xd & 1) != 0)
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);
+ else
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = srcData[sp + (xs >> 1)];
+ if ((xd & 1) != 0) {
+ pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));
+ } else {
+ pixel = (byte)((mapping == null) ? ((x >> 4) & 0x0F) : (mapping[x >> 4] & 0x0F));
+ }
}
- val += inc;
+ xd += sxd;
+ ex += dxs2;
}
+ if ((xd & 1) != 0)
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);
+ else
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
}
}
/**
- * Renders a gradient onto a GC.
- * <p>
- * This is a GC helper.
- * </p>
- *
- * @param gc the GC to render the gradient onto
- * @param device the device the GC belongs to
- * @param x the top-left x coordinate of the region to be filled
- * @param y the top-left y coordinate of the region to be filled
- * @param width the width of the region to be filled
- * @param height the height of the region to be filled
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- * @param fromRGB the color to start with
- * @param toRGB the color to end with
- * @param redBits the number of significant red bits, 0 for palette modes
- * @param greenBits the number of significant green bits, 0 for palette modes
- * @param blueBits the number of significant blue bits, 0 for palette modes
+ * Stretches the source, an 8-bit image, into the destination, an 8-bit image.
*/
-static void fillGradientRectangle(GC gc, Device device,
- int x, int y, int width, int height, boolean vertical,
- RGB fromRGB, RGB toRGB,
- int redBits, int greenBits, int blueBits) {
- /* Create the bitmap and tile it */
- ImageData band = createGradientBand(width, height, vertical,
- fromRGB, toRGB, redBits, greenBits, blueBits);
- Image image = new Image(device, band);
- if ((band.width == 1) || (band.height == 1)) {
- gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
+static void stretch8(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp, x;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
} else {
- if (vertical) {
- for (int dx = 0; dx < width; dx += band.width) {
- int blitWidth = width - dx;
- if (blitWidth > band.width) blitWidth = band.width;
- gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
- }
- } else {
- for (int dy = 0; dy < height; dy += band.height) {
- int blitHeight = height - dy;
- if (blitHeight > band.height) blitHeight = band.height;
- gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
- }
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ x = srcData[sp + xs] & 0xFF;
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + xd] = pixel;
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = srcData[sp + xs] & 0xFF;
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ }
+ xd += sxd;
+ ex += dxs2;
}
+ destData[dp + xd] = pixel;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
}
- image.dispose();
}
-} \ No newline at end of file
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
index a892742646..1528cf33db 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
@@ -140,17 +140,10 @@ public ImageData[] load(String filename) {
InputStream stream = null;
try {
stream = new FileInputStream(filename);
- return load(stream);
} catch (IOException e) {
SWT.error(SWT.ERROR_IO, e);
- } finally {
- try {
- if (stream != null) stream.close();
- } catch (IOException e) {
- // Ignore error
- }
}
- return null;
+ return load(stream);
}
/**
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
index ea91b4a5b3..412fb6f066 100755
--- 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
@@ -31,12 +31,12 @@ public class Callback {
/**
* SWT Major version number (must be >= 0)
*/
- public static int MAJOR_VERSION = 2;
+ public static int MAJOR_VERSION = 0;
/**
* SWT Minor version number (must be in the range 0..999)
*/
- public static int MINOR_VERSION = 2;
+ public static int MINOR_VERSION = 125;
/**
* SWT revision number (must be >= 0)
@@ -158,18 +158,6 @@ public static int getVersion () {
public static native String getPlatform ();
/**
- * Returns the OS name.
- *
- * @return the os name of the currently running SWT
- */
-static String getOS () {
- String name = System.getProperty("os.name");
- if (name.regionMatches(true, 0, "win", 0, 3)) return "win32";
- if (name.regionMatches(true, 0, "sun", 0, 3)) return "solaris";
- return name.toLowerCase();
-}
-
-/**
* Returns the SWT revision number as an integer. Revision changes
* occur as a result of non-API breaking bug fixes.
*
@@ -239,10 +227,7 @@ public static void loadLibrary () {
* @param name the name of the library to load
*/
public static void loadLibrary (String name) {
- /* Include os name to support same window system on
- * different operating systems
- */
- String newName = name + "-" + getOS () + "-" + MAJOR_VERSION;
+ String newName = name + MAJOR_VERSION;
/* Force 3 digits in minor version number */
if (MINOR_VERSION < 10) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
index 6754225bda..1b692b2383 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
@@ -188,7 +188,7 @@ public String getText () {
/**
* Sets the receiver's text, which is the string that the
* window manager will typically display as the receiver's
- * <em>title</em>, to the argument, which must not be null.
+ * <em>title</em>, to the argument, which may not be null.
*
* @param text the new text
*
@@ -201,7 +201,6 @@ public String getText () {
* </ul>
*/
public void setText (String string) {
- if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
title = string;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
index f80c0330b0..e6c7b68425 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
@@ -79,9 +79,6 @@ void releaseWidget () {
*
* @param image the image to display on the receiver (may be null)
*
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -89,7 +86,6 @@ void releaseWidget () {
*/
public void setImage (Image image) {
checkWidget ();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
this.image = image;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
index eb91d2a6a6..1c3227e43c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
@@ -1 +1 @@
-version 2.002 \ No newline at end of file
+version 0.125 \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
index fef01d317a..5a14d0d699 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
@@ -9,8 +9,8 @@
# getSharedLibraryMajorVersionNumber and getSharedLibraryMinorVersionNumber
# calls so java can query the swt shared library version number
-setenv MAJOR_VER 2
-setenv MINOR_VER 002
+setenv MAJOR_VER 0
+setenv MINOR_VER 125
setenv BUILD_NUM 0
# Some UNIX/Linux compilers don't like <CR>'s in files (DOS format).
@@ -29,42 +29,24 @@ endif
# Determine the operating system being built
set OS=`uname -s`
switch ($OS )
- case AIX:
- if ( "$1" == "clean" ) then
- make -f make_aix.mak clean
- else
- echo "Building AIX version of SWT and CDE DLLs."
- make -f make_aix.mak make_swt
- make -f make_aix.mak make_cde
- endif
- breaksw
case Linux:
- if ( "$1" == "clean" ) then
- make -f make_linux.mak clean
- else
- echo "Building Linux version of SWT and GNOME DLLs."
- make -f make_linux.mak make_swt make_gnome
-
- set build_kde = `rpm -q kdebase | grep "not installed"`
- if ( "$build_kde" == "" ) then
- echo "Building Linux version of KDE DLL."
- make -f make_linux.mak make_kde
- endif
- endif
- breaksw
-
- case SunOS:
- if ( "$1" == "clean" ) then
- make -f make_solaris.mak clean
- else
- echo "Building Solaris version of SWT and CDE DLLs."
- make -f make_solaris.mak make_swt
- make -f make_solaris.mak make_cde
- endif
- breaksw
+ if ( "$1" == "clean" ) then
+ make -f make_linux.mak clean
+ else
+ echo "Building Linux version of SWT and GNOME DLLs."
+ make -f make_linux.mak make_swt make_gnome
+
+ set build_kde = `rpm -q kdebase | grep "not installed"`
+ set build_kde = "not ported" # KDE porting not complete yet (KJC)
+ if ( "$build_kde" == "" ) then
+ echo "Building Linux version of KDE DLL."
+ make -f make_linux.mak make_kde
+ endif
+ endif
+ breaksw
default:
- echo "Unknown OS -- build aborted"
+ echo "Unknown"
breaksw
endsw
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
index 6c7e251193..79cb99f03c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
@@ -11,13 +11,11 @@
#define NDEBUG
#include <stdio.h>
-#include <signal.h>
#include "jni.h"
#include <kapp.h>
#include <kservice.h>
#include <kmimetype.h>
-#include <krun.h>
#include <kuserprofile.h>
#include <kurl.h>
#include <qstring.h>
@@ -32,37 +30,13 @@ extern "C" {
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KApplication_1new
(JNIEnv *env, jclass that, int appName)
{
- int myArgc = 1;
- char* myArgv[2] = { "SWT", 0 }; // KApplication requires a NULL terminated list
+ int myArgc = 0;
+ char* myArgv[1];
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "KApplication_1new\n");
#endif
QCString qcString = *((QCString*) appName);
-
- // NOTE: When a KDE application is initialized, it installs its own
- // SIGSEGV signal handler so that it can pop up a dialogue box and
- // display an error message should SIGSEGV occur. After the dialogue
- // box is closed, it terminates the program. The Hursley Java VM (on Linux)
- // happens to catch SIGSEGV signals so that it can throw a null pointer
- // exception. Thus when KDE is initialized, the Java try ... catch
- // mechanism for null pointers does not work. Eclipse code relies upon
- // this try ... catch feature.
- //
- // The solution is to obtain the Java VM's signal handler before initializing
- // KDE and to reinstall that handler after the initialization. The method
- // sigaction() must be used instead of signal() because it returns more
- // information on how to handle the signal.
-
- // Obtain the current signal handling logic for SIGSEGV.
- struct sigaction prev;
- sigaction( SIGSEGV, NULL, &prev );
-
- // Initialize KDE, which installs its own signal handler.
KApplication* app = new KApplication(myArgc, myArgv, qcString);
-
- // Replace the Java VM signal handler.
- sigaction( SIGSEGV, &prev, NULL );
-
return (jint) app;
}
@@ -86,12 +60,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KGlobal_1iconLoad
* Signature: (IIII)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KIconLoader_1iconPath
- (JNIEnv *env, jclass that, jint kloader, jint iconQString, jint iconType, jint canReturnNull)
+ (JNIEnv *env, jclass that, jint receiver, jint iconQString, jint iconType, jint canReturnNull)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "KIconLoader_1iconPath\n");
#endif
- KIconLoader* loader = (KIconLoader*) kloader;
+ KIconLoader* loader = (KIconLoader*) receiver;
QString iconName = *((QString*) iconQString);
QString iconPath = loader->iconPath(iconName, iconType, canReturnNull);
if (iconPath == 0) return 0;
@@ -102,18 +76,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KIconLoader_1icon
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeType_1mimeType
+ * Method: KMimeType_1findByURL
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1mimeType
- (JNIEnv *env, jclass that, jint mimeTypeName)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1findByURL
+ (JNIEnv *env, jclass that, jint kurl)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeType_1mimeType\n");
+ fprintf(stderr, "KMimeType_1findByURL\n");
#endif
+ KURL url = *((KURL*) kurl);
KSharedPtr<KMimeType>* mimeType = new KSharedPtr<KMimeType>();
- QString qMimeType = *((QString*) mimeTypeName);
- *mimeType = KMimeType::mimeType( qMimeType );
+ *mimeType = KMimeType::findByURL(url);
return (jint) mimeType;
}
@@ -123,12 +97,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1mimeTy
* Signature: (III)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1icon
- (JNIEnv *env, jclass that, jint mimeTypePtr, jint unused1, jint unused2)
+ (JNIEnv *env, jclass that, jint receiver, jint unused1, jint unused2)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "KMimeType_1icon\n");
#endif
- KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
+ KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
QString* answer = new QString();
*answer = mimeType->icon((const QString&) NULL, 0);
return (jint) answer;
@@ -140,279 +114,151 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1icon
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1name
- (JNIEnv *env, jclass that, jint mimeTypePtr)
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "KMimeType_1name\n");
#endif
- KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
- QString* name = new QString();
- *name = mimeType->name();
- return (jint) name;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeType_1patterns
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1patterns
- (JNIEnv *env, jclass that, jint mimeTypePtr)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeType_1patterns\n");
-#endif
- KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
- QStringList* patternList = new QStringList();
- *patternList = mimeType->patterns();
- return (jint) patternList;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeType_1offers
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1offers
- (JNIEnv *env, jclass that, jint mimeTypeName)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeType_1offers\n");
-#endif
- QString qMimeType = *((QString*) mimeTypeName);
- KService::List* serviceList = new KService::List();
- *serviceList = KMimeType::offers( qMimeType );
- return (jint) serviceList;
+ KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
+ QString* answer = new QString();
+ *answer = mimeType->name();
+ return (jint) answer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeType_1allMimeTypes
+ * Method: KService_1allServices
* Signature: ()I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1allMimeTypes
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1allServices
(JNIEnv *env, jclass that)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeType_1allMimeTypes\n");
+ fprintf(stderr, "KService_1allServices\n");
#endif
- KMimeType::List* mimeTypeList = new KMimeType::List();
- *mimeTypeList = KMimeType::allMimeTypes();
- return (jint) mimeTypeList;
+ KService::List* pointer = new KService::List();
+ *pointer = KService::allServices();
+ return (jint) pointer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeList_1begin
+ * Method: KService_1exec
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1begin
- (JNIEnv *env, jclass that, jint mimeTypeList)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeList_1begin\n");
-#endif
- KMimeType::List *list= (KMimeType::List*) mimeTypeList;
- QValueListIterator<KMimeType::Ptr>* iterator = new QValueListIterator<KMimeType::Ptr>();
- *iterator = list->begin();
- return (jint) iterator;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeList_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1delete
- (JNIEnv *env, jclass that, jint mimeTypeList)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeList_1delete\n");
-#endif
- delete (KMimeType::List*) mimeTypeList;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeList_1end
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1end
- (JNIEnv *env, jclass that, jint mimeTypeList)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeList_1end\n");
-#endif
- KMimeType::List *list = (KMimeType::List*) mimeTypeList;
- QValueListIterator<KMimeType::Ptr>* iterator = new QValueListIterator<KMimeType::Ptr>();
- *iterator = list->end();
- return (jint) iterator;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeListIterator_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1delete
- (JNIEnv *env, jclass that, jint iterator)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1exec
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeListIterator_1delete\n");
+ fprintf(stderr, "KService_1exec\n");
#endif
- delete (QValueListIterator<KMimeType::Ptr>*) iterator;
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->exec();
+ return (jint) answer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeListIterator_1dereference
+ * Method: KService_1icon
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1dereference
- (JNIEnv *env, jclass that, jint iterator)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1icon
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeListIterator_1dereference\n");
+ fprintf(stderr, "KService_1icon\n");
#endif
- KSharedPtr<KMimeType>* mimeType = new KSharedPtr<KMimeType>();
- *mimeType = *(*((QValueListIterator<KMimeType::Ptr>*) iterator));
- return (jint) mimeType;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeListIterator_1equals
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1equals
- (JNIEnv *env, jclass that, jint iterator, jint iterator2)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeListIterator_1equals\n");
-#endif
- return *((QValueListIterator<KMimeType::Ptr>*) iterator) ==
- *((QValueListIterator<KMimeType::Ptr>*) iterator2);
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->icon();
+ return (jint) answer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KMimeTypeListIterator_1increment
+ * Method: KService_1name
* Signature: (I)I
*/
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1increment
- (JNIEnv *env, jclass that, jint iterator)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1name
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KMimeTypeListIterator_1increment\n");
+ fprintf(stderr, "KService_1name\n");
#endif
- ++(*((QValueListIterator<KMimeType::Ptr>*) iterator));
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->name();
+ return (jint) answer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringList_1begin
+ * Method: KService_1serviceByName
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1begin
- (JNIEnv *env, jclass that, jint qstringList)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringList_1begin\n");
-#endif
- QStringList *list= (QStringList*) qstringList;
- QValueListIterator<QString>* iterator = new QValueListIterator<QString>();
- *iterator = list->begin();
- return (jint) iterator;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringList_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1delete
- (JNIEnv *env, jclass that, jint qstringList)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1serviceByName
+ (JNIEnv *env, jclass that, jint serviceName)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringList_1delete\n");
+ fprintf(stderr, "KService_1serviceByName\n");
#endif
- delete (QStringList*) qstringList;
+ QString* name = (QString*) serviceName;
+ KSharedPtr<KService> service = KService::serviceByName(*name);
+ if (service == 0) return 0;
+ KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+ *pointer = service;
+ return (jint) pointer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringList_1end
+ * Method: KService_1type
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1end
- (JNIEnv *env, jclass that, jint qstringList)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1type
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringList_1end\n");
+ fprintf(stderr, "KService_1type\n");
#endif
- QStringList *list = (QStringList*) qstringList;
- QValueListIterator<QString>* iterator = new QValueListIterator<QString>();
- *iterator = list->end();
- return (jint) iterator;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringListIterator_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1delete
- (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringListIterator_1delete\n");
-#endif
- delete (QValueListIterator<QString>*) iterator;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringListIterator_1dereference
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1dereference
- (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringListIterator_1dereference\n");
-#endif
- QString* qstring = new QString();
- *qstring = *(*((QValueListIterator<QString>*) iterator));
- return (jint) qstring;
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->type();
+ return (jint) answer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringListIterator_1equals
+ * Method: KServiceTypeProfile_1preferredService
* Signature: (II)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1equals
- (JNIEnv *env, jclass that, jint iterator, jint iterator2)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceTypeProfile_1preferredService
+ (JNIEnv *env, jclass that, jint mimeTypeQString, jint needApp)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringListIterator_1equals\n");
+ fprintf(stderr, "KServiceTypeProfile_1preferredService\n");
#endif
- return *((QValueListIterator<QString>*) iterator) ==
- *((QValueListIterator<QString>*) iterator2);
+ QString mimeTypeName = *((QString*) mimeTypeQString);
+ KSharedPtr<KService> service = KServiceTypeProfile::preferredService(mimeTypeName, needApp);
+ if (service == 0) return 0;
+ KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+ *pointer = service;
+ return (jint) pointer;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: QStringListIterator_1increment
- * Signature: (I)I
+ * Method: KURL_1delete
+ * Signature: (I)V
*/
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1increment
- (JNIEnv *env, jclass that, jint iterator)
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1delete
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "QStringListIterator_1increment\n");
+ fprintf(stderr, "KURL_1delete\n");
#endif
- ++(*((QValueListIterator<QString>*) iterator));
+ delete (KURL*) receiver;
}
/*
@@ -421,57 +267,61 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterat
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1new
- (JNIEnv *env, jclass that, jint qURLString)
+ (JNIEnv *env, jclass that, jint qString)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "KURL_1new\n");
#endif
- QString urlString = *((QString*) qURLString);
+ QString urlString = *((QString*) qString);
return (jint) new KURL(urlString);
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KURL_1delete
- * Signature: (I)V
+ * Method: KServiceList_1begin
+ * Signature: (I)I
*/
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1delete
- (JNIEnv *env, jclass that, jint url)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1begin
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KURL_1delete\n");
+ fprintf(stderr, "KServiceList_1begin\n");
#endif
- delete (KURL*) url;
+ KService::List *list= (KService::List*) receiver;
+ QValueListConstIterator<KService::Ptr>* beginning = new QValueListConstIterator<KService::Ptr>();
+ *beginning = list->begin();
+ return (jint) beginning;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KRun_1runURL
- * Signature: (II)I
+ * Method: KServiceList_1delete
+ * Signature: (I)V
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KRun_1runURL
- (JNIEnv *env, jclass that, jint kurl, jint mimeTypeName)
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1delete
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KRun_1runURL\n");
+ fprintf(stderr, "KServiceList_1delete\n");
#endif
- KURL url = *((KURL*) kurl);
- QString qMimeType = *((QString*) mimeTypeName);
- return (jint) KRun::runURL( url, qMimeType );
+ delete (KService::List*) receiver;
}
/*
* Class: org_eclipse_swt_internal_motif_KDE
- * Method: KServiceList_1delete
- * Signature: (I)V
+ * Method: KServiceList_1end
+ * Signature: (I)I
*/
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1delete
- (JNIEnv *env, jclass that, jint serviceList)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1end
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "KServiceList_1delete\n");
+ fprintf(stderr, "KServiceList_1end\n");
#endif
- delete (KService::List*) serviceList;
+ KService::List *list = (KService::List*) receiver;
+ QValueListConstIterator<KService::Ptr>* end = new QValueListConstIterator<KService::Ptr>();
+ *end = list->end();
+ return (jint) end;
}
/*
@@ -480,12 +330,12 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1del
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1data
- (JNIEnv *env, jclass that, jint qcString)
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "QCString_1data\n");
#endif
- return (jint) ((QCString*) qcString)->data();
+ return (jint) ((QCString*) receiver)->data();
}
/*
@@ -494,12 +344,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1data
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1delete
- (JNIEnv *env, jclass that, jint qcString)
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "QCString_1delete\n");
#endif
- delete (QCString*) qcString;
+ delete (QCString*) receiver;
}
/*
@@ -526,12 +376,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1new
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1delete
- (JNIEnv *env, jclass that, jint qString)
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "QString_1delete\n");
#endif
- delete (QString*) qString;
+ delete (QString*) receiver;
}
/*
@@ -540,12 +390,12 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1delete
* Signature: (I[B)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1equals
- (JNIEnv *env, jclass that, jint qString, jint qString2)
+ (JNIEnv *env, jclass that, jint receiver, jint object)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "QString_1equals\n");
#endif
- return *((QString*) qString) == *((QString*) qString2);
+ return *((QString*) receiver) == *((QString*) object);
}
/*
@@ -572,16 +422,93 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1new
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1utf8
- (JNIEnv *env, jclass that, jint qString)
+ (JNIEnv *env, jclass that, jint receiver)
{
#ifdef DEBUG_CALL_PRINTS
fprintf(stderr, "QString_1utf8\n");
#endif
- QString string = *((QString*) qString);
+ QString string = *((QString*) receiver);
QCString* qcString = new QCString();
*qcString = string.utf8();
return (jint) qcString;
}
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1delete\n");
+#endif
+ delete (QValueListIterator<KService::Ptr>*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1dereference
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1dereference
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1dereference\n");
+#endif
+ KSharedPtr<KService>* service = new KSharedPtr<KService>();
+ *service = *(*((QValueListIterator<KService::Ptr>*) receiver));
+ return (jint) service;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1increment
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1increment
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1increment\n");
+#endif
+ ++(*((QValueListIterator<KService::Ptr>*) receiver));
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1new
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1new
+ (JNIEnv *env, jclass that, jint listBeginning)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1new\n");
+#endif
+ const QValueListIterator<KService::Ptr> *iterator =
+ (const QValueListIterator<KService::Ptr> *) listBeginning;
+
+ return (jint) new QValueListIterator<KService::Ptr>(*iterator);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1equals
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1equals
+ (JNIEnv *env, jclass that, jint receiver, jint object)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1equals\n");
+#endif
+ return *((QValueListIterator<KService::Ptr>*) receiver) ==
+ *((QValueListIterator<KService::Ptr>*) object);
+}
+
+
} /* extern "C" */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
index f326f3ba33..def0e62635 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
@@ -18,29 +18,28 @@ DLL_VERSION=$(MAJOR_VER)$(MINOR_VER)
# QT_HOME - identifier namespace package (used by KDE)
IVE_HOME = /bluebird/teamswt/swt-builddir/ive/bin
MOTIF_HOME = /bluebird/teamswt/swt-builddir/motif21
-QT_HOME = /usr/lib/qt-2.2.4
+QT_HOME = /usr/lib/qt-2.2.0
# Define the various DLL (shared) libraries to be made.
SWT_PREFIX = swt
-OS_PREFIX = linux
-SWT_DLL = lib$(SWT_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+SWT_DLL = lib$(SWT_PREFIX)$(DLL_VERSION).so
SWT_OBJ = callback.o globals.o library.o structs.o swt.o
SWT_LIB = -L$(MOTIF_HOME)/lib -lXm -L/usr/lib -L/usr/X11R6/lib \
- -rpath . -x -shared -lX11 -lm -lXext -lXt -lXp -ldl
+ -x -shared -lX11 -lm -lXext -lXt -lXp -lXpm -ldl
GNOME_PREFIX = swt-gnome
-GNOME_DLL = lib$(GNOME_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+GNOME_DLL = lib$(GNOME_PREFIX)$(DLL_VERSION).so
GNOME_OBJ = gnome.o
GNOME_LIB = -x -shared \
- `gnome-config --libs gnome`
+ `gnome-config --libs gnome`
KDE_PREFIX = swt-kde
-KDE_DLL = lib$(KDE_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+KDE_DLL = lib$(KDE_PREFIX)$(DLL_VERSION).so
KDE_OBJ = kde.o
KDE_LIB = -L/usr/lib -L$(QT_HOME)/lib \
- -shared -lksycoca -lkdecore -lqt
+ -shared -lksycoca -lkdecore -lq
#
# The following CFLAGS are for compiling both the SWT library and the GNOME
@@ -49,7 +48,7 @@ KDE_LIB = -L/usr/lib -L$(QT_HOME)/lib \
CFLAGS = -O -s \
-DSWT_LIBRARY_MAJOR_VERSION=$(MAJOR_VER) \
-DSWT_LIBRARY_MINOR_VERSION=$(MINOR_VER) \
- -DLINUX -DMOTIF -DGNOME \
+ -DLINUX -DMOTIF -DGNOME -DXPM \
-fpic \
-I./ \
-I$(IVE_HOME)/include \
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
index feab06591d..99d97120cf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
@@ -15,9 +15,6 @@
#include <stdio.h>
#include <assert.h>
-#include <langinfo.h>
-#include <iconv.h>
-#include <stdlib.h>
JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_getSharedLibraryMajorVersionNumber
(JNIEnv *env, jclass that)
@@ -1866,35 +1863,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGrabPointer
/*
* Class: org_eclipse_swt_internal_motif_OS
- * Method: XInternAtom
- * Signature: (I[BZ)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XInternAtom
- (JNIEnv *env, jclass that, jint display, jbyteArray name, jboolean ifExists)
-{
- jbyte *name1 = NULL;
- jint rc;
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XInternAtom\n");
-#endif
- if (name)
- name1 = (*env)->GetByteArrayElements(env, name, NULL);
-
- rc = (jint) XInternAtom((Display *)display, (char *)name1, ifExists);
-
-#ifdef PRINT_FAILED_RCODES
- if (rc == 0)
- fprintf(stderr, "XInternAtom: call failed rc = %d\n", rc);
-#endif
-
- if (name)
- (*env)->ReleaseByteArrayElements(env, name, name1, 0);
- return rc;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
* Method: XKeysymToString
* Signature: (I)I
*/
@@ -1943,35 +1911,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XListFonts
/*
* Class: org_eclipse_swt_internal_motif_OS
- * Method: XListProperties
- * Signature: (II[I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XListProperties
- (JNIEnv *env, jclass that, jint display, jint window, jintArray num_prop_return)
-{
- jint *num_prop_return1=NULL;
- jint rc;
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XListProperties\n");
-#endif
- if (num_prop_return)
- num_prop_return1 = (*env)->GetIntArrayElements(env, num_prop_return, NULL);
-
- rc = (jint) XListProperties((Display *)display, (Window)window, (int *)num_prop_return1);
-
-#ifdef PRINT_FAILED_RCODES
- if (rc == 0)
- fprintf(stderr, "XListProperties: call failed rc = %d\n", rc);
-#endif
-
- if (num_prop_return)
- (*env)->ReleaseIntArrayElements(env, num_prop_return, num_prop_return1, 0);
- return rc;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
* Method: XLookupString
* Signature: (Lorg/eclipse/swt/internal/motif/XKeyEvent;[BI[I[I)I
*/
@@ -2000,7 +1939,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XLookupString
if (status)
status1 = (*env)->GetIntArrayElements(env, status, NULL);
rc = (jint) XLookupString((XKeyEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (XComposeStatus *)status1);
-
+
#ifdef PRINT_FAILED_RCODES
if (rc < 0)
fprintf(stderr, "XLookupString: call failed rc = %d\n", rc);
@@ -4123,27 +4062,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetFocusWidget
/*
* Class: org_eclipse_swt_internal_motif_OS
- * Method: XmGetPixmap
- * Signature: (I[BII)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmap
- (JNIEnv *env, jclass that, jint screen, jbyteArray name, jint fgPixel, jint bgPixel)
-{
- jbyte* name1 = NULL;
- jint pixmap;
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmGetPixmap\n");
-#endif
-
- if (name) name1 = (*env)->GetByteArrayElements(env, name, NULL);
- pixmap = (jint) XmGetPixmap((Screen*)screen, (char*)name1, (Pixel)fgPixel, (Pixel)bgPixel);
- if (name) (*env)->ReleaseByteArrayElements(env, name, name1, 0);
- return pixmap;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
* Method: XmGetXmDisplay
* Signature: (I)I
*/
@@ -5318,9 +5236,8 @@ JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmWidgetGetDis
* Method: XmbLookupString
* Signature: (ILorg/eclipse/swt/internal/motif/XInputEvent;[BI[I[I)I
*/
-/*
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmbLookupString
- (JNIEnv *env, jclass that, jint ic, jobject event, jbyteArray string, jint size, jintArray keysym, jintArray status)
+ (JNIEnv *env, jclass that, jint widget, jobject event, jbyteArray string, jint size, jintArray keysym, jintArray status)
{
DECL_GLOB(pGlob)
XEvent xEvent, *lpxEvent=NULL;
@@ -5343,11 +5260,11 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmbLookupString
if (status)
status1 = (*env)->GetIntArrayElements(env, status, NULL);
- rc = (jint)XmbLookupString((XIC)ic, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
+ rc = (jint)XmImMbLookupString((Widget)widget, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
#ifdef PRINT_FAILED_RCODES
if (rc == 0)
- fprintf(stderr, "XmbLookupString: call failed rc = %d\n", rc);
+ fprintf(stderr, "XmImMbLookupString: call failed rc = %d\n", rc);
#endif
if (event) {
@@ -5361,7 +5278,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmbLookupString
(*env)->ReleaseIntArrayElements(env, status, status1, 0);
return rc;
}
-*/
/*
* Class: org_eclipse_swt_internal_motif_OS
@@ -6598,6 +6514,43 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardEndRetr
/*
* Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpmReadFileToPixmap
+ * Signature: (II[B[I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpmReadFileToPixmap
+ (JNIEnv *env, jclass that, jint display, jint drawable, jbyteArray fileName, jintArray pixmap_return, jintArray shapemask_return, jint attributes)
+{
+#ifdef XPM
+ jint rc;
+ jbyte *fileName1 = NULL;
+ jint *pixmap_return1 = NULL;
+ jint *shapemask_return1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpmReadFileToPixmap\n");
+#endif
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ if (pixmap_return) pixmap_return1 = (*env)->GetIntArrayElements(env, pixmap_return, NULL);
+ if (shapemask_return) shapemask_return1 = (*env)->GetIntArrayElements(env, shapemask_return, NULL);
+
+ rc = (jint) XpmReadFileToPixmap((Display *)display,
+ drawable,
+ fileName1,
+ (Pixmap*) pixmap_return1,
+ (Pixmap*) shapemask_return1,
+ attributes);
+
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ if (pixmap_return) (*env)->ReleaseIntArrayElements(env, pixmap_return, pixmap_return1, 0);
+ if (shapemask_return) (*env)->ReleaseIntArrayElements(env, shapemask_return, shapemask_return1, 0);
+ return rc;
+#endif
+#ifndef XPM
+ return -1;
+#endif
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
* Method: XmCreateDrawnButton
* Signature: (I[B[II)I
*/
@@ -7035,7 +6988,7 @@ JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTabListInsertTabs
* Method: XmDestroyPixmap
* Signature: (II)Z
*/
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixmap
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixmap
(JNIEnv *env, jclass that, jint screen, jint pixmap)
{
#ifdef DEBUG_CALL_PRINTS
@@ -7043,13 +6996,14 @@ JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixma
#endif
return (jboolean) XmDestroyPixmap((Screen *)screen, pixmap);
}
+*/
/*
* Class: org_eclipse_swt_internal_motif_OS
* Method: XmGetPixmapByDepth
* Signature: (I[BIII)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
(JNIEnv *env, jclass that, jint screen, jbyteArray image_name, jint foreground, jint background, jint depth)
{
jbyte *image_name1=NULL;
@@ -7072,7 +7026,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
(*env)->ReleaseByteArrayElements(env, image_name, image_name1, 0);
return rc;
}
-
+*/
/*
* Class: org_eclipse_swt_internal_motif_OS
@@ -7641,8 +7595,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetIOErrorHandler
* ======== Start printing functions ========
*/
-#ifndef NO_XPRINTING_EXTENSIONS
-
/*
* Class: org_eclipse_swt_internal_motif_OS
* Method: XpCreateContext
@@ -7909,35 +7861,6 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpCancelJob
/*
* Class: org_eclipse_swt_internal_motif_OS
- * Method: XpQueryVersion
- * Signature: (I[S[S)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpQueryVersion
- (JNIEnv *env, jclass that, jint display, jshortArray major_version, jshortArray minor_version)
-{
- jshort *major_version1=NULL, *minor_version1=NULL;
- jint rc;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XpQueryVersion\n");
-#endif
-
- if (major_version)
- major_version1 = (*env)->GetShortArrayElements(env, major_version, NULL);
- if (minor_version)
- minor_version1 = (*env)->GetShortArrayElements(env, minor_version, NULL);
- rc = (jint) XpQueryVersion((Display *)display, (short *)major_version1, (short *)minor_version1);
- if (major_version)
- (*env)->ReleaseShortArrayElements(env, major_version, major_version1, 0);
- if (minor_version)
- (*env)->ReleaseShortArrayElements(env, minor_version, minor_version1, 0);
-
- return rc;
-}
-
-#endif /* ! NO_XPRINTING_EXTENSIONS */
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
* Method: XDefaultGCOfScreen
* Signature: (I)I
*/
@@ -8023,6 +7946,33 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDestroyWindow
}
/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpQueryVersion
+ * Signature: (I[S[S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpQueryVersion
+ (JNIEnv *env, jclass that, jint display, jshortArray major_version, jshortArray minor_version)
+{
+ jshort *major_version1=NULL, *minor_version1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpQueryVersion\n");
+#endif
+
+ if (major_version)
+ major_version1 = (*env)->GetShortArrayElements(env, major_version, NULL);
+ if (minor_version)
+ minor_version1 = (*env)->GetShortArrayElements(env, minor_version, NULL);
+ rc = (jint) XpQueryVersion((Display *)display, (short *)major_version1, (short *)minor_version1);
+ if (major_version)
+ (*env)->ReleaseShortArrayElements(env, major_version, major_version1, 0);
+ if (minor_version)
+ (*env)->ReleaseShortArrayElements(env, minor_version, minor_version1, 0);
+
+ return rc;
+}
+
+/*
* ======== End printing functions ========
*/
@@ -8065,7 +8015,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_read
if (buf)
buf1 = (*env)->GetByteArrayElements(env, buf, NULL);
- rc = (jint) read(filedes, (char *)buf1, nbyte);
+ rc = (jint) read(filedes, (char *)buf, nbyte);
if (buf)
(*env)->ReleaseByteArrayElements(env, buf, buf1, 0);
@@ -8088,7 +8038,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_write
if (buf)
buf1 = (*env)->GetByteArrayElements(env, buf, NULL);
- rc = (jint) write(filedes, (char *)buf1, nbyte);
+ rc = (jint) write(filedes, (char *)buf, nbyte);
if (buf)
(*env)->ReleaseByteArrayElements(env, buf, buf1, 0);
@@ -8139,484 +8089,3 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtRemoveInput
XtRemoveInput((XtInputId)id);
}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImGetXIC
- * Signature: (II[II)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImGetXIC
- (JNIEnv *env, jclass that, jint widget, jint input_policy, jintArray args, jint num_args)
-{
- jint *args1=NULL;
- jint rc;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImGetXIC\n");
-#endif
- if (args)
- args1 = (*env)->GetIntArrayElements(env, args, NULL);
- rc = (jint) XmImGetXIC((Widget)widget, (XmInputPolicy)input_policy, (ArgList)args1, num_args);
- if (args)
- (*env)->ReleaseIntArrayElements(env, args, args1, 0);
-
- return rc;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImGetXIM
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImGetXIM
- (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImGetXIM\n");
-#endif
-
- return (jint) XmImGetXIM((Widget)widget);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImRegister
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImRegister
- (JNIEnv *env, jclass that, jint widget, jint reserved)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImRegister\n");
-#endif
-
- XmImRegister((Widget)widget, reserved);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImSetFocusValues
- * Signature: (I[II)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImSetFocusValues
- (JNIEnv *env, jclass that, jint widget, jintArray args, jint num_args)
-{
- jint *args1=NULL;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImSetFocusValues\n");
-#endif
- if (args)
- args1 = (*env)->GetIntArrayElements(env, args, NULL);
- XmImSetFocusValues((Widget)widget, (ArgList)args1, num_args);
- if (args)
- (*env)->ReleaseIntArrayElements(env, args, args1, 0);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImVaSetFocusValues
- * Signature: (IIIIIIIIII)I
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImVaSetFocusValues
- (JNIEnv *env, jclass that, jint widget, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImVaSetFocusValues\n");
-#endif
- XmImVaSetFocusValues((Widget)widget, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImSetValues
- * Signature: (I[II)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImSetValues
- (JNIEnv *env, jclass that, jint widget, jintArray args, jint num_args)
-{
- jint *args1=NULL;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImSetValues\n");
-#endif
- if (args)
- args1 = (*env)->GetIntArrayElements(env, args, NULL);
- XmImSetValues((Widget)widget, (ArgList)args1, num_args);
- if (args)
- (*env)->ReleaseIntArrayElements(env, args, args1, 0);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImUnregister
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImUnregister
- (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImUnregister\n");
-#endif
-
- XmImUnregister((Widget)widget);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XmImUnsetFocus
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImUnsetFocus
- (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XmImUnsetFocus\n");
-#endif
-
- XmImUnsetFocus((Widget)widget);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XCreateIC
- * Signature: (IIIIIIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateIC
- (JNIEnv *env, jclass that, jint im, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XCreateIC\n");
-#endif
-
- return (jint)XCreateIC((XIM)im, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XSetICValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetICValues
- (JNIEnv *env, jclass that, jint ic, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XSetICValues\n");
-#endif
-
- return (jint)XSetICValues((XIC)ic, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XGetICValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetICValues
- (JNIEnv *env, jclass that, jint ic, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XGetICValues\n");
-#endif
-
- return (jint)XGetICValues((XIC)ic, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XSetICFocus
- * Signature: (I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetICFocus
- (JNIEnv *env, jclass that, jint ic)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XSetICFocus\n");
-#endif
-
- XSetICFocus((XIC)ic);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XUnsetICFocus
- * Signature: (I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XUnsetICFocus
- (JNIEnv *env, jclass that, jint ic)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XUnsetICFocus\n");
-#endif
-
- XUnsetICFocus((XIC)ic);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XGetIMValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetIMValues
- (JNIEnv *env, jclass that, jint im, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XGetIMValues\n");
-#endif
-
- return (jint)XGetIMValues((XIM)im, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: memmove
- * Signature: (I[SI)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3SI
- (JNIEnv *env, jclass that, jint dest, jshortArray src, jint count)
-{
- jshort *src1;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "memmove__I_3SI\n");
-#endif
-
- /* don't do anything if src pointer is NULL */
- if (src) {
- src1 = (*env)->GetShortArrayElements(env, src, NULL);
- memmove((void *)dest, (void *)src1, count);
- (*env)->ReleaseShortArrayElements(env, src, src1, 0);
- }
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: nl_langinfo
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_nl_1langinfo
- (JNIEnv *env, jclass that, jint item)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "nl_langinfo\n");
-#endif
-
- return (jint)nl_langinfo(item);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: iconv_open
- * Signature: ([B[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv_1open
- (JNIEnv *env, jclass that, jbyteArray tocode, jbyteArray fromcode)
-{
- jbyte *tocode1=NULL, *fromcode1=NULL;
- jint result;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "iconv_open\n");
-#endif
- if (tocode)
- tocode1 = (*env)->GetByteArrayElements(env, tocode, NULL);
- if (fromcode)
- fromcode1 = (*env)->GetByteArrayElements(env, fromcode, NULL);
- result = (jint)iconv_open(tocode1, fromcode1);
- if (tocode)
- (*env)->ReleaseByteArrayElements(env, tocode, tocode1, 0);
- if (fromcode)
- (*env)->ReleaseByteArrayElements(env, fromcode, fromcode1, 0);
-
- return result;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: iconv_close
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv_1close
- (JNIEnv *env, jclass that, jint cd)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "iconv_close\n");
-#endif
-
- return (jint)iconv_close((iconv_t)cd);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: iconv
- * Signature: (I[BI[BI)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv
- (JNIEnv *env, jclass that, jint cd, jintArray inBuf, jintArray inBytesLeft, jintArray outBuf, jintArray outBytesLeft)
-{
- jint *inBuf1=NULL, *outBuf1=NULL, *inBytesLeft1=NULL, *outBytesLeft1=NULL;
- jint result;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "iconv\n");
-#endif
- if (inBuf)
- inBuf1 = (*env)->GetIntArrayElements(env, inBuf, NULL);
- if (outBuf)
- outBuf1 = (*env)->GetIntArrayElements(env, outBuf, NULL);
- if (inBytesLeft)
- inBytesLeft1 = (*env)->GetIntArrayElements(env, inBytesLeft, NULL);
- if (outBytesLeft)
- outBytesLeft1 = (*env)->GetIntArrayElements(env, outBytesLeft, NULL);
- result = (jint)iconv((iconv_t)cd, (void *)inBuf1, (size_t *)inBytesLeft1, (char **)outBuf1, (size_t *)outBytesLeft1);
- if (inBuf)
- (*env)->ReleaseIntArrayElements(env, inBuf, inBuf1, 0);
- if (outBuf)
- (*env)->ReleaseIntArrayElements(env, outBuf, outBuf1, 0);
- if (inBytesLeft)
- (*env)->ReleaseIntArrayElements(env, inBytesLeft, inBytesLeft1, 0);
- if (outBytesLeft)
- (*env)->ReleaseIntArrayElements(env, outBytesLeft, outBytesLeft1, 0);
- return result;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: MB_1CUR_1MAX
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_MB_1CUR_1MAX
- (JNIEnv *env, jclass that)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "MB_1CUR_1MAX\n");
-#endif
-
- return (jint)MB_CUR_MAX;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: memmove
- * Signature: ([CII)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove___3CII
- (JNIEnv *env, jclass that, jcharArray dest, jint src, jint count)
-{
- jchar *dest1;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "memmove___3CII\n");
-#endif
-
- if (dest) {
- dest1 = (*env)->GetCharArrayElements(env, dest, NULL);
- memmove((void *)dest1, (void *)src, count);
- (*env)->ReleaseCharArrayElements(env, dest, dest1, 0);
- }
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: memmove
- * Signature: (I[CI)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3CI
- (JNIEnv *env, jclass that, jint dest, jcharArray src, jint count)
-{
- jchar *src1;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "memmove__I_3CI\n");
-#endif
-
- if (src) {
- int i;
- unsigned char *dest1 = (unsigned char *)dest;
- src1 = (*env)->GetCharArrayElements(env, src, NULL);
- memmove((void *)dest, (void *)src1, count);
- (*env)->ReleaseCharArrayElements(env, src, src1, 0);
- }
-}
-*/
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XCreateFontSet
- * Signature: (I[B[I[I[I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateFontSet
- (JNIEnv *env, jclass that, jint display, jbyteArray base_font_name_list, jintArray missing_charset_list_return, jintArray missing_charset_count_return, jintArray def_string_return)
-{
- jbyte *base_font_name_list1=NULL;
- jint *missing_charset_list_return1=NULL, *missing_charset_count_return1=NULL, *def_string_return1=NULL;
- jint result;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XCreateFontSet\n");
-#endif
- if (base_font_name_list)
- base_font_name_list1 = (*env)->GetByteArrayElements(env, base_font_name_list, NULL);
- if (missing_charset_list_return)
- missing_charset_list_return1 = (*env)->GetIntArrayElements(env, missing_charset_list_return, NULL);
- if (missing_charset_count_return)
- missing_charset_count_return1 = (*env)->GetIntArrayElements(env, missing_charset_count_return, NULL);
- if (def_string_return)
- def_string_return1 = (*env)->GetIntArrayElements(env, def_string_return, NULL);
- result = (jint)XCreateFontSet((Display *)display, (char *)base_font_name_list1, (char ***)missing_charset_list_return1, (int *)missing_charset_count_return1, (char **)def_string_return1);
- if (base_font_name_list)
- (*env)->ReleaseByteArrayElements(env, base_font_name_list, base_font_name_list1, 0);
- if (missing_charset_list_return)
- (*env)->ReleaseIntArrayElements(env, missing_charset_list_return, missing_charset_list_return1, 0);
- if (missing_charset_count_return)
- (*env)->ReleaseIntArrayElements(env, missing_charset_count_return, missing_charset_count_return1, 0);
- if (def_string_return)
- (*env)->ReleaseIntArrayElements(env, def_string_return, def_string_return1, 0);
- return result;
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: XLocaleOfFontSet
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XLocaleOfFontSet
- (JNIEnv *env, jclass that, jint fontSet)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "XLocaleOfFontSet\n");
-#endif
-
- return (jint)XLocaleOfFontSet((XFontSet)fontSet);
-}
-
-/*
- * Class: org_eclipse_swt_internal_motif_OS
- * Method: setlocale
- * Signature: (I[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_setlocale
- (JNIEnv *env, jclass that, int category, jbyteArray locale)
-{
- jbyte *locale1=NULL;
- jint rc;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "setlocale\n");
-#endif
-
- if (locale)
- locale1 = (*env)->GetByteArrayElements(env, locale, NULL);
- rc = (jint) setlocale(category, (char *)locale1);
- if (locale)
- (*env)->ReleaseByteArrayElements(env, locale, locale1, 0);
-
- return rc;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
index 5dc1701dfb..07ff9ce115 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
@@ -306,7 +306,6 @@ public FontData [] getFontList (String faceName, boolean scalable) {
xlfd = "-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*";
}
}
- /* Use the character encoding for the default locale */
byte [] buffer1 = Converter.wcsToMbcs (null, xlfd, true);
int [] ret = new int [1];
int listPtr = OS.XListFonts (xDisplay, buffer1, 65535, ret);
@@ -320,7 +319,6 @@ public FontData [] getFontList (String faceName, boolean scalable) {
int length = OS.strlen (charPtr);
byte [] buffer2 = new byte [length];
OS.memmove (buffer2, charPtr, length);
- /* Use the character encoding for the default locale */
char [] chars = Converter.mbcsToWcs (null, buffer2);
FontData data = FontData.motif_new (new String (chars));
boolean isScalable = data.averageWidth == 0 && data.pixels == 0 && data.points == 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
index 838b61bfe4..3345d70dde 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
@@ -8,7 +8,6 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.motif.*;
import org.eclipse.swt.*;
-import java.util.Locale;
/**
* Instances of this class manage operating system resources that
@@ -175,7 +174,6 @@ public FontData[] getFontData() {
int length = OS.strlen(ptr);
byte[] nameBuf = new byte[length];
OS.memmove(nameBuf, ptr, length);
- /* Use the character encoding for the default locale */
String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
/* Add the xlfd to the array */
String[] newXlfds = new String[xlfds.length + 1];
@@ -253,35 +251,26 @@ public int hashCode () {
return handle;
}
int loadFont(int xDisplay, FontData fd) {
- /* Use the character encoding for the default locale */
byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
return OS.XLoadQueryFont(xDisplay, buffer);
}
-int loadFontSet(int xDisplay, FontData fd) {
- /* Use the character encoding for the default locale */
- byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
- int [] missing_charset = new int [1];
- int [] missing_charset_count = new int [1];
- int [] def_string = new int [1];
- return OS.XCreateFontSet(xDisplay, buffer, missing_charset, missing_charset_count, def_string);
-}
-int matchFont(int xDisplay, FontData fd, boolean fontSet) {
- int font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
- if (font != 0) return font;
+int matchFont(int xDisplay, FontData fd) {
+ int fontStruct = loadFont(xDisplay, fd);
+ if (fontStruct != 0) return fontStruct;
if (fd.slant != null) {
fd.slant = null;
- font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
- if (font != 0) return font;
+ fontStruct = loadFont(xDisplay, fd);
+ if (fontStruct != 0) return fontStruct;
}
if (fd.weight != null) {
fd.weight = null;
- font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
- if (font != 0) return font;
+ fontStruct = loadFont(xDisplay, fd);
+ if (fontStruct != 0) return fontStruct;
}
if (fd.points != 0) {
fd.points = 0;
- font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
- if (font != 0) return font;
+ fontStruct = loadFont(xDisplay, fd);
+ if (fontStruct != 0) return fontStruct;
}
return 0;
}
@@ -290,53 +279,8 @@ void init (Device device, FontData fd) {
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = device;
int xDisplay = device.xDisplay;
- int fontListEntry;
-// int fontStruct = loadFont(xDisplay, fd);
-// if (fontStruct == 0) {
-// /*
-// * If the desired font can not be loaded, the XLFD fields are wildcard
-// * in order to preserve the font style and height. If there is no
-// * font with the desired style and height, the slant, weight and points
-// * are wildcard in that order, until a font can be loaded.
-// */
-// FontData newFD = new FontData();
-// newFD.slant = fd.slant;
-// newFD.weight = fd.weight;
-// newFD.points = fd.points;
-// newFD.characterSetName = fd.characterSetName;
-// if (newFD.characterSetName == null) {
-// newFD.characterSetName = device.characterSetName;
-// }
-// newFD.characterSetRegistry = fd.characterSetRegistry;
-// if (newFD.characterSetRegistry == null) {
-// newFD.characterSetRegistry = device.characterSetRegistry;
-// }
-// fontStruct = matchFont(xDisplay, newFD, false);
-//
-// /* Failed to load any font. Use the system font. */
-// if (fontStruct == 0) {
-// handle = device.systemFont;
-// if (handle != 0) return;
-// }
-// }
-// fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);
- Locale locale = fd.locale;
- if (locale != null) {
- String lang = locale.getLanguage();
- String country = locale.getCountry();
- String variant = locale.getVariant();
- String osLocale = lang;
- if (country != null && country.length() > 0) osLocale += "_" + country;
- if (variant != null && variant.length() > 0) osLocale += "." + variant;
- int length = osLocale.length();
- byte [] buffer = new byte[length + 1];
- for (int i=0; i<length; i++) {
- buffer[i] = (byte)osLocale.charAt(i);
- }
- OS.setlocale (OS.LC_CTYPE, buffer);
- }
- int fontSet = loadFontSet(xDisplay, fd);
- if (fontSet == 0) {
+ int fontStruct = loadFont(xDisplay, fd);
+ if (fontStruct == 0) {
/*
* If the desired font can not be loaded, the XLFD fields are wildcard
* in order to preserve the font style and height. If there is no
@@ -355,16 +299,16 @@ void init (Device device, FontData fd) {
if (newFD.characterSetRegistry == null) {
newFD.characterSetRegistry = device.characterSetRegistry;
}
- fontSet = matchFont(xDisplay, newFD, true);
- }
- if (locale != null) OS.setlocale (OS.LC_CTYPE, new byte [0]);
-
- /* Failed to load any font. Use the system font. */
- if (fontSet == 0) {
- handle = device.systemFont;
- if (handle != 0) return;
+ fontStruct = matchFont(xDisplay, newFD);
+
+ /* Failed to load any font. Use the system font. */
+ if (fontStruct == 0) {
+ handle = device.systemFont;
+ if (handle != 0) return;
+ }
}
- fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONTSET, fontSet);
+ if (fontStruct == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);
if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);
handle = OS.XmFontListAppendEntry(0, fontListEntry);
OS.XmFontListEntryFree(new int[]{fontListEntry});
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
index 977b0e02a7..ac4958afe4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
@@ -6,7 +6,6 @@ package org.eclipse.swt.graphics;
*/
import org.eclipse.swt.*;
-import java.util.Locale;
/**
* Instances of this class describe operating system fonts.
@@ -104,12 +103,6 @@ public final class FontData {
* Warning: This field is platform dependent.
*/
public String characterSetName;
-
- /**
- * The locale of the font
- * (Warning: This field is platform dependent)
- */
- Locale locale;
/**
* Constructs a new un-initialized font data.
*/
@@ -388,15 +381,6 @@ public void setName(String name) {
fontFamily = name;
}
}
-/**
- * Sets the locale of the receiver.
- *
- * @param locale the Locale of the <code>FontData</code>
- *
- */
-public void setLocale(Locale locale) {
- this.locale = locale;
-}
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
index a6af8a5afb..36f1186e8a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
@@ -413,14 +413,12 @@ void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHei
blues[i] = (byte)((color.blue >> 8) & 0xFF);
}
ImageData.blit(ImageData.BLIT_ALPHA,
- srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, reds, greens, blues,
- srcImage.alpha, srcImage.alphaData, imgWidth,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, reds, greens, blues, srcImage.alpha, srcImage.alphaData, imgWidth,
destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, reds, greens, blues,
false, false);
} else {
ImageData.blit(ImageData.BLIT_ALPHA,
- srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask,
- srcImage.alpha, srcImage.alphaData, imgWidth,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask, srcImage.alpha, srcImage.alphaData, imgWidth,
destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask,
false, false);
}
@@ -518,11 +516,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
int bplX = ((destWidth + 7) / 8 + 3) & 0xFFFC;
int bufSize = bplX * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 1, xSrcImage.bytes_per_line, bitOrder, 0, 0, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 1, bplX, bitOrder, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
+ ImageData.stretch1(srcData, xSrcImage.bytes_per_line, bitOrder, 0, 0, srcWidth, srcHeight, buf, bplX, bitOrder, 0, 0, destWidth, destHeight, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
@@ -540,11 +534,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
int bplX = (destWidth + 3) & 0xFFFC;
int bufSize = bplX * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 4, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 4, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
+ ImageData.stretch4(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImagePtr = OS.XCreateImage(display, visual, 4, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
@@ -554,11 +544,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
int bplX = (destWidth + 3) & 0xFFFC;
int bufSize = bplX * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 8, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 8, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
+ ImageData.stretch8(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImagePtr = OS.XCreateImage(display, visual, 8, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
@@ -571,11 +557,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
OS.memmove(xImage, xImagePtr, XImage.sizeof);
int bufSize = xImage.bytes_per_line * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 16, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 16, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,
- flipX, flipY);
+ ImageData.stretch16(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImage.data = bufPtr;
@@ -589,11 +571,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
OS.memmove(xImage, xImagePtr, XImage.sizeof);
int bufSize = xImage.bytes_per_line * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 24, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 24, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,
- flipX, flipY);
+ ImageData.stretch24(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImage.data = bufPtr;
@@ -607,11 +585,7 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
OS.memmove(xImage, xImagePtr, XImage.sizeof);
int bufSize = xImage.bytes_per_line * destHeight;
byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, 32, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 32, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,
- flipX, flipY);
+ ImageData.stretch32(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
int bufPtr = OS.XtMalloc(bufSize);
OS.memmove(bufPtr, buf, bufSize);
xImage.data = bufPtr;
@@ -849,7 +823,7 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
}
if (nh < 0) {
nh = 0 - nh;
- ny = ny - nh;
+ ny = ny -nh;
}
if (naw < 0)
naw = 0 - naw;
@@ -861,33 +835,14 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
int xDisplay = data.display;
int xDrawable = data.drawable;
-
- if (nw > naw) {
- if (nh > nah) {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx, ny + nah2, nx, ny + nh - nah2);
- } else {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
- }
- } else {
- if (nh > nah) {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx, ny + nah2, nx, ny + nh - nah2);
- } else {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
- }
- }
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny, nx + nw - naw2, ny);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx,ny + nah2, nx, ny + nh - nah2);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
}
/**
* Draws the given string, using the receiver's current font and
@@ -933,7 +888,7 @@ public void drawString (String string, int x, int y) {
public void drawString (String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
int xmString = OS.XmStringCreate (buffer, OS.XmFONTLIST_DEFAULT_TAG);
if (isTransparent) {
OS.XmStringDraw (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
@@ -1041,7 +996,7 @@ public void drawText (String string, int x, int y, boolean isTransparent) {
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (data.renderTable == 0) createRenderTable();
int renderTable = data.renderTable;
- byte [] textBuffer = Converter.wcsToMbcs (getCodePage (), string, true);
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, true);
int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);
if (isTransparent) {
OS.XmStringDraw (data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
@@ -1121,105 +1076,6 @@ public void fillArc(int x, int y, int width, int height, int startAngle, int end
OS.XFillArc(xDisplay,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64);
OS.XSetForeground (xDisplay, handle, values.foreground);
}
-
-/**
- * Fills the interior of the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
- */
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if ((width == 0) || (height == 0)) return;
- int xDisplay = data.display;
- int xScreenNum = OS.XDefaultScreen(xDisplay);
- XGCValues values = new XGCValues();
- int fromColor, toColor;
- OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
- fromColor = values.foreground;
- toColor = values.background;
- boolean swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- final int t = fromColor;
- fromColor = toColor;
- toColor = t;
- }
- if (fromColor == toColor) {
- OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height);
- return;
- }
- /* X Window deals with a virtually limitless array of color formats
- * but we only distinguish between paletted and direct modes
- */
- final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay);
- final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum);
- Visual visual = new Visual();
- OS.memmove(visual, xVisual, visual.sizeof);
- final int depth = OS.XDefaultDepthOfScreen(xScreen);
- final boolean directColor = (depth > 8);
-
- // This code is intentionally commented since elsewhere in SWT we
- // assume that depth <= 8 means we are in a paletted mode though
- // this is not always the case.
- //final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor);
-
- XColor xColor = new XColor();
- xColor.pixel = fromColor;
- OS.XQueryColor(xDisplay, data.colormap, xColor);
- final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
- xColor.pixel = toColor;
- OS.XQueryColor(xDisplay, data.colormap, xColor);
- final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
-
- final int redBits, greenBits, blueBits;
- if (directColor) {
- // RGB mapped display
- redBits = getChannelWidth(visual.red_mask);
- greenBits = getChannelWidth(visual.green_mask);
- blueBits = getChannelWidth(visual.blue_mask);
- } else {
- // Index display
- redBits = greenBits = blueBits = 0;
- }
- ImageData.fillGradientRectangle(this, data.device,
- x, y, width, height, vertical, fromRGB, toRGB,
- redBits, greenBits, blueBits);
-}
-
-/**
- * Computes the required channel width (depth) from a mask.
- */
-static int getChannelWidth(int mask) {
- int width = 0;
- while (mask != 0) {
- width += (mask & 1);
- mask >>>= 1;
- }
- return width;
-}
-
/**
* Fills the interior of an oval, within the specified
* rectangular area, with the receiver's background
@@ -1283,7 +1139,7 @@ public void fillPolygon(int[] pointArray) {
XGCValues values = new XGCValues ();
OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
OS.XSetForeground (xDisplay, handle, values.background);
- OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Complex, OS.CoordModeOrigin);
+ OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Convex, OS.CoordModeOrigin);
OS.XSetForeground (xDisplay, handle, values.foreground);
}
/**
@@ -1376,6 +1232,9 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt
if (nah < 0)
nah = 0 - nah;
+ naw = naw < nw ? naw : nw;
+ nah = nah < nh ? nah : nh;
+
int naw2 = naw / 2;
int nah2 = nah / 2;
@@ -1384,30 +1243,13 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt
XGCValues values = new XGCValues ();
OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
OS.XSetForeground(xDisplay, handle, values.background);
-
- if (nw > naw) {
- if (nh > nah) {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nah2);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny + nh - nah2, nw - naw, nah2);
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
- } else {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nh);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
- }
- } else {
- if (nh > nah) {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
- } else {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
- }
- }
+ OS.XFillArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx + naw2, ny, nw - naw, nh);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx,ny + nah2, naw2, nh - nah);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx + nw - (naw / 2), ny + nah2, naw2, nh -nah);
OS.XSetForeground(xDisplay, handle, values.foreground);
}
/**
@@ -1428,7 +1270,7 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int fontList = data.fontList;
- byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), new char[] { ch }, false);
+ byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);
int val = charBuffer[0] & 0xFF;
/* Create a font context to iterate over each element in the font list */
int[] buffer = new int[1];
@@ -1526,7 +1368,11 @@ public Color getBackground() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int xDisplay = data.display;
XGCValues values = new XGCValues();
- OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values);
+ if (OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values) == 0) {
+ // Check error case here. If a palette has been set we may be able
+ // to do a better job.
+ return null;
+ }
XColor xColor = new XColor();
xColor.pixel = values.background;
OS.XQueryColor(xDisplay,data.colormap,xColor);
@@ -1552,7 +1398,7 @@ public Color getBackground() {
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int fontList = data.fontList;
- byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), new char[] { ch }, false);
+ byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);
int val = charBuffer[0] & 0xFF;
/* Create a font context to iterate over each element in the font list */
int[] buffer = new int[1];
@@ -1694,9 +1540,6 @@ public void getClipping(Region region) {
OS.XSubtractRegion (hRegion, hRegion, hRegion);
OS.XUnionRegion (clipRgn, hRegion, hRegion);
}
-String getCodePage () {
- return Converter.getCodePage(data.display, data.fontList);
-}
/**
* Returns the font currently being used by the receiver
* to draw and measure text.
@@ -1929,7 +1772,11 @@ public Color getForeground() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int xDisplay = data.display;
XGCValues values = new XGCValues();
- OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values);
+ if (OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values) == 0) {
+ // Check error case here. If a palette has been set we may be able
+ // to do a better job.
+ return null;
+ }
XColor xColor = new XColor();
xColor.pixel = values.foreground;
OS.XQueryColor(xDisplay,data.colormap,xColor);
@@ -2307,7 +2154,7 @@ public Point stringExtent(String string) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (string.length () == 0) return new Point(0, getFontHeight());
- byte[] buffer = Converter.wcsToMbcs(getCodePage (), string, true);
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
int xmString = OS.XmStringCreate(buffer, OS.XmFONTLIST_DEFAULT_TAG);
int fontList = data.fontList;
int width = OS.XmStringWidth(fontList, xmString);
@@ -2338,7 +2185,7 @@ public Point textExtent(String string) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (string.length () == 0) return new Point(0, getFontHeight());
- byte [] textBuffer = Converter.wcsToMbcs (getCodePage (), string, true);
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, true);
int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);
if (data.renderTable == 0) createRenderTable();
int renderTable = data.renderTable;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
index d3594e936d..70d84c99d2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
@@ -453,7 +453,6 @@ public Image(Device device, Image srcImage, int flag) {
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
* </ul>
*/
public Image(Device device, Rectangle bounds) {
@@ -690,11 +689,6 @@ public ImageData getImageData() {
OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);
/* Calculate the palette depending on the display attributes */
PaletteData palette = null;
-
- /* Get the data for the source image. */
- int length = xSrcImage.bytes_per_line * xSrcImage.height;
- byte[] srcData = new byte[length];
- OS.memmove(srcData, xSrcImage.data, length);
switch (xSrcImage.depth) {
case 1:
palette = new PaletteData(new RGB[] {
@@ -709,40 +703,13 @@ public ImageData getImageData() {
*/
SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
case 8:
- /* Normalize the pixels in the source image data (by making the
- * pixel values sequential starting at pixel 0). Reserve normalized
- * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is
- * always used in the image.
- */
- byte[] normPixel = new byte[ 256 ];
- for (int index = 0; index < normPixel.length; index++) {
- normPixel[ index ] = 0;
- }
- int numPixels = 1;
- int index = 0;
- for (int y = 0; y < xSrcImage.height; y++) {
- for (int x = 0; x < xSrcImage.bytes_per_line; x++) {
- int srcPixel = srcData[ index + x ] & 0xFF;
- if (srcPixel != 0 && normPixel[ srcPixel ] == 0) {
- normPixel[ srcPixel ] = (byte)numPixels++;
- }
- srcData[ index + x ] = normPixel[ srcPixel ];
- }
- index += xSrcImage.bytes_per_line;
- }
-
- /* Create a palette with only the RGB values used in the image. */
- int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
- RGB[] rgbs = new RGB[ numPixels ];
- XColor color = new XColor();
- for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) {
- // If the pixel value was used in the image, get its RGB values.
- if (srcPixel == 0 || normPixel[ srcPixel ] != 0) {
- color.pixel = srcPixel;
- OS.XQueryColor(xDisplay, colormap, color);
- int rgbIndex = normPixel[ srcPixel ] & 0xFF;
- rgbs[ rgbIndex ] = new RGB((color.red >> 8) & 0xFF, (color.green >> 8) & 0xFF, (color.blue >> 8) & 0xFF);
- }
+ /* Use the RGBs from the display to make the palette */
+ XColor[] xcolors = device.xcolors;
+ RGB[] rgbs = new RGB[xcolors.length];
+ for (int i = 0; i < rgbs.length; i++) {
+ XColor xcolor = xcolors[i];
+ if (xcolor == null) rgbs[i] = new RGB(0, 0, 0);
+ else rgbs[i] = new RGB((xcolor.red >> 8) & 0xFF, (xcolor.green >> 8) & 0xFF, (xcolor.blue >> 8) & 0xFF);
}
palette = new PaletteData(rgbs);
break;
@@ -764,7 +731,9 @@ public ImageData getImageData() {
SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
}
ImageData data = new ImageData(width, height, xSrcImage.depth, palette);
- data.data = srcData;
+ int length = xSrcImage.bytes_per_line * xSrcImage.height;
+ data.data = new byte[length];
+ OS.memmove(data.data, xSrcImage.data, length);
if (xSrcImage.bits_per_pixel == 32) {
/**
* If bits per pixel is 32, scale the data down to 24, since we do not
@@ -778,7 +747,7 @@ public ImageData getImageData() {
int srcIndex = 0;
int rOffset = 0, gOffset = 1, bOffset = 2;
if (xSrcImage.byte_order == OS.MSBFirst) {
- rOffset = 3; gOffset = 2; bOffset = 1;
+ rOffset = 2; gOffset = 1; bOffset = 0;
}
for (int y = 0; y < height; y++) {
destIndex = y * bytesPerLine;
@@ -985,7 +954,6 @@ void init(Device device, ImageData image) {
* @private
*/
public int internal_new_GC (GCData data) {
- if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (type != SWT.BITMAP || memGC != null) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
@@ -1053,7 +1021,7 @@ public static Image motif_new(Device device, int type, int pixmap, int mask) {
static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, int display, int visual, int screenDepth, XColor[] xcolors, int[] transparentPixel, int drawable, int gc) {
PaletteData palette = image.palette;
if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||
- ((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))
+ ((image.depth == 16 || image.depth == 24) && palette.isDirect)))
return SWT.ERROR_UNSUPPORTED_DEPTH;
boolean flipX = destWidth < 0;
@@ -1067,7 +1035,7 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
destY = destY - destHeight;
}
byte[] srcReds = null, srcGreens = null, srcBlues = null;
- if (! palette.isDirect) {
+ if (image.depth <= 8) {
int length = palette.getRGBs().length;
srcReds = new byte[length];
srcGreens = new byte[length];
@@ -1083,7 +1051,6 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
}
byte[] destReds = null, destGreens = null, destBlues = null;
int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;
- final boolean screenDirect;
if (screenDepth <= 8) {
if (xcolors == null) return SWT.ERROR_UNSUPPORTED_DEPTH;
destReds = new byte[xcolors.length];
@@ -1096,14 +1063,12 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
destGreens[i] = (byte)((color.green >> 8) & 0xFF);
destBlues[i] = (byte)((color.blue >> 8) & 0xFF);
}
- screenDirect = false;
} else {
Visual xVisual = new Visual();
OS.memmove(xVisual, visual, Visual.sizeof);
destRedMask = xVisual.red_mask;
destGreenMask = xVisual.green_mask;
destBlueMask = xVisual.blue_mask;
- screenDirect = true;
}
if (transparentPixel != null) {
RGB rgb = image.palette.getRGB(transparentPixel[0]);
@@ -1122,7 +1087,15 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
OS.XtFree(bufPtr);
return SWT.ERROR_NO_HANDLES;
}
- int foreground = 1, background = 0;
+ int foreground = 0, background = 0;
+ if (srcReds.length > 1) {
+ foreground = ImageData.closestMatch(screenDepth, srcReds[1], srcGreens[1], srcBlues[1],
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
+ if (srcReds.length > 0) {
+ background = ImageData.closestMatch(screenDepth, srcReds[0], srcGreens[0], srcBlues[0],
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
XImage xImage = new XImage();
OS.memmove(xImage, xImagePtr, XImage.sizeof);
xImage.byte_order = OS.MSBFirst;
@@ -1130,11 +1103,8 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
xImage.bitmap_bit_order = OS.MSBFirst;
OS.memmove(xImagePtr, xImage, XImage.sizeof);
int destOrder = ImageData.MSB_FIRST;
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, 1, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, 1, bplX, destOrder, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
+ ImageData.stretch1(image.data, image.bytesPerLine, ImageData.MSB_FIRST, srcX, srcY, srcWidth, srcHeight,
+ buf, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, flipX, flipY);
OS.memmove(xImage.data, buf, bufSize);
XGCValues values = new XGCValues();
OS.XGetGCValues(display, gc, OS.GCForeground | OS.GCBackground, values);
@@ -1157,76 +1127,61 @@ static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHe
int bufPtr = OS.XtMalloc(bufSize);
xImage.data = bufPtr;
OS.memmove(xImagePtr, xImage, XImage.sizeof);
- int srcOrder = image.getByteOrder();
+ int srcOrder = image.depth == 16 ? ImageData.LSB_FIRST : ImageData.MSB_FIRST;
int destOrder = xImage.byte_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;
- if (palette.isDirect) {
- if (screenDirect) {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
- flipX, flipY);
- } else {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
- flipX, flipY);
- }
- } else {
- if (screenDirect) {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
- flipX, flipY);
- } else {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
- ImageData.ALPHA_OPAQUE, null, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
- flipX, flipY);
- }
+ if (image.depth > 8 && screenDepth > 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else if (image.depth <= 8 && screenDepth > 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else if (image.depth > 8 && screenDepth <= 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
+ flipX, flipY);
+ } else if (image.depth <= 8 && screenDepth <= 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
+ flipX, flipY);
}
OS.memmove(xImage.data, buf, bufSize);
OS.XPutImage(display, drawable, gc, xImagePtr, 0, 0, destX, destY, destWidth, destHeight);
OS.XDestroyImage(xImagePtr);
return 0;
}
-/**
- * Sets the color to which to map the transparent pixel.
- * <p>
- * There are certain uses of <code>Images</code> that do not support
- * transparency (for example, setting an image into a button or label).
- * In these cases, it may be desired to simulate transparency by using
- * the background color of the widget to paint the transparent pixels
- * of the image. This method specifies the color that will be used in
- * these cases. For example:
- * <pre>
- * Button b = new Button();
- * image.setBackground(b.getBackground());>
- * b.setImage(image);
- * </pre>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ * Button b = new Button();
+ * image.setBackground(b.getBackground());>
+ * b.setImage(image);
+ * </pre>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the color is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
+ * </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
- */
+ */
public void setBackground(Color color) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
index ccd0a97bcd..b314d0f539 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
@@ -41,7 +41,6 @@ Region (int handle) {
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -50,8 +49,6 @@ Region (int handle) {
public void add (Rectangle rect) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
XRectangle xRect = new XRectangle();
xRect.x = (short)rect.x;
xRect.y = (short)rect.y;
@@ -67,8 +64,7 @@ public void add (Rectangle rect) {
* @param region the region to merge
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
@@ -77,7 +73,6 @@ public void add (Rectangle rect) {
public void add (Region region) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
OS.XUnionRegion(handle, region.handle, handle);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
index f9e73e673b..cf248bd654 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
@@ -5,396 +5,82 @@ package org.eclipse.swt.internal;
* All Rights Reserved
*/
-import org.eclipse.swt.internal.motif.*;
-import java.util.*;
-
-/**
- * This class implements the conversions between unicode characters
- * and the <em>platform supported</em> representation for characters.
- * <p>
- * Note that, unicode characters which can not be found in the platform
- * encoding will be converted to an arbitrary platform specific character.
- * </p>
- */
+/**
+ * This class implements the conversions between unicode characters
+ * and the <em>platform supported</em> representation for characters.
+ * <p>
+ * Note that, unicode characters which can not be found in the platform
+ * encoding will be converted to an arbitrary platform specific character.
+ * </p>
+ */
public final class Converter {
-
- static final byte [] NULL_BYTE_ARRAY = new byte [1];
- static final byte [] EMPTY_BYTE_ARRAY = new byte [0];
- static final char [] EMPTY_CHAR_ARRAY = new char [0];
-
- static String CodePage;
- static byte[] Unicode;
-
- /* Converter cache */
- static String LastMBToWCCodePage;
- static String LastWCToMBCodePage;
- static int LastWCToMB;
- static int LastMBToWC;
-
- /* Buffers cache */
- static int BufferSize;
- static int BufferTimes2;
- static int BufferTimes4;
-
- static {
- Unicode = getAsciiBytes("UCS-2");
-
- int length, item = OS.nl_langinfo (OS.CODESET);
- if (item != 0 && (length = OS.strlen (item)) > 0) {
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item, length);
- CodePage = new String (buffer);
- if (OS.IsSunOS) {
- if (length > 3 && CodePage.indexOf ("ISO") == 0) {
- CodePage = CodePage.substring (3, length - 3);
- }
- }
- } else {
- if (OS.IsLinux) CodePage = "ISO-8859-1";
- else if (OS.IsAIX) CodePage = "ISO8859-1";
- else if (OS.IsSunOS) CodePage = "8859-1";
- else CodePage = "iso8859_1";
- }
-
- BufferSize = 512;
- BufferTimes2 = OS.XtMalloc (BufferSize * 2);
- BufferTimes4 = OS.XtMalloc (BufferSize * 4);
- }
-
-/**
- * Returns the default code page for the platform where the
- * application is currently running.
- *
- * @return the default code page
- */
+ public static final byte [] NullByteArray = new byte [1];
+ public static final char [] NullCharArray = new char [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
+/**
+ * Returns the default code page for the platform where the
+ * application is currently running.
+ *
+ * @return the default code page
+ */
public static String defaultCodePage () {
- return CodePage;
-}
-
-/**
- * Returns the code page for the specified font list.
- * (Warning this method is platform dependent.)
- *
- * @return the code page for the font list
- */
-public static String getCodePage (int xDisplay, int fontList) {
- int[] buffer = new int[1];
- if (!OS.XmFontListInitFontContext(buffer, fontList)) return null;
- int context = buffer[0];
- XFontStruct fontStruct = new XFontStruct();
- int fontListEntry;
- int[] fontStructPtr = new int[1];
- int[] fontNamePtr = new int[1];
- String codePage = null;
- /* Go through each entry in the font list */
- while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
- int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
- if (buffer[0] == OS.XmFONT_IS_FONT) {
- /* FontList contains a single font */
- OS.memmove(fontStruct,fontPtr,20 * 4);
- int propPtr = fontStruct.properties;
- for (int i = 0; i < fontStruct.n_properties; i++) {
- /* Reef through properties looking for XAFONT */
- int[] prop = new int[2];
- OS.memmove(prop, propPtr, 8);
- if (prop[0] == OS.XA_FONT) {
- /* Found it, prop[1] points to the string */
- StringBuffer stringBuffer = new StringBuffer();
- int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
- int length = OS.strlen(ptr);
- byte[] nameBuf = new byte[length];
- OS.memmove(nameBuf, ptr, length);
- /* Use the character encoding for the default locale */
- String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
- int start = xlfd.lastIndexOf ('-');
- if (start != -1 && start > 0) {
- start = xlfd.lastIndexOf ('-', start - 1);
- if (start != -1) {
- codePage = xlfd.substring (start + 1, xlfd.length ());
- if (codePage.indexOf ("iso") == 0) {
- if (OS.IsLinux) {
- codePage = "ISO-" + codePage.substring (3, codePage.length ());
- }
- }
- }
- }
- OS.XtFree(ptr);
- break;
- }
- propPtr += 8;
- }
- }
- else {
- /* FontList contains a fontSet */
-
- /* Get the font set locale */
- int localePtr = OS.XLocaleOfFontSet(fontPtr);
- int length = OS.strlen (localePtr);
- byte [] locale = new byte [length + 1];
- OS.memmove (locale, localePtr, length);
-
- /* Get code page for the font set locale */
- OS.setlocale (OS.LC_CTYPE, locale);
- int codesetPtr = OS.nl_langinfo (OS.CODESET);
- length = OS.strlen (codesetPtr);
- byte [] codeset = new byte [length];
- OS.memmove (codeset, codesetPtr, length);
- codePage = getAsciiString (codeset);
-
- /* Reset the locale */
- OS.setlocale (OS.LC_CTYPE, new byte[1]);
- }
- }
- OS.XmFontListFreeFontContext(context);
- return codePage;
+ /*
+ | ptr cp |
+ DefaultCodePage == nil ifFalse: [^DefaultCodePage].
+ cp := ''. "$NON-NLS$"
+ (ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull
+ ifFalse: [cp := String copyFromOSMemory: ptr].
+ cp isEmpty ifFalse: [
+ IsSunOS ifTrue: [
+ (cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])
+ ifTrue: [cp := cp copyFrom: 4 to: cp size]].
+ ^DefaultCodePage := cp].
+ IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].
+ IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].
+ ^DefaultCodePage := 'iso8859_1'
+ */
+ return null;
}
-
-static byte[] getAsciiBytes (String str) {
- int length = str.length ();
- byte [] buffer = new byte [length + 1];
- for (int i=0; i<length; i++) {
- buffer [i] = (byte)str.charAt (i);
+static boolean is7BitAscii (byte [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if ((buffer [i] & 0xFF) > 0x7F) return false;
}
- return buffer;
+ return true;
}
-
-static String getAsciiString (byte [] buffer) {
- int length = buffer.length;
- char [] chars = new char [length];
- for (int i=0; i<length; i++) {
- chars [i] = (char)buffer [i];
+static boolean is7BitAscii (char [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if (buffer [i] > 0x7F) return false;
}
- return new String (chars);
+ return true;
}
-
-/**
- * Converts an array of bytes representing the platform's encoding,
- * in the given code page, of some character data into an array of
- * matching unicode characters.
- *
- * @param codePage the code page to use for conversion
- * @param buffer the array of bytes to be converted
- * @return the unicode conversion
- */
public static char [] mbcsToWcs (String codePage, byte [] buffer) {
-
- /* Check for the simple cases */
- if (buffer == null) {
- return EMPTY_CHAR_ARRAY;
- }
- int length = buffer.length;
- if (length == 0) {
- return EMPTY_CHAR_ARRAY;
- }
-
- /*
- * Optimize for English ASCII encoding. If no conversion is
- * performed, it is safe to return any object that will also not
- * be converted if this routine is called again with the result.
- * This ensures that double conversion will not be performed
- * on the same bytes. Note that this relies on the fact that
- * lead bytes are never in the range 0..0x7F.
- */
- char [] wideCharStr = new char [length];
- for (int i=0; i<length; i++) {
- if ((buffer [i] & 0xFF) <= 0x7F) {
- wideCharStr [i] = (char) buffer [i]; // all bytes <= 0x7F, so no ((char) (buffer[i]&0xFF)) needed
- } else {
- synchronized (Converter.class) {
- String cp = codePage != null ? codePage : CodePage;
- if (LastMBToWC != 0 && !cp.equals (LastMBToWCCodePage)) {
- OS.iconv_close (LastMBToWC);
- LastMBToWC = 0;
- }
- if (LastMBToWC == 0) {
- LastMBToWCCodePage = cp;
- LastMBToWC = OS.iconv_open (Unicode, getAsciiBytes (cp));
- }
- int cd = LastMBToWC;
- if (cd == 0) return EMPTY_CHAR_ARRAY;
- int inBytes = length;
- int outBytes = length * 2;
- int ptr1, ptr2;
- if (length <= BufferSize * 2) {
- ptr1 = BufferTimes2;
- ptr2 = BufferTimes4;
- } else {
- ptr1 = OS.XtMalloc (inBytes);
- ptr2 = OS.XtMalloc (outBytes);
- }
- int [] inBuf = {ptr1};
- int [] inBytesLeft = {inBytes};
- int [] outBuf = {ptr2};
- int [] outBytesLeft = {outBytes};
- OS.memmove (ptr1, buffer, inBytes);
- int result = OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
- outBytes = outBuf [0] - ptr2;
- wideCharStr = new char [outBytes / 2];
-
- /* Memmove can not be used because of the endianess */
-// OS.memmove (wideCharStr, ptr2, outBytesLeft [0]);
- byte[] b = new byte [outBytes];
- OS.memmove (b, ptr2, outBytes);
- for (int j=0; j<outBytes; j+=2) {
- wideCharStr [j >> 1] = (char)(((b [j] & 0xFF) << 8) | (b [j + 1] & 0xFF));
- }
-
- if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
- if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
- }
- return wideCharStr;
- }
- }
- return wideCharStr;
+ //SLOW AND BOGUS
+ return new String (buffer).toCharArray ();
}
-
-/**
- * Free any cached resources.
- */
-public static void release () {
- synchronized (Converter.class) {
- if (BufferTimes2 != 0) OS.XtFree (BufferTimes2);
- if (BufferTimes4 != 0) OS.XtFree (BufferTimes4);
- if (LastWCToMB != 0) OS.iconv_close (LastWCToMB);
- if (LastMBToWC != 0) OS.iconv_close (LastMBToWC);
- LastMBToWC = LastWCToMB = BufferTimes4 = BufferTimes2 = 0;
- }
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, String string) {
+ return wcsToMbcs (codePage, string, false);
}
-
-/**
- * Converts an array of chars (containing unicode data) to an array
- * of bytes representing the platform's encoding, of those characters
- * in the given code page.
- *
- * @param codePage the code page to use for conversion
- * @param buffer the array of chars to be converted
- * @return the platform encoding
- */
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ //SLOW AND BOGUS
+ int count = string.length ();
+ if (terminate) count++;
+ char [] buffer = new char [count];
+ string.getChars (0, string.length (), buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+}
+/* TEMPORARY CODE */
public static byte [] wcsToMbcs (String codePage, char [] buffer) {
return wcsToMbcs (codePage, buffer, false);
}
-
-/**
- * Converts an array of chars (containing unicode data) to an array
- * of bytes representing the platform's encoding, of those characters
- * in the given code page. If the termination flag is true, the resulting
- * byte data will be null (zero) terminated.
- *
- * @param codePage the code page to use for conversion
- * @param buffer the array of chars to be converted
- * @param terminate <code>true</code> if the result should be null terminated and false otherwise.
- * @return the platform encoding
- */
public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
-
- /* Check for the simple cases */
- if (buffer == null) {
- return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
- }
- int length = buffer.length;
- if (length == 0) {
- return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
- }
-
- /*
- * Optimize for English ASCII encoding. This optimization
- * relies on the fact that lead bytes can never be in the
- * range 0..0x7F.
- */
- byte [] mbcs = new byte [(terminate) ? length + 1 : length];
- for (int i=0; i<length; i++) {
- if ((buffer [i] & 0xFFFF) <= 0x7F) {
- mbcs [i] = (byte) buffer [i];
- } else {
- synchronized (Converter.class) {
- String cp = codePage != null ? codePage : CodePage;
- if (LastWCToMB != 0 && !cp.equals (LastWCToMBCodePage)) {
- OS.iconv_close (LastWCToMB);
- LastWCToMB = 0;
- }
- if (LastWCToMB == 0) {
- LastWCToMBCodePage = cp;
- LastWCToMB = OS.iconv_open (getAsciiBytes (cp), Unicode);
- }
- int cd = LastWCToMB;
- if (cd == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
- int inBytes = length * 2;
- int outBytes = length * 4;
- int ptr1, ptr2;
- if (length <= BufferSize) {
- ptr1 = BufferTimes2;
- ptr2 = BufferTimes4;
- } else {
- ptr1 = OS.XtMalloc (inBytes);
- ptr2 = OS.XtMalloc (outBytes);
- }
- int [] inBuf = {ptr1};
- int [] inBytesLeft = {inBytes};
- int [] outBuf = {ptr2};
- int [] outBytesLeft = {outBytes};
-
- /* Memmove can not be used because of the endianess */
-// OS.memmove (ptr1, buffer, inBytes);
- byte[] b = new byte[inBytes];
- for (int j=0; j<inBytes; j+=2) {
- int c = buffer [j >> 1];
- b [j] = (byte)(c >> 8);
- b [j + 1] = (byte)(c & 0xFF);
- }
- OS.memmove (ptr1, b, inBytes);
-
- int result = OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
- outBytes = outBuf [0] - ptr2;
- mbcs = new byte [outBytes];
- OS.memmove (mbcs, ptr2, outBytes);
- if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
- if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
- }
- return mbcs;
- }
- }
- return mbcs;
+ //SLOW AND BOGUS
+ if (!terminate) return new String (buffer).getBytes ();
+ byte [] buffer1 = new String (buffer).getBytes ();
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
}
-
-/**
- * Converts a String (containing unicode data) to an array
- * of bytes representing the platform's encoding, of those characters
- * in the given code page.
- *
- * @param codePage the code page to use for conversion
- * @param string the string to be converted
- * @return the platform encoding
- */
-public static byte [] wcsToMbcs (String codePage, String string) {
- return wcsToMbcs (codePage, string, false);
-}
-
-/**
- * Converts a String (containing unicode data) to an array
- * of bytes representing the platform's encoding, of those characters
- * in the given code page. If the termination flag is true, the resulting
- * byte data will be null (zero) terminated.
- *
- * @param codePage the code page to use for conversion
- * @param string the string to be converted
- * @param terminate <code>true</code> if the result should be null terminated and false otherwise.
- * @return the platform encoding
- */
-public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
- if (terminate) {
- if (string == null) return NULL_BYTE_ARRAY;
- int count = string.length ();
- char [] buffer = new char [count + 1];
- string.getChars (0, count, buffer, 0);
- return wcsToMbcs (codePage, buffer, false);
- } else {
- if (string == null) return EMPTY_BYTE_ARRAY;
- int count = string.length ();
- char [] buffer = new char [count];
- string.getChars (0, count, buffer, 0);
- return wcsToMbcs (codePage, buffer, false);
- }
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
index eeb4c65232..949c48c736 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
@@ -9,50 +9,46 @@ public class KDE extends OS {
public static final int KICON_SMALL = 0;
-public static final native int KApplication_new(int qcString);
+public static final native int KApplication_new(int qcString);
-public static final native int KGlobal_iconLoader();
+public static final native int KGlobal_iconLoader();
-public static final native int KIconLoader_iconPath(int loader, int iconQString, int iconType, int canReturnNull);
+public static final native int KIconLoader_iconPath(int receiver, int iconQString, int iconType, int canReturnNull);
-public static final native int KMimeType_mimeType(int mimeTypeName);
-public static final native int KMimeType_icon(int mimeType, int unused1, int unused2);
-public static final native int KMimeType_name(int mimeType);
-public static final native int KMimeType_patterns(int mimeType);
-public static final native int KMimeType_offers(int mimeTypeName);
-public static final native int KMimeType_allMimeTypes();
+public static final native int KMimeType_findByURL(int kurl);
+public static final native int KMimeType_icon(int receiver, int unused1, int unused2);
+public static final native int KMimeType_name(int receiver);
-public static final native int KMimeTypeList_begin(int mimeTypeList);
-public static final native int KMimeTypeList_delete(int mimeTypeList);
-public static final native int KMimeTypeList_end(int mimeTypeList);
+public static final native int KService_allServices();
+public static final native int KService_exec(int receiver);
+public static final native int KService_icon(int receiver);
+public static final native int KService_name(int receiver);
+public static final native int KService_serviceByName(int serviceName);
+public static final native int KService_type(int receiver);
-public static final native int KMimeTypeListIterator_delete(int iterator);
-public static final native int KMimeTypeListIterator_dereference(int iterator);
-public static final native int KMimeTypeListIterator_equals(int iterator, int iterator2);
-public static final native void KMimeTypeListIterator_increment(int iterator);
+public static final native int KServiceTypeProfile_preferredService(int mimeTypeQString, int needApp);
-public static final native int QStringList_begin(int qstringList);
-public static final native int QStringList_delete(int qstringList);
-public static final native int QStringList_end(int qstringList);
+public static final native void KURL_delete(int receiver);
-public static final native int QStringListIterator_delete(int iterator);
-public static final native int QStringListIterator_dereference(int iterator);
-public static final native int QStringListIterator_equals(int iterator, int iterator2);
-public static final native void QStringListIterator_increment(int iterator);
+public static final native int KURL_new(int qString);
-public static final native int KURL_new( int qURLString );
-public static final native void KURL_delete( int url );
-public static final native int KRun_runURL( int url, int mimeTypeName );
+public static final native int KServiceList_begin(int receiver);
+public static final native int KServiceList_delete(int receiver);
+public static final native int KServiceList_end(int receiver);
-public static final native int KServiceList_delete(int serviceList);
+public static final native int QCString_data(int receiver);
+public static final native int QCString_delete(int receiver);
+public static final native int QCString_new(byte[] string);
-public static final native int QCString_data(int qcString);
-public static final native int QCString_delete(int qcString);
-public static final native int QCString_new(byte[] string);
+public static final native int QString_delete(int receiver);
+public static final native int QString_equals(int receiver, int object);
+public static final native int QString_new(byte[] string);
+public static final native int QString_utf8(int receiver);
-public static final native int QString_delete(int qString);
-public static final native int QString_equals(int qString, int qString2);
-public static final native int QString_new(byte[] string);
-public static final native int QString_utf8(int qString);
+public static final native int KServiceListIterator_delete(int receiver);
+public static final native int KServiceListIterator_dereference(int receiver);
+public static final native void KServiceListIterator_increment(int receiver);
+public static final native int KServiceListIterator_new(int listBeginning);
+public static final native int KServiceListIterator_equals(int receiver, int object);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
index 6caa14ef15..c311603786 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
@@ -14,44 +14,6 @@ public class OS {
Callback.loadLibrary ();
}
- /* OS and locale Constants*/
- public static final boolean IsAIX, IsSunOS, IsLinux;
- public static final int CODESET;
- public static final int LC_CTYPE;
- static {
-
- /* Initialize the OS flags and locale constants */
- String osName = System.getProperty ("os.name");
- if (osName.equals("Linux")) {
- IsLinux = true;
- IsAIX = IsSunOS = false;
- } else {
- if (osName.equals("AIX")) {
- IsAIX = true;
- IsLinux = IsSunOS = false;
- } else {
- if (osName.equals("Solaris")) {
- IsSunOS = true;
- IsLinux = IsAIX = false;
- } else {
- IsLinux = IsSunOS = IsAIX = false;
- }
- }
- }
-
- CODESET = OS.IsLinux ? 14 : 49;
- LC_CTYPE = OS.IsAIX ? 1 : 0;
- }
-
- /* BEGIN Visual classes */
- //public static final int StaticGray = 0;
- //public static final int GrayScale = 1;
- //public static final int StaticColor = 2;
- //public static final int PseudoColor = 3;
- //public static final int TrueColor = 4;
- //public static final int DirectColor = 5;
- /* END Visual clases */
-
/* X/Xt/Xm Constants */
public static final byte [] XmFONTLIST_DEFAULT_TAG = {0x46, 0x4F, 0x4E, 0x54, 0x4C, 0x49, 0x53, 0x54, 0x5F, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4C, 0x54, 0x5F, 0x54, 0x41, 0x47, 0x5F, 0x53, 0x54, 0x52, 0x49, 0x4E, 0x47, 0x0};
public static final int Above = 0;
@@ -87,7 +49,7 @@ public class OS {
// public static final int ClipByChildren = 0x0;
// public static final int ColormapChangeMask = 1 << 23;
// public static final int ColormapNotify = 32;
- public static final int Complex = 0;
+// public static final int Complex = 0;
public static final int ConfigureNotify = 22;
// public static final int ConfigureRequest = 23;
public static final int ControlMask = (1<<2);
@@ -198,7 +160,7 @@ public class OS {
// public static final int LeaveNotify = 8;
public static final int LeaveWindowMask = 1 << 5;
public static final int LineDoubleDash = 0x2;
- public static final int LineOnOffDash = 0x1;
+// public static final int LineOnOffDash = 0x1;
public static final int LineSolid = 0x0;
// public static final int LockMask = (1<<1);
public static final int LSBFirst = 0;
@@ -417,7 +379,7 @@ public class OS {
public static final int XK_Shift_L = 0xFFE1;
public static final int XK_Shift_R = 0xFFE2;
public static final int XK_Tab = 0xFF09;
- public static final int XK_Up = 0xFF52;
+ public static final int XK_Up = 0xFF52;
public static final int XK_VoidSymbol = 0xFFFFFF;
// public static final int XLookupBoth = 0x4;
// public static final int XLookupChars = 0x2;
@@ -613,7 +575,7 @@ public class OS {
public static final int XmNdragInitiatorProtocolStyle = malloc ("dragInitiatorProtocolStyle");
public static final int XmNdragReceiverProtocolStyle = malloc ("dragReceiverProtocolStyle");
public static final int XmNdragOperations = malloc ("dragOperations");
- public static final int XmNeditable = malloc ("editable");
+ public static final int XmNeditable = malloc ("editable");
public static final int XmNenableThinThickness = malloc ("enableThinThickness");
public static final int XmNiconic = malloc ("iconic");
public static final int XmNlabelType = malloc ("labelType");
@@ -771,11 +733,6 @@ public class OS {
public static final int XmNvisibleItemCount = malloc ("visibleItemCount");
public static final int XmNdropTransfers = malloc ("dropTransfers");
public static final int XmNshowArrows = malloc ("showArrows");
- public static final int XmNspotLocation = malloc ("spotLocation");
-// public static final int XNFocusWindow = malloc ("focusWindow");
-// public static final int XNInputStyle = malloc ("inputStyle");
-// public static final int XNClientWindow = malloc ("clientWindow");
-// public static final int XNQueryInputStyle = malloc ("queryInputStyle");
/* Unknown */
public static final int XmNdropSiteActivity = malloc("dropSiteActivity");
@@ -863,7 +820,9 @@ public class OS {
public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
public static final native int XmCreateRowColumn (int parent, byte [] name, int [] arglist, int argcount);
public static final native int XmCreateScrolledWindow (int parent, byte [] name, int [] arglist, int argcount);
+ public static final native boolean XmDestroyPixmap (int screen, int pixmap);
public static final native int XmGetFocusWidget (int widget);
+ public static final native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);
public static final native void XmListAddItemsUnselected (int list, int xmStringTable, int item_count, int position);
public static final native void XmListDeleteItem (int list, int item);
public static final native void XmListDeselectItem (int list, int xmString);
@@ -954,10 +913,8 @@ public static final native int XGrabPointer (
int cursor,
int time);
public static final native int XInitThreads ();
-public static final native int XInternAtom( int display, byte [] name, boolean ifExists );
public static final native int XKeysymToString (int keysym);
public static final native int XListFonts(int display, byte[] pattern, int maxnames, int[] actual_count_return);
-public static final native int XListProperties(int display, int window, int[] num_prop_return);
public static final native int XLookupString (XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
public static final native int XLowerWindow (int display, int window);
public static final native boolean XPointInRegion (int region, int x, int y);
@@ -1049,7 +1006,6 @@ public static final native int XmCreateTextField (int parent, byte [] name, int
public static final native int XmCreateToggleButton (int parent, byte [] name, int [] arglist, int argcount);
public static final native int XmCreateToggleButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
public static final native int XmCreateWarningDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final native boolean XmDestroyPixmap (int screen, int pixmap);
public static final native void XmDragCancel(int dragcontext);
public static final native int XmDragStart(int widget, XAnyEvent event, int[] arglist, int argcount);
public static final native void XmDropSiteRegister(int widget, int [] arglist, int argcount);
@@ -1070,8 +1026,6 @@ public static final native int XmFontListNextEntry (int context);
public static final native int XmGetAtomName (int display, int atom);
public static final native int XmGetDragContext (int widget, int timestamp);
public static final native int XmGetFocusWidget (int widget);
-public static final native int XmGetPixmap( int screen, byte [] name, int fgPixel, int bgPixel );
-public static final native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);
public static final native int XmGetXmDisplay (int display);
public static final native int XmImMbLookupString (int widget, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
public static final native int XmInternAtom (int display, byte [] name, boolean only_if_exists);
@@ -1148,7 +1102,7 @@ public static final native void XmTextSetString (int widget, byte [] value);
public static final native void XmTextShowPosition (int widget, int position);
public static final native void XmUpdateDisplay (int widget);
public static final native boolean XmWidgetGetDisplayRect (int region, XRectangle rectangle);
-//public static final native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
public static final native void XtAddCallback (int widget, int callback_name, int callback, int client_data);
public static final native void XtAddEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
public static final native void XtAddExposureToRegion (int event, int region);
@@ -1258,6 +1212,7 @@ public static final native void memmove (XmTextVerifyCallbackStruct dest, int sr
public static final native void memmove (byte [] dest, int src, int count);
public static final native void memmove (int [] dest, int src, int count);
public static final native int strlen (int string);
+public static final native int XpmReadFileToPixmap(int display, int drawable, byte[] fileName, int[] pixmap_return, int[] shapemask_return, int attributes);
public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
public static final native int XCheckIfEvent (int display, XAnyEvent event_return, int predicate, int arg);
public static final native boolean XtToolkitThreadInitialize ();
@@ -1302,47 +1257,19 @@ public static final native void XDestroyWindow(int display, int w);
/*
* ======== End of printing constants and functions ========
*/
-
-public static final native int pipe (int [] filedes);
-public static final native int read (int filedes, byte [] buf, int nbyte);
-public static final native int write (int filedes, byte [] buf, int nbyte);
-public static final native int close (int filedes);
-public static final native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);
-public static final native void XtRemoveInput (int id);
-// public static final int XtInputNoneMask = 0;
- public static final int XtInputReadMask = 1;
-// public static final int XtInputWriteMask = 2;
+
+public static final native int pipe (int [] filedes);
+public static final native int read (int filedes, byte [] buf, int nbyte);
+public static final native int write (int filedes, byte [] buf, int nbyte);
+public static final native int close (int filedes);
+public static final native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);
+public static final native void XtRemoveInput (int id);
+// public static final int XtInputNoneMask = 0;
+ public static final int XtInputReadMask = 1;
+// public static final int XtInputWriteMask = 2;
// public static final int XtInputExceptMask = 4;
public static final native int XLoadQueryFont (int display, byte[] name);
public static final native int XmFontListEntryCreate (byte[] tag, int type, int font);
-
-public static final native int XmImGetXIC (int widget, int input_policy, int[] args, int num_args);
-public static final native int XmImGetXIM (int widget);
-public static final native void XmImRegister (int widget, int reserved);
-//public static final native int XmImSetFocusValues (int widget, int[] args, int num_args);
-public static final native int XmImVaSetFocusValues(int widget, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
-public static final native int XmImSetValues (int widget, int[] args, int num_args);
-public static final native void XmImUnregister (int widget);
-public static final native void XmImUnsetFocus (int widget);
-//public static final native void XSetICFocus (int ic);
-//public static final native void XUnsetICFocus (int ic);
-//public static final native int XCreateIC (int im, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
-//public static final native int XSetICValues (int ic, int arg1, int arg2, int arg3);
-//public static final native int XGetICValues (int ic, int arg1, int arg2, int arg3);
-//public static final native int XGetIMValues (int im, int arg1, int arg2, int arg3);
-public static final native void memmove (int dest, short [] src, int count);
-//public static final native void memmove (char[] dest, int src, int count);
-//public static final native void memmove ( int dest, char[] src,int count);
-
-public static final native int nl_langinfo (int item);
-public static final native int iconv_open (byte[] tocode, byte[] fromcode);
-public static final native int iconv_close (int cd);
-public static final native int iconv (int cd, int[] inBuf, int[] inBytesLeft, int[] outBuf, int[] outBytesLeft);
-public static final native int MB_CUR_MAX ();
-public static final native int setlocale (int category, byte[] locale);
-
-public static final native int XCreateFontSet (int display, byte [] base_font_name_list, int [] missing_charset_list_return, int [] missing_charset_count_return, int [] def_string_return);
-public static final native int XLocaleOfFontSet (int fontSet);
-
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
new file mode 100755
index 0000000000..41f7d95a58
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,313 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/**
+ * This class stores and manages child items of a tree item.
+ * It provides protocol to query the index of an item relative
+ * to the root and to retrieve items by index.
+ * The TreeItem class implements this protocol for general
+ * tree items.
+ * TreeRoots provides a special implementation that allows the
+ * Tree class to treat trees with one root and with multiple
+ * roots equally.
+ */
+abstract class AbstractTreeItem extends SelectableItem {
+ private Vector children;
+ private boolean isExpanded = false;
+ // number of children.
+ // includes all expanded items down to the leafs.
+ private int visibleItemCount = 0;
+
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver belongs to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+AbstractTreeItem(Tree parent, int swtStyle) {
+ super(parent, swtStyle);
+}
+/**
+ * Insert 'item' in the list of child items. Notify the
+ * parent about the new item.
+ * @param 'item' - the item that should be added to the
+ * receiver's children.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void add(TreeItem item, int index) {
+ Vector items = getChildren();
+ int visibleIndex = getVisibleIndex();
+
+ if (index < 0 || index > items.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (item.isRoot()) {
+ visibleIndex = index;
+ }
+ else
+ if (isExpanded == false) {
+ visibleIndex = -1;
+ }
+ if (visibleIndex != -1) {
+ if (index > 0) {
+ TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);
+ visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;
+ }
+ else {
+ visibleIndex = getVisibleIndex() + 1;
+ }
+ }
+ getSelectableParent().addingItem(item, visibleIndex);
+ item.setIndex(index);
+ resetChildIndices(index, true);
+ items.insertElementAt(item, index);
+ if (isExpanded == true) {
+ visibleItemCount++;
+ calculateVisibleItemCountParent();
+ }
+ getSelectableParent().addedItem(item, visibleIndex);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expanded -
+ * true=the receiver is expanded, making its child items visible.
+ * false=the receiver is collapsed, making its child items invisible
+ */
+void internalSetExpanded(boolean expanded) {
+ isExpanded = expanded;
+ calculateVisibleItemCount();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+abstract void calculateVisibleItemCount();
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+abstract void calculateVisibleItemCountParent();
+/**
+ * Deselect the receiver and all children
+ */
+void deselectAll() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ setSelected(false);
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.deselectAll();
+ }
+}
+public void dispose() {
+ if (!isValidWidget ()) return;
+ Vector children = getChildren();
+ AbstractTreeItem child;
+ while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
+ child = (AbstractTreeItem) children.firstElement();
+ child.dispose();
+ }
+ super.dispose();
+}
+void doDispose() {
+ setChildren(null);
+ visibleItemCount = 0;
+ super.doDispose();
+}
+/**
+ * Answer the Vector containing the child items of the receiver.
+ */
+Vector getChildren() {
+ if (children == null) {
+ children = new Vector(4);
+ }
+ return children;
+}
+/**
+ * Answer whether the receiver is expanded or not.
+ * If the receiver is expanded its children are visible.
+ * @return
+ * true - the receiver is expanded, making its children visible
+ * false - the receiver is collapsed, making its children invisible
+ */
+public boolean getExpanded() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return isExpanded;
+}
+/**
+ * Answer the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getChildren().size();
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the global index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+abstract int getVisibleIndex();
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+abstract int getVisibleIndex(int childIndex);
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ */
+abstract TreeItem getVisibleItem(int searchIndex);
+/**
+ * Answer the number of expanded children, direct and indirect.
+ */
+int getVisibleItemCount() {
+ return visibleItemCount;
+}
+/**
+ * Returns the expanded state. Circumvent widget/thread check
+ * for performance. For non-API callers only.
+ */
+boolean internalGetExpanded() {
+ return isExpanded;
+}
+/**
+ * Answer whether the receiver is a leaf item.
+ * An item is a leaf when it has no child items.
+ * @return
+ * true - receiver is a leaf item
+ * false - receiver is not a leaf item.
+ */
+boolean isLeaf() {
+ return (getChildren().size() == 0);
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it doesn't have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return false;
+}
+/**
+ * Remove 'child' from the receiver.
+ * Notify the parent widget only if it is not being disposed itself.
+ */
+void removeItem(SelectableItem child) {
+ Vector children = getChildren();
+ SelectableItemWidget parent = getSelectableParent();
+ int childIndex = children.indexOf(child);
+
+ if (childIndex != -1) {
+ if (((Tree) parent).isRemovingAll() == true) {
+ children.removeElementAt(childIndex); // just remove the item from the list if the whole tree is being disposed
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ }
+ else {
+ parent.removingItem(child);
+ children.removeElementAt(childIndex);
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ resetChildIndices(childIndex, false); // mark child index dirty
+ parent.removedItem(child);
+ }
+ }
+}
+/**
+ * Allow subclasses to reset any cached data.
+ * Called for all children of the receiver.
+ */
+void reset() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.reset();
+ }
+}
+/**
+ * Mark all child indices dirty starting with the child at
+ * 'startIndex'. This causes getIndex to recalculate the index.
+ * @param startIndex - index in the list of children at which
+ * and after which the indices are reset.
+ */
+void resetChildIndices(int startIndex, boolean addItem) {
+ Vector children = getChildren();
+ TreeItem child;
+ int increment = addItem ? 1 : 0;
+
+ for (int i = startIndex; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ child.setIndex(i + increment); // mark child index dirty
+ }
+}
+/**
+ * Select the receiver and all children.
+ * Return a Vector containing all the items that have been selected
+ * (and that have not been selected before).
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ if (isSelected() == false) {
+ selectedItems.addElement(this);
+ setSelected(true);
+ getSelectableParent().redrawSelection(this);
+ }
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+/**
+ * Set the Array containing the receiver's child items to 'children'.
+ */
+void setChildren(Vector children) {
+ this.children = children;
+}
+
+void setVisibleItemCount(int count) {
+ visibleItemCount = count;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
index bfcb36a7d7..ebacd6aa45 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
@@ -11,20 +11,20 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
-/**
- * Instances of this class represent a selectable user interface object that
- * issues notification when pressed and released.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
- * <dd>LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * Instances of this class represent a selectable user interface object that
+ * issues notification when pressed and released.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
public /*final*/ class Button extends Control {
@@ -41,33 +41,33 @@ public /*final*/ class Button extends Control {
}
ARM_AND_ACTIVATE = buffer;
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> 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.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> 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.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Button (Composite parent, int style) {
super (parent, checkStyle (style));
@@ -97,7 +97,8 @@ public Button (Composite parent, int style) {
* @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection,typedListener);
@@ -123,7 +124,8 @@ void click () {
* Computes the preferred size.
*/
public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int border = getBorderWidth ();
int width = border * 2, height = border * 2;
if ((style & SWT.ARROW) != 0) {
@@ -281,24 +283,25 @@ int defaultFont () {
int defaultForeground () {
return getDisplay ().buttonForeground;
}
-/**
- * Returns a value which describes the position of the
- * text or image in the receiver. The value will be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the alignment will indicate the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>.
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in
+ * which case, the alignment will indicate the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
+ * <code>UP</code> or <code>DOWN</code>.
+ *
+ * @return the alignment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public int getAlignment () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.ARROW) != 0) {
int [] argList = {OS.XmNarrowDirection, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
@@ -323,64 +326,67 @@ boolean getDefault () {
OS.XtGetValues (handle, argList, argList.length / 2);
return argList [1] != 0;
}
-/**
- * Returns the receiver's image if it has one, or null
- * if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Image getImage () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return image;
}
String getNameText () {
return getText ();
}
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public boolean getSelection () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
int [] argList = {OS.XmNset, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
return argList [1] != 0;
}
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public String getText () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.ARROW) != 0) return "";
int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
- int xmString = argList [1];
- int mnemonic = argList [3];
+ int xmString = argList [1];
+ int mnemonic = argList [3];
if (mnemonic == OS.XK_VoidSymbol) mnemonic = 0;
if (xmString == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
char [] result = null;
@@ -397,7 +403,7 @@ public String getText () {
byte [] buffer = new byte [length];
OS.memmove (buffer, address, length);
OS.XtFree (address);
- result = Converter.mbcsToWcs (getCodePage (), buffer);
+ result = Converter.mbcsToWcs (null, buffer);
}
if (xmString != 0) OS.XmStringFree (xmString);
int count = 0;
@@ -471,25 +477,26 @@ void releaseWidget () {
if (disabled != null) disabled.dispose ();
image = bitmap = disabled = null;
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is selected.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
*/
public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.Selection, listener);
@@ -511,24 +518,25 @@ void selectRadio () {
}
setSelection (true);
}
-/**
- * Controls how text, images and arrows will be displayed
- * in the receiver. The argument should be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the argument indicates the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>.
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Controls how text, images and arrows will be displayed
+ * in the receiver. The argument should be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in
+ * which case, the argument indicates the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
+ * <code>UP</code> or <code>DOWN</code>.
+ *
+ * @param alignment the new alignment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setAlignment (int alignment) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.ARROW) != 0) {
int [] argList = {OS.XmNarrowDirection, OS.XmARROW_UP};
if ((alignment & SWT.UP) != 0) argList [1] = OS.XmARROW_UP;
@@ -557,7 +565,6 @@ void setBitmap (Image image) {
if (disabled != null) disabled.dispose ();
bitmap = disabled = null;
if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
Display display = getDisplay ();
switch (image.type) {
case SWT.BITMAP:
@@ -594,63 +601,63 @@ void setDefault (boolean value) {
int [] argList = {OS.XmNshowAsDefault, (value ? 1 : 0)};
OS.XtSetValues (handle, argList, argList.length / 2);
}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setImage (Image image) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
setBitmap (this.image = image);
}
-/**
- * Sets the selection state of the receiver.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setSelection (boolean selected) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
int [] argList = {OS.XmNset, selected ? 1 : 0};
OS.XtSetValues (handle, argList, argList.length / 2);
}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label. The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setText (String string) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.ARROW) != 0) return;
char [] text = new char [string.length ()];
@@ -665,7 +672,7 @@ public void setText (String string) {
}
}
while (j < text.length) text [j++] = 0;
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), text, true);
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
int xmString = OS.XmStringParseText (
buffer,
0,
@@ -674,7 +681,7 @@ public void setText (String string) {
null,
0,
0);
- if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+ if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
int [] argList = {
OS.XmNlabelType, OS.XmSTRING,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
index 79336fa941..f8e2d316b2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
@@ -9,58 +9,58 @@ import org.eclipse.swt.internal.motif.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class provide a surface for drawing
- * arbitrary graphics.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are <em>not</em> constructed
- * from aggregates of other controls. That is, they are either
- * painted using SWT graphics calls or are handled by native
- * methods.
- * </p>
- *
- * @see Composite
- */
+/**
+ * Instances of this class provide a surface for drawing
+ * arbitrary graphics.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are <em>not</em> constructed
+ * from aggregates of other controls. That is, they are either
+ * painted using SWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
+ */
public class Canvas extends Composite {
Caret caret;
Canvas () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> 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.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> 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.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Canvas (Composite parent, int style) {
super (parent, style);
@@ -69,35 +69,30 @@ void createWidget (int index) {
super.createWidget (index);
fontList = defaultFont ();
}
-/**
- * Returns the caret.
- * <p>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- *
- * @return the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled. To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ *
+ * @return the caret
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Caret getCaret () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return caret;
}
-short [] getIMECaretPos () {
- if (caret == null) return super.getIMECaretPos ();
- int width = caret.width;
- if (width <= 0) width = 2;
- return new short[]{(short) (caret.x + width), (short) (caret.y + caret.height)};
-}
int processFocusIn () {
int result = super.processFocusIn ();
if (caret != null) caret.setFocus ();
@@ -133,30 +128,31 @@ void releaseWidget () {
super.releaseWidget();
}
-/**
- * Scrolls a rectangular area of the receiver by first copying
- * the source area to the destination and then causing the area
- * of the source which is not covered by the destination to
- * be repainted. Children that intersect the rectangle are
- * optionally moved during the operation. In addition, outstanding
- * paint events are flushed before the source area is copied to
- * ensure that the contents of the canvas are drawn correctly.
- *
- * @param destX the x coordinate of the destination
- * @param destY the y coordinate of the destination
- * @param x the x coordinate of the source
- * @param y the y coordinate of the source
- * @param width the width of the area
- * @param height the height of the area
- * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+/**
+ * Scrolls a rectangular area of the receiver by first copying
+ * the source area to the destination and then causing the area
+ * of the source which is not covered by the destination to
+ * be repainted. Children that intersect the rectangle are
+ * optionally moved during the operation. In addition, outstanding
+ * paint events are flushed before the source area is copied to
+ * ensure that the contents of the canvas are drawn correctly.
+ *
+ * @param destX the x coordinate of the destination
+ * @param destY the y coordinate of the destination
+ * @param x the x coordinate of the source
+ * @param y the y coordinate of the source
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (width <= 0 || height <= 0) return;
int deltaX = destX - x, deltaY = destY - y;
if (deltaX == 0 && deltaY == 0) return;
@@ -201,68 +197,56 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
if (isFocus) caret.setFocus ();
}
public void setBounds (int x, int y, int width, int height) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
boolean isFocus = caret != null && caret.isFocusCaret ();
if (isFocus) caret.killFocus ();
super.setBounds (x, y, width, height);
if (isFocus) caret.setFocus ();
}
-/**
- * Sets the receiver's caret.
- * <p>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- * @param caret the new caret for the receiver, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled. To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setCaret (Caret caret) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
Caret newCaret = caret;
Caret oldCaret = this.caret;
this.caret = newCaret;
if (hasFocus ()) {
if (oldCaret != null) oldCaret.killFocus ();
- if (newCaret != null) {
- if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- newCaret.setFocus ();
- }
+ if (newCaret != null) newCaret.setFocus ();
}
}
public void setLocation (int x, int y) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
boolean isFocus = caret != null && caret.isFocusCaret ();
if (isFocus) caret.killFocus ();
super.setLocation (x, y);
if (isFocus) caret.setFocus ();
}
public void setSize (int width, int height) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
boolean isFocus = caret != null && caret.isFocusCaret ();
if (isFocus) caret.killFocus ();
super.setSize (width, height);
if (isFocus) caret.setFocus ();
}
-void updateCaret () {
- if (caret == null) return;
- if (!IsDBLocale) return;
- short [] point = getIMECaretPos ();
- int ptr = OS.XtMalloc (4);
- OS.memmove (ptr, point, 4);
- int[] argList = {OS.XmNspotLocation, ptr};
- OS.XmImSetValues (handle, argList, argList.length / 2);
- if (ptr != 0) OS.XtFree (ptr);
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
index 3ea6d6e5f8..5274b4443f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
@@ -9,19 +9,19 @@ import org.eclipse.swt.internal.motif.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class provide an i-beam that is typically used
- * as the insertion point for text.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * Instances of this class provide an i-beam that is typically used
+ * as the insertion point for text.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
public /*final*/ class Caret extends Widget {
@@ -30,33 +30,33 @@ public /*final*/ class Caret extends Widget {
boolean moved, resized;
boolean isVisible, isShowing;
int blinkRate = 500;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> 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.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> 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.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Caret (Canvas parent, int style) {
super (parent, style);
@@ -97,19 +97,20 @@ boolean drawCaret () {
OS.XFreeGC (xDisplay, gc);
return true;
}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Rectangle getBounds () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return new Rectangle (x, y, width, height);
}
/**
@@ -120,82 +121,87 @@ public Display getDisplay () {
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
-/**
- * Returns the font that the receiver will use to paint textual information.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Font getFont () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getFont ();
}
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Point getLocation () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return new Point (x, y);
}
-/**
- * Returns the receiver's parent, which must be a <code>Canvas</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the receiver's parent, which must be a <code>Canvas</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Canvas getParent () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return parent;
}
-/**
- * Returns a point describing the receiver's size.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns a point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Point getSize () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return new Point (width, height);
}
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public boolean getVisible () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return isVisible;
}
boolean hideCaret () {
@@ -205,25 +211,26 @@ boolean hideCaret () {
isShowing = false;
return drawCaret ();
}
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public boolean isVisible () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return isVisible && parent.isVisible () && parent.hasFocus ();
}
boolean isFocusCaret () {
@@ -249,24 +256,25 @@ void releaseWidget () {
}
parent = null;
}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the arguments. The <code>x</code> and
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setBounds (int x, int y, int width, int height) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
boolean samePosition, sameExtent, showing;
samePosition = (this.x == x) && (this.y == y);
sameExtent = (this.width == width) && (this.height == height);
@@ -278,33 +286,36 @@ public void setBounds (int x, int y, int width, int height) {
moved = true;
if (isVisible ()) {
moved = false;
- parent.updateCaret ();
+ //IsDBLocale ifTrue: [
+ //widget == nil ifFalse: [widget updateCaret]].
}
} else {
resized = true;
if (isVisible ()) {
moved = false;
- parent.updateCaret ();
+ //IsDBLocale ifTrue: [
+ //widget == nil ifFalse: [widget updateCaret]].
resized = false;
}
}
if (isShowing) showCaret ();
}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setBounds (Rectangle rect) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, rect.width, rect.height);
}
@@ -314,107 +325,113 @@ void setFocus () {
display.setCurrentCaret (this);
if (isVisible) showCaret ();
}
-/**
- * Sets the font that the receiver will use to paint textual information
- * to the font specified by the argument, or to the default font for that
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setFont (Font font) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setLocation (int x, int y) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
setBounds (x, y, width, height);
}
-/**
- * Sets the receiver's location to the point specified by
- * the argument which is relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setLocation (Point location) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setSize (int width, int height) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
setBounds (x, y, width, height);
}
-/**
- * Sets the receiver's size to the point specified by the argument.
- *
- * @param size the new extent for the receiver
- * @param height the new height for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setSize (Point size) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
-/**
- * Marks the receiver as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setVisible (boolean visible) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (visible == isVisible) return;
if (isVisible = visible) {
showCaret ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
index 0226056543..c598a52931 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
@@ -9,19 +9,19 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
-/**
- * Instances of this class allow the user to select a color
- * from a predefined set of available colors.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * Instances of this class allow the user to select a color
+ * from a predefined set of available colors.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
public /*final*/ class ColorDialog extends Dialog {
private static final int DEPTH_4 = 0; // index for COLOR_SWATCH_EXTENTS
@@ -41,60 +41,60 @@ public /*final*/ class ColorDialog extends Dialog {
private boolean okSelected; // true if the dialog was hidden
// because the ok button was selected
- private RGB rgb;
+ private RGB dialogResult;
private int colorDepth; // color depth of the display
private int colorSwatchExtent; // the size of on square used
// to display one color
private Color colorGrid[][]; // the colors displayed in the dialog
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
public ColorDialog(Shell parent) {
this(parent, SWT.NULL);
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> 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.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> 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.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
public ColorDialog(Shell parent, int style) {
super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
}
@@ -197,6 +197,10 @@ void disposeColors() {
}
}
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
void drawColor(int xIndex, int yIndex, Color color, GC gc) {
int colorSwatchExtent = getColorSwatchExtent();
int colorExtent = colorSwatchExtent - COLOR_SWATCH_BORDER;
@@ -206,37 +210,69 @@ void drawColor(int xIndex, int yIndex, Color color, GC gc) {
xIndex * colorSwatchExtent, yIndex * colorSwatchExtent,
colorExtent, colorExtent);
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Canvas getColorCanvas() {
return colorsCanvas;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
int getColorDepth() {
return colorDepth;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Color [][] getColorGrid() {
return colorGrid;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
int getColorSwatchExtent() {
return colorSwatchExtent;
}
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color
+ *
+ * @see PaletteData#getRGBs
+ */
public RGB getRGB() {
- return rgb;
+ return dialogResult;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Canvas getSampleCanvas() {
return sampleCanvas;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Label getSampleText() {
return sampleLabel;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Canvas getSelectionCanvas() {
return selectionCanvas;
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
Label getSelectionText() {
return selectionLabel;
}
@@ -267,6 +303,10 @@ void handleEvents(Event event) {
}
}
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
void initialize4BitColors() {
Display display = getDialogShell().getDisplay();
@@ -290,6 +330,10 @@ void initialize4BitColors() {
colorGrid[7][0] = new Color(display, 128, 0, 128);
colorGrid[7][1] = new Color(display, 255, 0, 255);
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
void initialize8BitColors() {
Display display = getDialogShell().getDisplay();
int numColumns = colorGrid.length;
@@ -322,6 +366,8 @@ void initialize8BitColors() {
void initializeWidgets() {
Display display = getDialogShell().getDisplay();
Color selectionColor;
+ RGB rgb = getRGB();
+
if (rgb != null) {
selectionColor = new Color(display, rgb);
getSelectionCanvas().setBackground(selectionColor);
@@ -342,6 +388,10 @@ void installListeners() {
colorCanvas.addListener(SWT.MouseDown, listener);
colorCanvas.addListener(SWT.MouseMove, listener);
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/19/99 7:13:21 PM)
+ */
void mouseDown(Event event) {
int swatchExtent = getColorSwatchExtent();
Color colorGrid[][] = getColorGrid();
@@ -350,6 +400,10 @@ void mouseDown(Event event) {
getSelectionCanvas().setBackground(color);
getSelectionText().setBackground(color);
}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/19/99 7:13:21 PM)
+ */
void mouseMove(Event event) {
int swatchExtent = getColorSwatchExtent();
Color colorGrid[][] = getColorGrid();
@@ -358,41 +412,40 @@ void mouseMove(Event event) {
getSampleCanvas().setBackground(color);
getSampleText().setBackground(color);
}
-/**
- * Makes the receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
public RGB open() {
Color selectionColor;
+ RGB dialogResult = null;
Shell dialog = new Shell(getParent(), getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
setDialogShell(dialog);
createChildren();
installListeners();
openModal();
- rgb = null;
if (isOkSelected() == true) {
selectionColor = getSelectionCanvas().getBackground();
- rgb = new RGB(
+ dialogResult = new RGB(
selectionColor.getRed(),
selectionColor.getGreen(),
selectionColor.getBlue());
+ setRGB(dialogResult);
}
disposeColors();
// Fix for 1G5NLY7
if (dialog.isDisposed() == false) {
dialog.dispose();
}
- return rgb;
+ return dialogResult;
}
void paint(Event event) {
Color colorGrid[][] = getColorGrid();
@@ -416,17 +469,15 @@ void setColorDepth(int bits) {
initialize8BitColors();
}
}
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color
+ *
+ * @see PaletteData#getRGBs
*/
public void setRGB(RGB rgb) {
- this.rgb = rgb;
+ dialogResult = rgb;
}
/**
* Create the widgets of the dialog.
@@ -470,6 +521,12 @@ Button getOKButton() {
return ok;
}
+
+/**
+ * Insert the method's description here.
+ * Creation date: (08/05/99 12:34:43)
+ * @return boolean
+ */
boolean isOkSelected() {
return okSelected;
}
@@ -506,6 +563,7 @@ void openModal() {
Display display = dialog.getDisplay();
initializeWidgets();
+ setRGB(null);
openDialog();
while (dialog.isDisposed() == false && dialog.getVisible() == true) {
if (display.readAndDispatch() == false) {
@@ -514,6 +572,12 @@ void openModal() {
}
}
+
+/**
+ * Insert the method's description here.
+ * Creation date: (08/05/99 12:34:43)
+ * @param newOkSelected boolean
+ */
void setOkSelected(boolean newOkSelected) {
okSelected = newOkSelected;
}
@@ -524,4 +588,6 @@ void setDialogShell(Shell shell) {
this.shell = shell;
}
+
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
index 1c3e81eaff..e1b66be8a7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
@@ -11,44 +11,44 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
-/**
- * Instances of this class are controls that allow the user
- * to choose an item from a list of items, or optionally
- * enter a new value by typing it into an editable text
- * field. Often, <code>Combo</code>s are used in the same place
- * where a single selection <code>List</code> widget could
- * be used but space is limited. A <code>Combo</code> takes
- * less space than a <code>List</code> widget and shows
- * similar information.
- * <p>
- * Note: Since <code>Combo</code>s can contain both a list
- * and an editable text field, it is possible to confuse methods
- * which access one versus the other (compare for example,
- * <code>clearSelection()</code> and <code>deselectAll()</code>).
- * The API documentation is careful to indicate either "the
- * receiver's list" or the "the receiver's text field" to
- * distinguish between the two cases.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see List
- */
+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ */
public /*final*/ class Combo extends Composite {
- /**
- * the operating system limit for the number of characters
- * that the text field in an instance of this class can hold
- */
+ /**
+ * the operating system limit for the number of characters
+ * that the text field in an instance of this class can hold
+ */
public static int LIMIT;
/*
@@ -60,93 +60,95 @@ public /*final*/ class Combo extends Composite {
LIMIT = 0x7FFFFFFF;
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> 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.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> 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.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Combo (Composite parent, int style) {
super (parent, checkStyle (style));
}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
- * </ul>
- *
- * @see #add(String,int)
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String,int)
*/
public void add (String string) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
int xmString = OS.XmStringCreateLocalized (buffer);
if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
OS.XmComboBoxAddItem(handle, xmString, -1, false);
OS.XmStringFree (xmString);
}
-/**
- * Adds the argument to the receiver's list at the given
- * zero-relative index.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
- * </ul>
- *
- * @see #add(String)
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String)
*/
public void add (String string, int index) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == -1) error (SWT.ERROR_INVALID_RANGE);
@@ -161,33 +163,34 @@ public void add (String string, int index) {
if (!(0 <= index && index <= argList [1])) {
error (SWT.ERROR_INVALID_RANGE);
}
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
int xmString = OS.XmStringCreateLocalized (buffer);
if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
OS.XmComboBoxAddItem(handle, xmString, index + 1, false);
OS.XmStringFree (xmString);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
*/
public void addModifyListener (ModifyListener listener) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Modify, typedListener);
@@ -217,7 +220,8 @@ public void addModifyListener (ModifyListener listener) {
* @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
@@ -253,25 +257,26 @@ static int checkStyle (int style) {
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-/**
- * Sets the selection in the receiver's text field to an empty
- * selection starting just before the first character. If the
- * text field is editable, this has the effect of placing the
- * i-beam at the start of the text.
- * <p>
- * Note: To clear the selected items in the receiver's list,
- * use <code>deselectAll()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #deselectAll
+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list,
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
*/
public void clearSelection () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int xDisplay = OS.XtDisplay (handle);
if (xDisplay == 0) return;
int [] argList = {OS.XmNtextField, 0};
@@ -280,7 +285,8 @@ public void clearSelection () {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] argList = {
OS.XmNlist, 0,
OS.XmNtextField, 0,
@@ -346,20 +352,21 @@ void createHandle (int index) {
handle = OS.XmCreateComboBox (formHandle, null, argList2, argList2.length / 2);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
}
-/**
- * Deselects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already deselected, it remains
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Deselects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void deselect (int index) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (index == -1) return;
int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
@@ -374,22 +381,23 @@ public void deselect (int index) {
OS.XmListDeselectAllItems (argList[3]);
}
}
-/**
- * Deselects all selected items in the receiver's list.
- * <p>
- * Note: To clear the selection in the receiver's text field,
- * use <code>clearSelection()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #clearSelection
+/**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
*/
public void deselectAll () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
Display display = getDisplay ();
@@ -402,27 +410,28 @@ public void deselectAll () {
}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver's list. Throws an exception if the index is out
- * of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public String getItem (int index) {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] argList = {OS.XmNitemCount, 0, OS.XmNitems, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
if (!(0 <= index && index < argList [1])) {
@@ -446,43 +455,45 @@ public String getItem (int index) {
byte [] buffer = new byte [length];
OS.memmove (buffer, address, length);
OS.XtFree (address);
- return decodeString(new String (Converter.mbcsToWcs (getCodePage (), buffer)));
+ return decodeString(new String (Converter.mbcsToWcs (null, buffer)));
}
-/**
- * Returns the number of items contained in the receiver's list.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public int getItemCount () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] argList = {OS.XmNitemCount, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
return argList [1];
}
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the receiver's list.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public int getItemHeight () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] listHandleArgs = {OS.XmNlist, 0};
OS.XtGetValues (handle, listHandleArgs, listHandleArgs.length / 2);
int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0};
@@ -491,33 +502,33 @@ public int getItemHeight () {
/* Result is from empirical analysis on Linux and AIX */
return getFontHeight () + spacing + (2 * highlight);
}
-/**
- * Returns an array of <code>String</code>s which are the items
- * in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public String [] getItems () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
int items = argList [1], itemCount = argList [3];
int [] buffer1 = new int [1];
String [] result = new String [itemCount];
- String codePage = getCodePage ();
for (int i = 0; i < itemCount; i++) {
OS.memmove (buffer1, items, 4);
int ptr = buffer1 [0];
@@ -534,27 +545,28 @@ public String [] getItems () {
byte [] buffer = new byte [length];
OS.memmove (buffer, address, length);
OS.XtFree (address);
- result[i] = decodeString(new String (Converter.mbcsToWcs (codePage, buffer)));
+ result[i] = decodeString(new String (Converter.mbcsToWcs (null, buffer)));
items += 4;
}
return result;
}
-/**
- * Returns a <code>Point</code> whose x coordinate is the start
- * of the selection in the receiver's text field, and whose y
- * coordinate is the end of the selection. The returned values
- * are zero-relative. An "empty" selection as indicated by
- * the the x and y coordinates having the same value.
- *
- * @return a point representing the selection start and end
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns a <code>Point</code> whose x coordinate is the start
+ * of the selection in the receiver's text field, and whose y
+ * coordinate is the end of the selection. The returned values
+ * are zero-relative. An "empty" selection as indicated by
+ * the the x and y coordinates having the same value.
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Point getSelection () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int [] start = new int [1], end = new int [1];
int [] argList = {OS.XmNtextField, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
@@ -564,19 +576,21 @@ public Point getSelection () {
}
return new Point (start [0], end [0]);
}
-/**
- * Returns the zero-relative index of the item which is currently
- * selected in the receiver's list, or -1 if no item is selected.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public int getSelectionIndex () {
- checkWidget();
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
int [] argList = {OS.XmNlist, 0};
OS.XtGetValues (handle, argList, argList.length / 2);
@@ -591,19 +605,21 @@ public int getSelectionIndex () {
OS.XtFree (address);
return indices [0] - 1;
}
-/**
- * Returns a string containing a copy of the contents of the
- * receiver's text field.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>