org.eclipse.swt.win32.win32.x86_3.7.2.v3740f

nt getInt()
  {
    if (type == 0) {
      OLE.error(1010, -1);
    }
    if (type == 3) {
      return intData;
    }
    int oldPtr = OS.GlobalAlloc(64, sizeof);
    int newPtr = OS.GlobalAlloc(64, sizeof);
    try
    {
      getData(oldPtr);
      int result = COM.VariantChangeType(newPtr, oldPtr, (short)0, (short)3);
      if (result != 0) {
        OLE.error(1010, result);
      }
      Variant intVar = new Variant();
      intVar.setData(newPtr);
      return intVar.getInt();
    }
    finally
    {
      COM.VariantClear(oldPtr);
      OS.GlobalFree(oldPtr);
      COM.VariantClear(newPtr);
      OS.GlobalFree(newPtr);
    }
  }
  
  public long getLong()
  {
    if (type == 0) {
      OLE.error(1010, -1);
    }
    if (type == 20) {
      return longData;
    }
    int oldPtr = OS.GlobalAlloc(64, sizeof);
    int newPtr = OS.GlobalAlloc(64, sizeof);
    try
    {
      getData(oldPtr);
      int result = COM.VariantChangeType(newPtr, oldPtr, (short)0, (short)20);
      if (result != 0) {
        OLE.error(1010, result);
      }
      Variant longVar = new Variant();
      longVar.setData(newPtr);
      return longVar.getLong();
    }
    finally
    {
      COM.VariantClear(oldPtr);
      OS.GlobalFree(oldPtr);
      COM.VariantClear(newPtr);
      OS.GlobalFree(newPtr);
    }
  }
  
  public short getShort()
  {
    if (type == 0) {
      OLE.error(1010, -1);
    }
    if (type == 2) {
      return shortData;
    }
    int oldPtr = OS.GlobalAlloc(64, sizeof);
    int newPtr = OS.GlobalAlloc(64, sizeof);
    try
    {
      getData(oldPtr);
      int result = COM.VariantChangeType(newPtr, oldPtr, (short)0, (short)2);
      if (result != 0) {
        OLE.error(1010, result);
      }
      Variant shortVar = new Variant();
      shortVar.setData(newPtr);
      return shortVar.getShort();
    }
    finally
    {
      COM.VariantClear(oldPtr);
      OS.GlobalFree(oldPtr);
      COM.VariantClear(newPtr);
      OS.GlobalFree(newPtr);
    }
  }
  
  public String getString()
  {
    if (type == 0) {
      OLE.error(1010, -1);
    }
    if (type == 8) {
      return stringData;
    }
    int oldPtr = OS.GlobalAlloc(64, sizeof);
    int newPtr = OS.GlobalAlloc(64, sizeof);
    try
    {
      getData(oldPtr);
      int result = COM.VariantChangeType(newPtr, oldPtr, (short)0, (short)8);
      if (result != 0) {
        OLE.error(1010, result);
      }
      Variant stringVar = new Variant();
      stringVar.setData(newPtr);
      return stringVar.getString();
    }
    finally
    {
      COM.VariantClear(oldPtr);
      OS.GlobalFree(oldPtr);
      COM.VariantClear(newPtr);
      OS.GlobalFree(newPtr);
    }
  }
  
  public short getType()
  {
    return type;
  }
  
  public IUnknown getUnknown()
  {
    if (type == 0) {
      OLE.error(1010, -1);
    }
    if (type == 13) {
      return unknownData;
    }
    int oldPtr = OS.GlobalAlloc(64, sizeof);
    int newPtr = OS.GlobalAlloc(64, sizeof);
    try
    {
      getData(oldPtr);
      int result = COM.VariantChangeType(newPtr, oldPtr, (short)0, (short)13);
      if (result != 0) {
        OLE.error(1010, result);
      }
      Variant unknownVar = new Variant();
      unknownVar.setData(newPtr);
      return unknownVar.getUnknown();
    }
    finally
    {
      COM.VariantClear(oldPtr);
      OS.GlobalFree(oldPtr);
      COM.VariantClear(newPtr);
      
      OS.GlobalFree(newPtr);
    }
  }
  
  public void setByRef(boolean val)
  {
    if (((type & 0x4000) == 0) || ((type & 0xB) == 0)) {
      OLE.error(1010);
    }
    COM.MoveMemory(byRefPtr, new short[] { val ? -1 : 0 }, 2);
  }
  
  public void setByRef(float val)
  {
    if (((type & 0x4000) == 0) || ((type & 0x4) == 0)) {
      OLE.error(1010);
    }
    COM.MoveMemory(byRefPtr, new float[] { val }, 4);
  }
  
  public void setByRef(int val)
  {
    if (((type & 0x4000) == 0) || ((type & 0x3) == 0)) {
      OLE.error(1010);
    }
    COM.MoveMemory(byRefPtr, new int[] { val }, OS.PTR_SIZEOF);
  }
  
  public void setByRef(short val)
  {
    if (((type & 0x4000) == 0) || ((type & 0x2) == 0)) {
      OLE.error(1010);
    }
    COM.MoveMemory(byRefPtr, new short[] { val }, 2);
  }
  
  void setData(int pData)
  {
    if (pData == 0) {
      OLE.error(5);
    }
    short[] dataType = new short[1];
    COM.MoveMemory(dataType, pData, 2);
    type = dataType[0];
    if ((type & 0x4000) == 16384)
    {
      int[] newByRefPtr = new int[1];
      OS.MoveMemory(newByRefPtr, pData + 8, OS.PTR_SIZEOF);
      byRefPtr = newByRefPtr[0];
      return;
    }
    switch (type)
    {
    case 0: 
    case 1: 
      break;
    case 11: 
      short[] newBooleanData = new short[1];
      COM.MoveMemory(newBooleanData, pData + 8, 2);
      booleanData = (newBooleanData[0] != 0);
      break;
    case 16: 
      byte[] newByteData = new byte[1];
      COM.MoveMemory(newByteData, pData + 8, 1);
      byteData = newByteData[0];
      break;
    case 2: 
      short[] newShortData = new short[1];
      COM.MoveMemory(newShortData, pData + 8, 2);
      shortData = newShortData[0];
      break;
    case 18: 
      char[] newCharData = new char[1];
      COM.MoveMemory(newCharData, pData + 8, 2);
      charData = newCharData[0];
      break;
    case 3: 
      int[] newIntData = new int[1];
      OS.MoveMemory(newIntData, pData + 8, 4);
      intData = newIntData[0];
      break;
    case 20: 
      long[] newLongData = new long[1];
      OS.MoveMemory(newLongData, pData + 8, 8);
      longData = newLongData[0];
      break;
    case 4: 
      float[] newFloatData = new float[1];
      COM.MoveMemory(newFloatData, pData + 8, 4);
      floatData = newFloatData[0];
      break;
    case 5: 
      double[] newDoubleData = new double[1];
      COM.MoveMemory(newDoubleData, pData + 8, 8);
      doubleData = newDoubleData[0];
      break;
    case 9: 
      int[] ppvObject = new int[1];
      OS.MoveMemory(ppvObject, pData + 8, OS.PTR_SIZEOF);
      if (ppvObject[0] == 0)
      {
        type = 0;
      }
      else
      {
        dispatchData = new IDispatch(ppvObject[0]);
        dispatchData.AddRef();
      }
      break;
    case 13: 
      int[] ppvObject = new int[1];
      OS.MoveMemory(ppvObject, pData + 8, OS.PTR_SIZEOF);
      if (ppvObject[0] == 0)
      {
        type = 0;
      }
      else
      {
        unknownData = new IUnknown(ppvObject[0]);
        unknownData.AddRef();
      }
      break;
    case 8: 
      int[] hMem = new int[1];
      OS.MoveMemory(hMem, pData + 8, OS.PTR_SIZEOF);
      if (hMem[0] == 0)
      {
        type = 0;
      }
      else
      {
        int size = COM.SysStringByteLen(hMem[0]);
        if (size > 0)
        {
          char[] buffer = new char[(size + 1) / 2];
          COM.MoveMemory(buffer, hMem[0], size);
          stringData = new String(buffer);
        }
        else
        {
          stringData = "";
        }
      }
      break;
    case 6: 
    case 7: 
    case 10: 
    case 12: 
    case 14: 
    case 15: 
    case 17: 
    case 19: 
    default: 
      int newPData = OS.GlobalAlloc(64, sizeof);
      if (COM.VariantChangeType(newPData, pData, (short)0, (short)4) == 0) {
        setData(newPData);
      } else if (COM.VariantChangeType(newPData, pData, (short)0, (short)3) == 0) {
        setData(newPData);
      } else if (COM.VariantChangeType(newPData, pData, (short)0, (short)8) == 0) {
        setData(newPData);
      }
      COM.VariantClear(newPData);
      OS.GlobalFree(newPData);
    }
  }
  
  public String toString()
  {
    switch (type)
    {
    case 11: 
      return "VT_BOOL{" + booleanData + "}";
    case 16: 
      return "VT_I1{" + byteData + "}";
    case 2: 
      return "VT_I2{" + shortData + "}";
    case 18: 
      return "VT_UI2{" + charData + "}";
    case 3: 
      return "VT_I4{" + intData + "}";
    case 20: 
      return "VT_I8{" + longData + "}";
    case 4: 
      return "VT_R4{" + floatData + "}";
    case 5: 
      return "VT_R8{" + doubleData + "}";
    case 8: 
      return "VT_BSTR{" + stringData + "}";
    case 9: 
      return "VT_DISPATCH{" + (dispatchData == null ? 0 : dispatchData.getAddress()) + "}";
    case 13: 
      return "VT_UNKNOWN{" + (unknownData == null ? 0 : unknownData.getAddress()) + "}";
    case 0: 
      return "VT_EMPTY";
    case 1: 
      return "VT_NULL";
    }
    if ((type & 0x4000) != 0) {
      return "VT_BYREF|" + (type & 0xBFFF) + "{" + byRefPtr + "}";
    }
    return "Unsupported Type " + type;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.Variant
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.opengl;

import org.eclipse.swt.internal.opengl.win32.WGL;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class GLCanvas$1
  implements Listener
{
  final GLCanvas this$0;
  
  GLCanvas$1(GLCanvas paramGLCanvas)
  {
    this$0 = paramGLCanvas;
  }
  
  public void handleEvent(Event event)
  {
    switch (type)
    {
    case 12: 
      WGL.wglDeleteContext(this$0.context);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.opengl.GLCanvas.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.opengl;

import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.opengl.win32.PIXELFORMATDESCRIPTOR;
import org.eclipse.swt.internal.opengl.win32.WGL;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public class GLCanvas
  extends Canvas
{
  int context;
  int pixelFormat;
  static final String USE_OWNDC_KEY = "org.eclipse.swt.internal.win32.useOwnDC";
  
  public GLCanvas(Composite parent, int style, GLData data)
  {
    super(parent, checkStyle(parent, style));
    parent.getDisplay().setData("org.eclipse.swt.internal.win32.useOwnDC", new Boolean(false));
    if (data == null) {
      SWT.error(4);
    }
    PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR();
    nSize = 40;
    nVersion = 1;
    dwFlags = 36;
    dwLayerMask = 0;
    iPixelType = 0;
    if (doubleBuffer) {
      dwFlags |= 0x1;
    }
    if (stereo) {
      dwFlags |= 0x2;
    }
    cRedBits = ((byte)redSize);
    cGreenBits = ((byte)greenSize);
    cBlueBits = ((byte)blueSize);
    cAlphaBits = ((byte)alphaSize);
    cDepthBits = ((byte)depthSize);
    cStencilBits = ((byte)stencilSize);
    cAccumRedBits = ((byte)accumRedSize);
    cAccumGreenBits = ((byte)accumGreenSize);
    cAccumBlueBits = ((byte)accumBlueSize);
    cAccumAlphaBits = ((byte)accumAlphaSize);
    cAccumBits = ((byte)(cAccumRedBits + cAccumGreenBits + cAccumBlueBits + cAccumAlphaBits));
    
    int hDC = OS.GetDC(handle);
    pixelFormat = WGL.ChoosePixelFormat(hDC, pfd);
    if ((pixelFormat == 0) || (!WGL.SetPixelFormat(hDC, pixelFormat, pfd)))
    {
      OS.ReleaseDC(handle, hDC);
      dispose();
      SWT.error(38);
    }
    context = WGL.wglCreateContext(hDC);
    if (context == 0)
    {
      OS.ReleaseDC(handle, hDC);
      SWT.error(2);
    }
    OS.ReleaseDC(handle, hDC);
    if (shareContext != null) {
      WGL.wglShareLists(shareContext.context, context);
    }
    Listener listener = new Listener()
    {
      public void handleEvent(Event event)
      {
        switch (type)
        {
        case 12: 
          WGL.wglDeleteContext(context);
        }
      }
    };
    addListener(12, listener);
  }
  
  static int checkStyle(Composite parent, int style)
  {
    if ((parent != null) && 
      (!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0))) {
      parent.getDisplay().setData("org.eclipse.swt.internal.win32.useOwnDC", new Boolean(true));
    }
    return style;
  }
  
  public GLData getGLData()
  {
    checkWidget();
    GLData data = new GLData();
    PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR();
    nSize = 40;
    int hDC = OS.GetDC(handle);
    WGL.DescribePixelFormat(hDC, pixelFormat, 40, pfd);
    OS.ReleaseDC(handle, hDC);
    doubleBuffer = ((dwFlags & 0x1) != 0);
    stereo = ((dwFlags & 0x2) != 0);
    redSize = cRedBits;
    greenSize = cGreenBits;
    blueSize = cBlueBits;
    alphaSize = cAlphaBits;
    depthSize = cDepthBits;
    stencilSize = cStencilBits;
    accumRedSize = cAccumRedBits;
    accumGreenSize = cAccumGreenBits;
    accumBlueSize = cAccumBlueBits;
    accumAlphaSize = cAccumAlphaBits;
    return data;
  }
  
  public boolean isCurrent()
  {
    checkWidget();
    return WGL.wglGetCurrentContext() == context;
  }
  
  public void setCurrent()
  {
    checkWidget();
    if (WGL.wglGetCurrentContext() == context) {
      return;
    }
    int hDC = OS.GetDC(handle);
    WGL.wglMakeCurrent(hDC, context);
    OS.ReleaseDC(handle, hDC);
  }
  
  public void swapBuffers()
  {
    checkWidget();
    int hDC = OS.GetDC(handle);
    WGL.SwapBuffers(hDC);
    OS.ReleaseDC(handle, hDC);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.opengl.GLCanvas
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.opengl;

public class GLData
{
  public boolean doubleBuffer;
  public boolean stereo;
  public int redSize;
  public int greenSize;
  public int blueSize;
  public int alphaSize;
  public int depthSize;
  public int stencilSize;
  public int accumRedSize;
  public int accumGreenSize;
  public int accumBlueSize;
  public int accumAlphaSize;
  public int sampleBuffers;
  public int samples;
  public GLCanvas shareContext;
  
  public String toString()
  {
    return 
    
      (doubleBuffer ? "doubleBuffer," : "") + (stereo ? "stereo," : "") + "r:" + redSize + " g:" + greenSize + " b:" + blueSize + " a:" + alphaSize + "," + "depth:" + depthSize + ",stencil:" + stencilSize + ",accum r:" + accumRedSize + "g:" + accumGreenSize + "b:" + accumBlueSize + "a:" + accumAlphaSize + ",sampleBuffers:" + sampleBuffers + ",samples:" + samples;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.opengl.GLData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.printing;

import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.win32.DEVMODE;
import org.eclipse.swt.internal.win32.DEVMODEA;
import org.eclipse.swt.internal.win32.DEVMODEW;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.PRINTDLG;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class PrintDialog
  extends Dialog
{
  static final TCHAR DialogClass = new TCHAR(0, OS.IsWinCE ? "Dialog" : "#32770", true);
  PrinterData printerData = new PrinterData();
  
  public PrintDialog(Shell parent)
  {
    this(parent, 32768);
  }
  
  public PrintDialog(Shell parent, int style)
  {
    super(parent, checkStyle(parent, style));
    checkSubclass();
  }
  
  static int checkBits(int style, int int0, int int1, int int2, int int3, int int4, int int5)
  {
    int mask = int0 | int1 | int2 | int3 | int4 | int5;
    if ((style & mask) == 0) {
      style |= int0;
    }
    if ((style & int0) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int0;
    }
    if ((style & int1) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int1;
    }
    if ((style & int2) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int2;
    }
    if ((style & int3) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int3;
    }
    if ((style & int4) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int4;
    }
    if ((style & int5) != 0) {
      style = style & (mask ^ 0xFFFFFFFF) | int5;
    }
    return style;
  }
  
  static int checkStyle(Shell parent, int style)
  {
    int mask = 229376;
    if ((style & 0x10000000) != 0)
    {
      style &= 0xEFFFFFFF;
      if ((style & mask) == 0) {
        style |= (parent == null ? 65536 : 32768);
      }
    }
    if ((style & mask) == 0) {
      style |= 0x10000;
    }
    style &= 0xF7FFFFFF;
    if (((style & 0x6000000) == 0) && 
      (parent != null))
    {
      if ((parent.getStyle() & 0x2000000) != 0) {
        style |= 0x2000000;
      }
      if ((parent.getStyle() & 0x4000000) != 0) {
        style |= 0x4000000;
      }
    }
    return checkBits(style, 33554432, 67108864, 0, 0, 0, 0);
  }
  
  public void setPrinterData(PrinterData data)
  {
    if (data == null) {
      data = new PrinterData();
    }
    printerData = data;
  }
  
  public PrinterData getPrinterData()
  {
    return printerData;
  }
  
  public int getScope()
  {
    return printerData.scope;
  }
  
  public void setScope(int scope)
  {
    printerData.scope = scope;
  }
  
  public int getStartPage()
  {
    return printerData.startPage;
  }
  
  public void setStartPage(int startPage)
  {
    printerData.startPage = startPage;
  }
  
  public int getEndPage()
  {
    return printerData.endPage;
  }
  
  public void setEndPage(int endPage)
  {
    printerData.endPage = endPage;
  }
  
  public boolean getPrintToFile()
  {
    return printerData.printToFile;
  }
  
  public void setPrintToFile(boolean printToFile)
  {
    printerData.printToFile = printToFile;
  }
  
  protected void checkSubclass()
  {
    String name = getClass().getName();
    String validName = PrintDialog.class.getName();
    if (!validName.equals(name)) {
      SWT.error(43);
    }
  }
  
  public PrinterData open()
  {
    Control parent = getParent();
    int style = getStyle();
    int hwndOwner = handle;
    int hwndParent = handle;
    
    boolean enabled = false;
    if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(4, 10)))
    {
      int dialogOrientation = style & 0x6000000;
      int parentOrientation = parent.getStyle() & 0x6000000;
      if (dialogOrientation != parentOrientation)
      {
        int exStyle = 1048576;
        if (dialogOrientation == 67108864) {
          exStyle |= 0x400000;
        }
        hwndOwner = OS.CreateWindowEx(
          exStyle, 
          DialogClass, 
          null, 
          0, 
          Integer.MIN_VALUE, 0, Integer.MIN_VALUE, 0, 
          hwndParent, 
          0, 
          OS.GetModuleHandle(null), 
          null);
        enabled = OS.IsWindowEnabled(hwndParent);
        if (enabled) {
          OS.EnableWindow(hwndParent, false);
        }
      }
    }
    PrinterData data = null;
    PRINTDLG pd = new PRINTDLG();
    lStructSize = PRINTDLG.sizeof;
    hwndOwner = hwndOwner;
    
    boolean success = false;
    if (printerData.name != null)
    {
      PrinterData[] printerList = Printer.getPrinterList();
      if (printerList.length > 0) {
        for (int p = 0; p < printerList.length; p++) {
          if (name.equals(printerData.name))
          {
            success = true;
            break;
          }
        }
      }
      if (success)
      {
        TCHAR buffer = new TCHAR(0, printerData.name, true);
        int size = buffer.length() * TCHAR.sizeof;
        short[] offsets = new short[4];
        int offsetsSize = offsets.length * 2;
        offsets[1] = ((short)offsets.length);
        int hMem = OS.GlobalAlloc(66, offsetsSize + size);
        int ptr = OS.GlobalLock(hMem);
        OS.MoveMemory(ptr, offsets, offsetsSize);
        OS.MoveMemory(ptr + offsetsSize, buffer, size);
        OS.GlobalUnlock(hMem);
        hDevNames = hMem;
      }
    }
    if (!success)
    {
      Flags = 1024;
      if (((success = OS.PrintDlg(pd))) && 
        (hDevNames != 0))
      {
        OS.GlobalFree(hDevNames);
        hDevNames = 0;
      }
    }
    if (success)
    {
      byte[] devmodeData = printerData.otherData;
      if ((devmodeData != null) && (devmodeData.length != 0))
      {
        int hMem = OS.GlobalAlloc(66, devmodeData.length);
        int ptr = OS.GlobalLock(hMem);
        OS.MoveMemory(ptr, devmodeData, devmodeData.length);
        OS.GlobalUnlock(hMem);
        if (hDevMode != 0) {
          OS.GlobalFree(hDevMode);
        }
        hDevMode = hMem;
      }
      int hMem = hDevMode;
      if (hMem == 0)
      {
        hMem = OS.GlobalAlloc(66, DEVMODE.sizeof);
        hDevMode = hMem;
      }
      int ptr = OS.GlobalLock(hMem);
      DEVMODE devmode = OS.IsUnicode ? new DEVMODEW() : new DEVMODEA();
      OS.MoveMemory(devmode, ptr, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
      if (printerData.name != null)
      {
        int max = Math.min(printerData.name.length(), 31);
        if (OS.IsUnicode)
        {
          for (int i = 0; i < max; i++) {
            dmDeviceName[i] = printerData.name.charAt(i);
          }
        }
        else
        {
          byte[] bytes = printerData.name.getBytes();
          for (int i = 0; i < max; i++) {
            dmDeviceName[i] = bytes[i];
          }
        }
      }
      dmFields |= 0x1;
      dmOrientation = (printerData.orientation == 1 ? 1 : 2);
      if (printerData.copyCount != 1)
      {
        dmFields |= 0x100;
        dmCopies = ((short)printerData.copyCount);
      }
      if (printerData.collate)
      {
        dmFields |= 0x8000;
        dmCollate = 1;
      }
      if (printerData.duplex != -1)
      {
        dmFields |= 0x1000;
        switch (printerData.duplex)
        {
        case 2: 
          dmDuplex = 3; break;
        case 1: 
          dmDuplex = 2; break;
        default: 
          dmDuplex = 1;
        }
      }
      OS.MoveMemory(ptr, devmode, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
      OS.GlobalUnlock(hMem);
      
      Flags = 262144;
      if (printerData.printToFile) {
        Flags |= 0x20;
      }
      switch (printerData.scope)
      {
      case 1: 
        Flags |= 0x2; break;
      case 2: 
        Flags |= 0x1; break;
      default: 
        Flags |= 0x0;
      }
      nMinPage = 1;
      nMaxPage = -1;
      nFromPage = ((short)Math.min(65535, Math.max(1, printerData.startPage)));
      nToPage = ((short)Math.min(65535, Math.max(1, printerData.endPage)));
      
      Display display = parent.getDisplay();
      Shell[] shells = display.getShells();
      if ((getStyle() & 0x30000) != 0) {
        for (int i = 0; i < shells.length; i++) {
          if ((shells[i].isEnabled()) && (shells[i] != parent)) {
            shells[i].setEnabled(false);
          } else {
            shells[i] = null;
          }
        }
      }
      String key = "org.eclipse.swt.internal.win32.runMessagesInIdle";
      Object oldValue = display.getData(key);
      display.setData(key, new Boolean(true));
      success = OS.PrintDlg(pd);
      display.setData(key, oldValue);
      if ((getStyle() & 0x30000) != 0) {
        for (int i = 0; i < shells.length; i++) {
          if ((shells[i] != null) && (!shells[i].isDisposed())) {
            shells[i].setEnabled(true);
          }
        }
      }
      if (success)
      {
        hMem = hDevNames;
        
        int size = OS.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
        ptr = OS.GlobalLock(hMem);
        short[] offsets = new short[4];
        OS.MoveMemory(offsets, ptr, 2 * offsets.length);
        TCHAR buffer = new TCHAR(0, size);
        OS.MoveMemory(buffer, ptr, size);
        OS.GlobalUnlock(hMem);
        
        int driverOffset = offsets[0];
        int i = 0;
        while (driverOffset + i < size)
        {
          if (buffer.tcharAt(driverOffset + i) == 0) {
            break;
          }
          i++;
        }
        String driver = buffer.toString(driverOffset, i);
        
        int deviceOffset = offsets[1];
        i = 0;
        while (deviceOffset + i < size)
        {
          if (buffer.tcharAt(deviceOffset + i) == 0) {
            break;
          }
          i++;
        }
        String device = buffer.toString(deviceOffset, i);
        
        data = new PrinterData(driver, device);
        if ((Flags & 0x2) != 0)
        {
          scope = 1;
          startPage = (nFromPage & 0xFFFF);
          endPage = (nToPage & 0xFFFF);
        }
        else if ((Flags & 0x1) != 0)
        {
          scope = 2;
        }
        printToFile = ((Flags & 0x20) != 0);
        if (printToFile) {
          fileName = printerData.fileName;
        }
        copyCount = nCopies;
        collate = ((Flags & 0x10) != 0);
        
        hMem = hDevMode;
        size = OS.GlobalSize(hMem);
        ptr = OS.GlobalLock(hMem);
        otherData = new byte[size];
        OS.MoveMemory(otherData, ptr, size);
        
        devmode = OS.IsUnicode ? new DEVMODEW() : new DEVMODEA();
        OS.MoveMemory(devmode, ptr, OS.IsUnicode ? OS.DEVMODEW_sizeof() : OS.DEVMODEA_sizeof());
        if ((dmFields & 0x1) != 0)
        {
          int dmOrientation = dmOrientation;
          orientation = (dmOrientation == 2 ? 2 : 1);
        }
        if ((dmFields & 0x1000) != 0)
        {
          short dmDuplex = dmDuplex;
          duplex = (dmDuplex == 3 ? 2 : dmDuplex == 1 ? 0 : 1);
        }
        OS.GlobalUnlock(hMem);
        printerData = data;
      }
    }
    if (hDevNames != 0)
    {
      OS.GlobalFree(hDevNames);
      hDevNames = 0;
    }
    if (hDevMode != 0)
    {
      OS.GlobalFree(hDevMode);
      hDevMode = 0;
    }
    if (hwndParent != hwndOwner)
    {
      if (enabled) {
        OS.EnableWindow(hwndParent, true);
      }
      OS.SetActiveWindow(hwndParent);
      OS.DestroyWindow(hwndOwner);
    }
    return data;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.printing.PrintDialog
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.printing;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.DeviceData;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GCData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.DEVMODE;
import org.eclipse.swt.internal.win32.DEVMODEA;
import org.eclipse.swt.internal.win32.DEVMODEW;
import org.eclipse.swt.internal.win32.DOCINFO;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.TCHAR;

public final class Printer
  extends Device
{
  public int handle;
  PrinterData data;
  boolean isGCCreated = false;
  static TCHAR profile = new TCHAR(0, "PrinterPorts", true);
  static TCHAR appName = new TCHAR(0, "windows", true);
  static TCHAR keyName = new TCHAR(0, "device", true);
  
  public static PrinterData[] getPrinterList()
  {
    int length = 1024;
    
    TCHAR buf = new TCHAR(0, length);
    TCHAR nullBuf = new TCHAR(0, 1);
    int n = OS.GetProfileString(profile, null, nullBuf, buf, length);
    if (n == 0) {
      return new PrinterData[0];
    }
    String[] deviceNames = new String[5];
    int nameCount = 0;
    int index = 0;
    for (int i = 0; i < n; i++) {
      if (buf.tcharAt(i) == 0)
      {
        if (nameCount == deviceNames.length)
        {
          String[] newNames = new String[deviceNames.length + 5];
          System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length);
          deviceNames = newNames;
        }
        deviceNames[nameCount] = buf.toString(index, i - index);
        nameCount++;
        index = i + 1;
      }
    }
    PrinterData[] printerList = new PrinterData[nameCount];
    for (int p = 0; p < nameCount; p++)
    {
      String device = deviceNames[p];
      String driver = "";
      if (OS.GetProfileString(profile, new TCHAR(0, device, true), nullBuf, buf, length) > 0)
      {
        int commaIndex = 0;
        while ((buf.tcharAt(commaIndex) != 44) && (commaIndex < length)) {
          commaIndex++;
        }
        if (commaIndex < length) {
          driver = buf.toString(0, commaIndex);
        }
      }
      printerList[p] = new PrinterData(driver, device);
    }
    return printerList;
  }
  
  public static PrinterData getDefaultPrinterData()
  {
    String deviceName = null;
    int length = 1024;
    
    TCHAR buf = new TCHAR(0, length);
    TCHAR nullBuf = new TCHAR(0, 1);
    int n = OS.GetProfileString(appName, keyName, nullBuf, buf, length);
    if (n == 0) {
      return null;
    }
    int commaIndex = 0;
    while ((buf.tcharAt(commaIndex) != 44) && (commaIndex < length)) {
      commaIndex++;
    }
    if (commaIndex < length) {
      deviceName = buf.toString(0, commaIndex);
    }
    if (deviceName == null) {
      return null;
    }
    String driver = "";
    if (OS.GetProfileString(profile, new TCHAR(0, deviceName, true), nullBuf, buf, length) > 0)
    {
      commaIndex = 0;
      while ((buf.tcharAt(commaIndex) != 44) && (commaIndex < length)) {
        commaIndex++;
      }
      if (commaIndex < length) {
        driver = buf.toString(0, commaIndex);
      }
    }
    return new PrinterData(driver, deviceName);
  }
  
  static DeviceData checkNull(PrinterData data)
  {
    if (data == null) {
      data = new PrinterData();
    }
    if ((driver == null) || (name == null))
    {
      PrinterData defaultPrinter = getDefaultPrinterData();
      if (defaultPrinter == null) {
        SWT.error(2);
      }
      driver = driver;
      name = name;
    }
    return data;
  }
  
  public Printer()
  {
    this(null);
  }
  
  public Printer(PrinterData data)
  {
    super(checkNull(data));
  }
  
  protected void create(DeviceData deviceData)
  {
    data = ((PrinterData)deviceData);
    
    TCHAR driver = new TCHAR(0, data.driver, true);
    TCHAR device = new TCHAR(0, data.name, true);
    int lpInitData = 0;
    byte[] devmodeData = data.otherData;
    int hHeap = OS.GetProcessHeap();
    if ((devmodeData != null) && (devmodeData.length != 0))
    {
      lpInitData = OS.HeapAlloc(hHeap, 8, devmodeData.length);
      OS.MoveMemory(lpInitData, devmodeData, devmodeData.length);
    }
    else if (!OS.IsWinCE)
    {
      int[] hPrinter = new int[1];
      OS.OpenPrinter(device, hPrinter, 0);
      if (hPrinter[0] != 0)
      {
        int dwNeeded = OS.DocumentProperties(0, hPrinter[0], device, 0, 0, 0);
        if (dwNeeded >= 0)
        {
          lpInitData = OS.HeapAlloc(hHeap, 8, dwNeeded);
          int rc = OS.DocumentProperties(0, hPrinter[0], device, lpInitData, 0, 2);
          if (rc != 1)
          {
            OS.HeapFree(hHeap, 0, lpInitData);
            lpInitData = 0;
          }
        }
        OS.ClosePrinter(hPrinter[0]);
      }
    }
    if (lpInitData != 0)
    {
      DEVMODE devmode = OS.IsUnicode ? new DEVMODEW() : new DEVMODEA();
      OS.MoveMemory(devmode, lpInitData, DEVMODE.sizeof);
      dmFields |= 0x1;
      dmOrientation = (data.orientation == 2 ? 2 : 1);
      if (data.copyCount != 1)
      {
        dmFields |= 0x100;
        dmCopies = ((short)data.copyCount);
      }
      if (data.collate)
      {
        dmFields |= 0x8000;
        dmCollate = 1;
      }
      if (data.duplex != -1)
      {
        dmFields |= 0x1000;
        switch (data.duplex)
        {
        case 2: 
          dmDuplex = 3; break;
        case 1: 
          dmDuplex = 2; break;
        default: 
          dmDuplex = 1;
        }
      }
      OS.MoveMemory(lpInitData, devmode, DEVMODE.sizeof);
    }
    handle = OS.CreateDC(driver, device, 0, lpInitData);
    if (lpInitData != 0) {
      OS.HeapFree(hHeap, 0, lpInitData);
    }
    if (handle == 0) {
      SWT.error(2);
    }
  }
  
  public int internal_new_GC(GCData data)
  {
    if (handle == 0) {
      SWT.error(2);
    }
    if (data != null)
    {
      if (isGCCreated) {
        SWT.error(5);
      }
      int mask = 100663296;
      if ((style & mask) != 0) {
        layout = ((style & 0x4000000) != 0 ? 1 : 0);
      } else {
        style |= 0x2000000;
      }
      device = this;
      font = Font.win32_new(this, OS.GetCurrentObject(handle, 6));
      isGCCreated = true;
    }
    return handle;
  }
  
  public void internal_dispose_GC(int hDC, GCData data)
  {
    if (data != null) {
      isGCCreated = false;
    }
  }
  
  public boolean startJob(String jobName)
  {
    checkDevice();
    DOCINFO di = new DOCINFO();
    cbSize = DOCINFO.sizeof;
    int hHeap = OS.GetProcessHeap();
    int lpszDocName = 0;
    if ((jobName != null) && (jobName.length() != 0))
    {
      TCHAR buffer = new TCHAR(0, jobName, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      lpszDocName = OS.HeapAlloc(hHeap, 8, byteCount);
      OS.MoveMemory(lpszDocName, buffer, byteCount);
      lpszDocName = lpszDocName;
    }
    int lpszOutput = 0;
    if (data.printToFile)
    {
      if (data.fileName == null) {
        data.fileName = "FILE:";
      }
      TCHAR buffer = new TCHAR(0, data.fileName, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      lpszOutput = OS.HeapAlloc(hHeap, 8, byteCount);
      OS.MoveMemory(lpszOutput, buffer, byteCount);
      lpszOutput = lpszOutput;
    }
    int rc = OS.StartDoc(handle, di);
    if (lpszDocName != 0) {
      OS.HeapFree(hHeap, 0, lpszDocName);
    }
    if (lpszOutput != 0) {
      OS.HeapFree(hHeap, 0, lpszOutput);
    }
    return rc > 0;
  }
  
  public void endJob()
  {
    checkDevice();
    OS.EndDoc(handle);
  }
  
  public void cancelJob()
  {
    checkDevice();
    OS.AbortDoc(handle);
  }
  
  public boolean startPage()
  {
    checkDevice();
    int rc = OS.StartPage(handle);
    if (rc <= 0) {
      OS.AbortDoc(handle);
    }
    return rc > 0;
  }
  
  public void endPage()
  {
    checkDevice();
    OS.EndPage(handle);
  }
  
  public Point getDPI()
  {
    checkDevice();
    int dpiX = OS.GetDeviceCaps(handle, 88);
    int dpiY = OS.GetDeviceCaps(handle, 90);
    return new Point(dpiX, dpiY);
  }
  
  public Rectangle getBounds()
  {
    checkDevice();
    int width = OS.GetDeviceCaps(handle, 110);
    int height = OS.GetDeviceCaps(handle, 111);
    return new Rectangle(0, 0, width, height);
  }
  
  public Rectangle getClientArea()
  {
    checkDevice();
    int width = OS.GetDeviceCaps(handle, 8);
    int height = OS.GetDeviceCaps(handle, 10);
    return new Rectangle(0, 0, width, height);
  }
  
  public Rectangle computeTrim(int x, int y, int width, int height)
  {
    checkDevice();
    int printX = -OS.GetDeviceCaps(handle, 112);
    int printY = -OS.GetDeviceCaps(handle, 113);
    int printWidth = OS.GetDeviceCaps(handle, 8);
    int printHeight = OS.GetDeviceCaps(handle, 10);
    int paperWidth = OS.GetDeviceCaps(handle, 110);
    int paperHeight = OS.GetDeviceCaps(handle, 111);
    int hTrim = paperWidth - printWidth;
    int vTrim = paperHeight - printHeight;
    return new Rectangle(x + printX, y + printY, width + hTrim, height + vTrim);
  }
  
  public PrinterData getPrinterData()
  {
    return data;
  }
  
  protected void checkDevice()
  {
    if (handle == 0) {
      SWT.error(45);
    }
  }
  
  protected void release()
  {
    super.release();
    data = null;
  }
  
  protected void destroy()
  {
    if (handle != 0) {
      OS.DeleteDC(handle);
    }
    handle = 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.printing.Printer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.printing;

import org.eclipse.swt.graphics.DeviceData;

public final class PrinterData
  extends DeviceData
{
  public String driver;
  public String name;
  public int scope = 0;
  public int startPage = 1;
  public int endPage = 1;
  public boolean printToFile = false;
  public String fileName;
  public int copyCount = 1;
  public boolean collate = false;
  public int orientation = 1;
  public int duplex = -1;
  public static final int ALL_PAGES = 0;
  public static final int PAGE_RANGE = 1;
  public static final int SELECTION = 2;
  public static final int PORTRAIT = 1;
  public static final int LANDSCAPE = 2;
  public static final int DUPLEX_NONE = 0;
  public static final int DUPLEX_LONG_EDGE = 1;
  public static final int DUPLEX_SHORT_EDGE = 2;
  byte[] otherData;
  
  public PrinterData() {}
  
  public PrinterData(String driver, String name)
  {
    this.driver = driver;
    this.name = name;
  }
  
  public String toString()
  {
    return "PrinterData {driver = " + driver + ", name = " + name + "}";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.printing.PrinterData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.program;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.internal.win32.FILETIME;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.PROCESS_INFORMATION;
import org.eclipse.swt.internal.win32.SHELLEXECUTEINFO;
import org.eclipse.swt.internal.win32.SHFILEINFO;
import org.eclipse.swt.internal.win32.SHFILEINFOA;
import org.eclipse.swt.internal.win32.SHFILEINFOW;
import org.eclipse.swt.internal.win32.STARTUPINFO;
import org.eclipse.swt.internal.win32.TCHAR;

public final class Program
{
  String name;
  String command;
  String iconName;
  String extension;
  static final String[] ARGUMENTS = { "%1", "%l", "%L" };
  
  static String assocQueryString(int assocStr, TCHAR key, boolean expand)
  {
    TCHAR pszOut = new TCHAR(0, 1024);
    int[] pcchOut = new int[1];
    pcchOut[0] = pszOut.length();
    int flags = 1056;
    int result = OS.AssocQueryString(flags, assocStr, key, null, pszOut, pcchOut);
    if (result == -2147467261)
    {
      pszOut = new TCHAR(0, pcchOut[0]);
      result = OS.AssocQueryString(flags, assocStr, key, null, pszOut, pcchOut);
    }
    if (result == 0)
    {
      if ((!OS.IsWinCE) && (expand))
      {
        int length = OS.ExpandEnvironmentStrings(pszOut, null, 0);
        if (length != 0)
        {
          TCHAR lpDst = new TCHAR(0, length);
          OS.ExpandEnvironmentStrings(pszOut, lpDst, length);
          return lpDst.toString(0, Math.max(0, length - 1));
        }
        return "";
      }
      return pszOut.toString(0, Math.max(0, pcchOut[0] - 1));
    }
    return null;
  }
  
  public static Program findProgram(String extension)
  {
    if (extension == null) {
      SWT.error(4);
    }
    if (extension.length() == 0) {
      return null;
    }
    if (extension.charAt(0) != '.') {
      extension = "." + extension;
    }
    TCHAR key = new TCHAR(0, extension, true);
    Program program = null;
    if (OS.IsWinCE)
    {
      int[] phkResult = new int[1];
      if (OS.RegOpenKeyEx(Integer.MIN_VALUE, key, 0, 131097, phkResult) != 0) {
        return null;
      }
      int[] lpcbData = new int[1];
      int result = OS.RegQueryValueEx(phkResult[0], null, 0, null, null, lpcbData);
      if (result == 0)
      {
        TCHAR lpData = new TCHAR(0, lpcbData[0] / TCHAR.sizeof);
        result = OS.RegQueryValueEx(phkResult[0], null, 0, null, lpData, lpcbData);
        if (result == 0) {
          program = getProgram(lpData.toString(0, lpData.strlen()), extension);
        }
      }
      OS.RegCloseKey(phkResult[0]);
    }
    else
    {
      String command = assocQueryString(1, key, true);
      if (command != null)
      {
        String name = null;
        if (name == null) {
          name = assocQueryString(3, key, false);
        }
        if (name == null) {
          name = assocQueryString(4, key, false);
        }
        if (name == null) {
          name = "";
        }
        String iconName = assocQueryString(15, key, true);
        if (iconName == null) {
          iconName = "";
        }
        program = new Program();
        name = name;
        command = command;
        iconName = iconName;
        extension = extension;
      }
    }
    return program;
  }
  
  public static String[] getExtensions()
  {
    String[] extensions = new String['?'];
    
    TCHAR lpName = new TCHAR(0, 1024);
    int[] lpcName = { lpName.length() };
    FILETIME ft = new FILETIME();
    int dwIndex = 0;int count = 0;
    while (OS.RegEnumKeyEx(Integer.MIN_VALUE, dwIndex, lpName, lpcName, null, null, null, ft) != 259)
    {
      String exte
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd