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

   if (uBand != -1)
      {
        CoolItem item = items[wID];
        Control control = control;
        if (control != null)
        {
          int width = rcChild_right - rcChild_left;
          int height = rcChild_bottom - rcChild_top;
          control.setBounds(rcChild_left, rcChild_top, width, height);
        }
      }
      break;
    case -831: 
      if (!ignoreResize)
      {
        Point size = getSize();
        int border = getBorderWidth();
        int barHeight = OS.SendMessage(handle, 1051, 0, 0);
        if ((style & 0x200) != 0) {
          setSize(barHeight + 2 * border, y);
        } else {
          setSize(x, barHeight + 2 * border);
        }
      }
      break;
    case -841: 
      NMREBARCHEVRON lpnm = new NMREBARCHEVRON();
      OS.MoveMemory(lpnm, lParam, NMREBARCHEVRON.sizeof);
      CoolItem item = items[wID];
      if (item != null)
      {
        Event event = new Event();
        detail = 4;
        if ((style & 0x200) != 0)
        {
          x = right;
          y = top;
        }
        else
        {
          x = left;
          y = bottom;
        }
        item.sendSelectionEvent(13, event, false);
      }
      break;
    case -12: 
      if ((OS.COMCTL32_MAJOR >= 6) && (
        (findBackgroundControl() != null) || ((style & 0x800000) != 0)))
      {
        NMCUSTOMDRAW nmcd = new NMCUSTOMDRAW();
        OS.MoveMemory(nmcd, lParam, NMCUSTOMDRAW.sizeof);
        switch (dwDrawStage)
        {
        case 3: 
          return new LRESULT(68);
        case 4: 
          drawBackground(hdc);
        }
      }
      break;
    }
    return super.wmNotifyChild(hdr, wParam, lParam);
  }
}

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

import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.MARGINS;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.REBARBANDINFO;
import org.eclipse.swt.internal.win32.RECT;

public class CoolItem
  extends Item
{
  CoolBar parent;
  Control control;
  int id;
  boolean ideal;
  boolean minimum;
  
  public CoolItem(CoolBar parent, int style)
  {
    super(parent, style);
    this.parent = parent;
    parent.createItem(this, parent.getItemCount());
  }
  
  public CoolItem(CoolBar parent, int style, int index)
  {
    super(parent, style);
    this.parent = parent;
    parent.createItem(this, index);
  }
  
  public void addSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(13, typedListener);
    addListener(14, typedListener);
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  public Point computeSize(int wHint, int hHint)
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return new Point(0, 0);
    }
    int width = wHint;int height = hHint;
    if (wHint == -1) {
      width = 32;
    }
    if (hHint == -1) {
      height = 32;
    }
    if ((parent.style & 0x200) != 0) {
      height += parent.getMargin(index);
    } else {
      width += parent.getMargin(index);
    }
    return new Point(width, height);
  }
  
  void destroyWidget()
  {
    parent.destroyItem(this);
    releaseHandle();
  }
  
  public Rectangle getBounds()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return new Rectangle(0, 0, 0, 0);
    }
    int hwnd = parent.handle;
    RECT rect = new RECT();
    OS.SendMessage(hwnd, 1033, index, rect);
    if (OS.COMCTL32_MAJOR >= 6)
    {
      MARGINS margins = new MARGINS();
      OS.SendMessage(hwnd, 1064, 0, margins);
      left -= cxLeftWidth;
      right += cxRightWidth;
    }
    if (!parent.isLastItemOfRow(index)) {
      right += ((parent.style & 0x800000) == 0 ? 2 : 0);
    }
    int width = right - left;
    int height = bottom - top;
    if ((parent.style & 0x200) != 0) {
      return new Rectangle(top, left, height, width);
    }
    return new Rectangle(left, top, width, height);
  }
  
  Rectangle getClientArea()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return new Rectangle(0, 0, 0, 0);
    }
    int hwnd = parent.handle;
    RECT insetRect = new RECT();
    OS.SendMessage(hwnd, 1058, index, insetRect);
    RECT rect = new RECT();
    OS.SendMessage(hwnd, 1033, index, rect);
    int x = left + left;
    int y = top;
    int width = right - left - left;
    int height = bottom - top;
    if ((parent.style & 0x800000) == 0)
    {
      y += top;
      width -= right;
      height -= top + bottom;
    }
    if (index == 0)
    {
      REBARBANDINFO rbBand = new REBARBANDINFO();
      cbSize = REBARBANDINFO.sizeof;
      fMask = 2048;
      OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
      width = width - cxHeader + 1;
    }
    return new Rectangle(x, y, Math.max(0, width), Math.max(0, height));
  }
  
  public Control getControl()
  {
    checkWidget();
    return control;
  }
  
  public CoolBar getParent()
  {
    checkWidget();
    return parent;
  }
  
  void releaseHandle()
  {
    super.releaseHandle();
    parent = null;
    id = -1;
    control = null;
  }
  
  public void setControl(Control control)
  {
    checkWidget();
    if (control != null)
    {
      if (control.isDisposed()) {
        error(5);
      }
      if (parent != parent) {
        error(32);
      }
    }
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    if ((this.control != null) && (this.control.isDisposed())) {
      this.control = null;
    }
    Control oldControl = this.control;Control newControl = control;
    int hwnd = parent.handle;
    int hwndChild = newControl != null ? control.topHandle() : 0;
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 16;
    hwndChild = hwndChild;
    this.control = newControl;
    
    int hwndAbove = 0;
    if (newControl != null) {
      hwndAbove = OS.GetWindow(hwndChild, 3);
    }
    boolean hideNew = (newControl != null) && (!newControl.getVisible());
    boolean showOld = (oldControl != null) && (oldControl.getVisible());
    OS.SendMessage(hwnd, OS.RB_SETBANDINFO, index, rbBand);
    if (hideNew) {
      newControl.setVisible(false);
    }
    if (showOld) {
      oldControl.setVisible(true);
    }
    if ((hwndAbove != 0) && (hwndAbove != hwndChild))
    {
      int flags = 19;
      SetWindowPos(hwndChild, hwndAbove, 0, 0, 0, 0, flags);
    }
  }
  
  public Point getPreferredSize()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return new Point(0, 0);
    }
    int hwnd = parent.handle;
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 544;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    int width = cxIdeal + parent.getMargin(index);
    if ((parent.style & 0x200) != 0) {
      return new Point(cyMaxChild, width);
    }
    return new Point(width, cyMaxChild);
  }
  
  public void setPreferredSize(int width, int height)
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    width = Math.max(0, width);
    height = Math.max(0, height);
    ideal = true;
    int hwnd = parent.handle;
    int cyMaxChild;
    int cxIdeal;
    int cyMaxChild;
    if ((parent.style & 0x200) != 0)
    {
      int cxIdeal = Math.max(0, height - parent.getMargin(index));
      cyMaxChild = width;
    }
    else
    {
      cxIdeal = Math.max(0, width - parent.getMargin(index));
      cyMaxChild = height;
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    
    fMask = 32;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    
    fMask = 544;
    cxIdeal = cxIdeal;
    cyMaxChild = cyMaxChild;
    if (!minimum) {
      cyMinChild = cyMaxChild;
    }
    OS.SendMessage(hwnd, OS.RB_SETBANDINFO, index, rbBand);
  }
  
  public void setPreferredSize(Point size)
  {
    checkWidget();
    if (size == null) {
      error(4);
    }
    setPreferredSize(x, y);
  }
  
  public Point getSize()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      new Point(0, 0);
    }
    int hwnd = parent.handle;
    RECT rect = new RECT();
    OS.SendMessage(hwnd, 1033, index, rect);
    if (OS.COMCTL32_MAJOR >= 6)
    {
      MARGINS margins = new MARGINS();
      OS.SendMessage(hwnd, 1064, 0, margins);
      left -= cxLeftWidth;
      right += cxRightWidth;
    }
    if (!parent.isLastItemOfRow(index)) {
      right += ((parent.style & 0x800000) == 0 ? 2 : 0);
    }
    int width = right - left;
    int height = bottom - top;
    if ((parent.style & 0x200) != 0) {
      return new Point(height, width);
    }
    return new Point(width, height);
  }
  
  public void setSize(int width, int height)
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    width = Math.max(0, width);
    height = Math.max(0, height);
    int hwnd = parent.handle;
    int cxIdeal;
    int cx;
    int cyChild;
    int cxIdeal;
    if ((parent.style & 0x200) != 0)
    {
      int cx = height;
      int cyChild = width;
      cxIdeal = Math.max(0, height - parent.getMargin(index));
    }
    else
    {
      cx = width;
      cyChild = height;
      cxIdeal = Math.max(0, width - parent.getMargin(index));
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    
    fMask = 544;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    if (!ideal) {
      cxIdeal = cxIdeal;
    }
    if (!minimum) {
      cyMinChild = cyChild;
    }
    cyChild = cyChild;
    if (!parent.isLastItemOfRow(index))
    {
      if (OS.COMCTL32_MAJOR >= 6)
      {
        MARGINS margins = new MARGINS();
        OS.SendMessage(hwnd, 1064, 0, margins);
        cx -= cxLeftWidth + cxRightWidth;
      }
      int separator = (parent.style & 0x800000) == 0 ? 2 : 0;
      cx = (cx - separator);
      fMask |= 0x40;
    }
    OS.SendMessage(hwnd, OS.RB_SETBANDINFO, index, rbBand);
  }
  
  public void setSize(Point size)
  {
    if (size == null) {
      error(4);
    }
    setSize(x, y);
  }
  
  public Point getMinimumSize()
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return new Point(0, 0);
    }
    int hwnd = parent.handle;
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 32;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    if ((parent.style & 0x200) != 0) {
      return new Point(cyMinChild, cxMinChild);
    }
    return new Point(cxMinChild, cyMinChild);
  }
  
  public void setMinimumSize(int width, int height)
  {
    checkWidget();
    int index = parent.indexOf(this);
    if (index == -1) {
      return;
    }
    width = Math.max(0, width);
    height = Math.max(0, height);
    minimum = true;
    int hwnd = parent.handle;
    int cyMinChild;
    int cxMinChild;
    int cyMinChild;
    if ((parent.style & 0x200) != 0)
    {
      int cxMinChild = height;
      cyMinChild = width;
    }
    else
    {
      cxMinChild = width;
      cyMinChild = height;
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    
    fMask = 32;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    
    cxMinChild = cxMinChild;
    cyMinChild = cyMinChild;
    OS.SendMessage(hwnd, OS.RB_SETBANDINFO, index, rbBand);
  }
  
  public void setMinimumSize(Point size)
  {
    checkWidget();
    if (size == null) {
      error(4);
    }
    setMinimumSize(x, y);
  }
  
  boolean getWrap()
  {
    int index = parent.indexOf(this);
    int hwnd = parent.handle;
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 1;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    return (fStyle & 0x1) != 0;
  }
  
  void setWrap(boolean wrap)
  {
    int index = parent.indexOf(this);
    int hwnd = parent.handle;
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 1;
    OS.SendMessage(hwnd, OS.RB_GETBANDINFO, index, rbBand);
    if (wrap) {
      fStyle |= 0x1;
    } else {
      fStyle &= 0xFFFFFFFE;
    }
    OS.SendMessage(hwnd, OS.RB_SETBANDINFO, index, rbBand);
  }
  
  public void removeSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(13, listener);
    eventTable.unhook(14, listener);
  }
}

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

import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.internal.win32.INITCOMMONCONTROLSEX;
import org.eclipse.swt.internal.win32.LRESULT;
import org.eclipse.swt.internal.win32.MCHITTESTINFO;
import org.eclipse.swt.internal.win32.NMHDR;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.POINT;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.SIZE;
import org.eclipse.swt.internal.win32.SYSTEMTIME;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.internal.win32.WNDCLASS;

public class DateTime
  extends Composite
{
  static final int MIN_YEAR = 1752;
  static final int MAX_YEAR = 9999;
  boolean doubleClick;
  boolean ignoreSelection;
  SYSTEMTIME lastSystemTime;
  SYSTEMTIME time = new SYSTEMTIME();
  static final int DateTimeProc;
  static final TCHAR DateTimeClass = new TCHAR(0, "SysDateTimePick32", true);
  static final int CalendarProc;
  static final TCHAR CalendarClass = new TCHAR(0, "SysMonthCal32", true);
  static final int MARGIN = 4;
  static final int MAX_DIGIT = 9;
  static final int MAX_DAY = 31;
  static final int MAX_12HOUR = 12;
  static final int MAX_24HOUR = 24;
  static final int MAX_MINUTE = 60;
  static final int MONTH_DAY_YEAR = 0;
  static final int DAY_MONTH_YEAR = 1;
  static final int YEAR_MONTH_DAY = 2;
  static final char SINGLE_QUOTE = '\'';
  static final char DAY_FORMAT_CONSTANT = 'd';
  static final char MONTH_FORMAT_CONSTANT = 'M';
  static final char YEAR_FORMAT_CONSTANT = 'y';
  static final char HOURS_FORMAT_CONSTANT = 'h';
  static final char MINUTES_FORMAT_CONSTANT = 'm';
  static final char SECONDS_FORMAT_CONSTANT = 's';
  static final char AMPM_FORMAT_CONSTANT = 't';
  
  static
  {
    INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX();
    dwSize = INITCOMMONCONTROLSEX.sizeof;
    dwICC = 256;
    OS.InitCommonControlsEx(icex);
    
    WNDCLASS lpWndClass = new WNDCLASS();
    OS.GetClassInfo(0, DateTimeClass, lpWndClass);
    DateTimeProc = lpfnWndProc;
    
    int hInstance = OS.GetModuleHandle(null);
    int hHeap = OS.GetProcessHeap();
    lpWndClass.hInstance = hInstance;
    style &= 0xBFFF;
    style |= 0x8;
    int byteCount = DateTimeClass.length() * TCHAR.sizeof;
    int lpszClassName = OS.HeapAlloc(hHeap, 8, byteCount);
    OS.MoveMemory(lpszClassName, DateTimeClass, byteCount);
    lpWndClass.lpszClassName = lpszClassName;
    OS.RegisterClass(lpWndClass);
    OS.HeapFree(hHeap, 0, lpszClassName);
    
    WNDCLASS lpWndClass = new WNDCLASS();
    OS.GetClassInfo(0, CalendarClass, lpWndClass);
    CalendarProc = lpfnWndProc;
    
    int hInstance = OS.GetModuleHandle(null);
    int hHeap = OS.GetProcessHeap();
    lpWndClass.hInstance = hInstance;
    style &= 0xBFFF;
    style |= 0x8;
    int byteCount = CalendarClass.length() * TCHAR.sizeof;
    int lpszClassName = OS.HeapAlloc(hHeap, 8, byteCount);
    OS.MoveMemory(lpszClassName, CalendarClass, byteCount);
    lpWndClass.lpszClassName = lpszClassName;
    OS.RegisterClass(lpWndClass);
    OS.HeapFree(hHeap, 0, lpszClassName);
  }
  
  static final int[] MONTH_NAMES = { 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67 };
  
  public DateTime(Composite parent, int style)
  {
    super(parent, checkStyle(style));
    if ((this.style & 0x8000) != 0)
    {
      String buffer = (this.style & 0x20) != 0 ? getCustomShortDateFormat() : getCustomShortTimeFormat();
      TCHAR lpszFormat = new TCHAR(0, buffer, true);
      OS.SendMessage(handle, OS.DTM_SETFORMAT, 0, lpszFormat);
    }
  }
  
  public void addSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(13, typedListener);
    addListener(14, typedListener);
  }
  
  int callWindowProc(int hwnd, int msg, int wParam, int lParam)
  {
    if (handle == 0) {
      return 0;
    }
    return OS.CallWindowProc(windowProc(), hwnd, msg, wParam, lParam);
  }
  
  static int checkStyle(int style)
  {
    style &= 0xFCFF;
    style = checkBits(style, 32, 128, 1024, 0, 0, 0);
    style = checkBits(style, 65536, 32768, 268435456, 0, 0, 0);
    if ((style & 0x20) == 0) {
      style &= 0xFFFFFFFB;
    }
    return style;
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  public Point computeSize(int wHint, int hHint, boolean changed)
  {
    checkWidget();
    int width = 0;int height = 0;
    if ((wHint == -1) || (hHint == -1)) {
      if ((style & 0x400) != 0)
      {
        RECT rect = new RECT();
        OS.SendMessage(handle, 4105, 0, rect);
        width = right;
        height = bottom;
      }
      else
      {
        if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0)))
        {
          SIZE size = new SIZE();
          OS.SendMessage(handle, 4111, 0, size);
          width = cx;
          height = cy;
        }
        else
        {
          int oldFont = 0;
          int hDC = OS.GetDC(handle);
          int newFont = OS.SendMessage(handle, 49, 0, 0);
          if (newFont != 0) {
            oldFont = OS.SelectObject(hDC, newFont);
          }
          RECT rect = new RECT();
          if ((style & 0x20) != 0)
          {
            int dwFlags = 0;
            TCHAR lpFormat = null;
            if ((style & 0x8000) != 0) {
              lpFormat = new TCHAR(0, getCustomShortDateFormat(), true);
            } else {
              dwFlags = (style & 0x10000) != 0 ? 1 : 2;
            }
            int size = OS.GetDateFormat(1024, dwFlags, null, lpFormat, null, 0);
            if (size > 0)
            {
              TCHAR buffer = new TCHAR(getCodePage(), size);
              OS.GetDateFormat(1024, dwFlags, null, lpFormat, buffer, buffer.length());
              OS.DrawText(hDC, buffer, size, rect, 9216);
            }
          }
          else if ((style & 0x80) != 0)
          {
            int dwFlags = 0;
            TCHAR lpFormat = null;
            if ((style & 0x8000) != 0)
            {
              dwFlags = 2;
              lpFormat = new TCHAR(0, getCustomShortTimeFormat(), true);
            }
            int size = OS.GetTimeFormat(1024, dwFlags, null, lpFormat, null, 0);
            if (size > 0)
            {
              TCHAR buffer = new TCHAR(getCodePage(), size);
              OS.GetTimeFormat(1024, dwFlags, null, lpFormat, buffer, buffer.length());
              OS.DrawText(hDC, buffer, size, rect, 9216);
            }
          }
          width = right - left;
          height = bottom - top;
          if (newFont != 0) {
            OS.SelectObject(hDC, oldFont);
          }
          OS.ReleaseDC(handle, hDC);
          int upDownWidth = OS.GetSystemMetrics(2);
          width += upDownWidth + 4;
        }
        int upDownHeight = OS.GetSystemMetrics(20);
        if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0))) {
          upDownHeight += 7;
        }
        height = Math.max(height, upDownHeight);
      }
    }
    if (width == 0) {
      width = 64;
    }
    if (height == 0) {
      height = 64;
    }
    if (wHint != -1) {
      width = wHint;
    }
    if (hHint != -1) {
      height = hHint;
    }
    int border = getBorderWidth();
    width += border * 2;
    height += border * 2;
    return new Point(width, height);
  }
  
  void createHandle()
  {
    super.createHandle();
    state &= 0xFEFD;
    if ((style & 0x800) == 0)
    {
      int bits = OS.GetWindowLong(handle, -20);
      bits &= 0xFFFDFDFF;
      OS.SetWindowLong(handle, -20, bits);
    }
  }
  
  int defaultBackground()
  {
    return OS.GetSysColor(OS.COLOR_WINDOW);
  }
  
  String getCustomShortDateFormat()
  {
    TCHAR tchar = new TCHAR(getCodePage(), 80);
    int size = OS.GetLocaleInfo(1024, 4102, tchar, 80);
    return size != 0 ? tchar.toString(0, size - 1) : "M/yyyy";
  }
  
  String getCustomShortTimeFormat()
  {
    StringBuffer buffer = new StringBuffer(getTimeFormat());
    int length = buffer.length();
    boolean inQuotes = false;
    int start = 0;int end = 0;
    while (start < length)
    {
      char ch = buffer.charAt(start);
      if (ch == '\'')
      {
        inQuotes = !inQuotes;
      }
      else if ((ch == 's') && (!inQuotes))
      {
        end = start + 1;
        do
        {
          end++;
          if (end >= length) {
            break;
          }
        } while (buffer.charAt(end) == 's');
        while ((start > 0) && (buffer.charAt(start) != 'm')) {
          start--;
        }
        start++;
        break;
      }
      start++;
    }
    if (start < end) {
      buffer.delete(start, end);
    }
    return buffer.toString();
  }
  
  String getTimeFormat()
  {
    TCHAR tchar = new TCHAR(getCodePage(), 80);
    int size = OS.GetLocaleInfo(1024, 4099, tchar, 80);
    return size > 0 ? tchar.toString(0, size - 1) : "h:mm:ss tt";
  }
  
  public int getDay()
  {
    checkWidget();
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wDay;
  }
  
  public int getHours()
  {
    checkWidget();
    if ((style & 0x400) != 0) {
      return time.wHour;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wHour;
  }
  
  public int getMinutes()
  {
    checkWidget();
    if ((style & 0x400) != 0) {
      return time.wMinute;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wMinute;
  }
  
  public int getMonth()
  {
    checkWidget();
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wMonth - 1;
  }
  
  String getNameText()
  {
    return 
      getMonth() + 1 + "/" + getDay() + "/" + getYear();
  }
  
  public int getSeconds()
  {
    checkWidget();
    if ((style & 0x400) != 0) {
      return time.wSecond;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wSecond;
  }
  
  public int getYear()
  {
    checkWidget();
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    return wYear;
  }
  
  void releaseWidget()
  {
    super.releaseWidget();
    lastSystemTime = null;
  }
  
  public void removeSelectionListener(SelectionListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(13, listener);
    eventTable.unhook(14, listener);
  }
  
  public void setDate(int year, int month, int day)
  {
    checkWidget();
    if ((year < 1752) || (year > 9999)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wYear = ((short)year);
    wMonth = ((short)(month + 1));
    wDay = ((short)day);
    OS.SendMessage(handle, msg, 0, systime);
    lastSystemTime = null;
  }
  
  public void setDay(int day)
  {
    checkWidget();
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wDay = ((short)day);
    OS.SendMessage(handle, msg, 0, systime);
    lastSystemTime = null;
  }
  
  public void setHours(int hours)
  {
    checkWidget();
    if ((hours < 0) || (hours > 23)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wHour = ((short)hours);
    OS.SendMessage(handle, msg, 0, systime);
    if (((style & 0x400) != 0) && (hours >= 0) && (hours <= 23)) {
      time.wHour = ((short)hours);
    }
  }
  
  public void setMinutes(int minutes)
  {
    checkWidget();
    if ((minutes < 0) || (minutes > 59)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wMinute = ((short)minutes);
    OS.SendMessage(handle, msg, 0, systime);
    if (((style & 0x400) != 0) && (minutes >= 0) && (minutes <= 59)) {
      time.wMinute = ((short)minutes);
    }
  }
  
  public void setMonth(int month)
  {
    checkWidget();
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wMonth = ((short)(month + 1));
    OS.SendMessage(handle, msg, 0, systime);
    lastSystemTime = null;
  }
  
  public void setOrientation(int orientation)
  {
    if ((style & 0x400) != 0) {
      super.setOrientation(orientation);
    }
  }
  
  public void setSeconds(int seconds)
  {
    checkWidget();
    if ((seconds < 0) || (seconds > 59)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wSecond = ((short)seconds);
    OS.SendMessage(handle, msg, 0, systime);
    if (((style & 0x400) != 0) && (seconds >= 0) && (seconds <= 59)) {
      time.wSecond = ((short)seconds);
    }
  }
  
  public void setTime(int hours, int minutes, int seconds)
  {
    checkWidget();
    if ((hours < 0) || (hours > 23) || (minutes < 0) || (minutes > 59) || (seconds < 0) || (seconds > 59)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wHour = ((short)hours);
    wMinute = ((short)minutes);
    wSecond = ((short)seconds);
    OS.SendMessage(handle, msg, 0, systime);
    if (((style & 0x400) != 0) && 
      (hours >= 0) && (hours <= 23) && 
      (minutes >= 0) && (minutes <= 59) && 
      (seconds >= 0) && (seconds <= 59))
    {
      time.wHour = ((short)hours);
      time.wMinute = ((short)minutes);
      time.wSecond = ((short)seconds);
    }
  }
  
  public void setYear(int year)
  {
    checkWidget();
    if ((year < 1752) || (year > 9999)) {
      return;
    }
    SYSTEMTIME systime = new SYSTEMTIME();
    int msg = (style & 0x400) != 0 ? 4097 : 4097;
    OS.SendMessage(handle, msg, 0, systime);
    msg = (style & 0x400) != 0 ? 4098 : 4098;
    wYear = ((short)year);
    OS.SendMessage(handle, msg, 0, systime);
    lastSystemTime = null;
  }
  
  int widgetStyle()
  {
    int bits = super.widgetStyle() | 0x10000;
    if ((style & 0x400) != 0) {
      return bits | 0x10;
    }
    bits &= 0xFDFFFFFF;
    if ((style & 0x80) != 0) {
      bits |= 0x9;
    }
    if ((style & 0x20) != 0)
    {
      bits |= ((style & 0x10000) != 0 ? 12 : 4);
      if ((style & 0x4) == 0) {
        bits |= 0x1;
      }
    }
    return bits;
  }
  
  TCHAR windowClass()
  {
    return (style & 0x400) != 0 ? CalendarClass : DateTimeClass;
  }
  
  int windowProc()
  {
    return (style & 0x400) != 0 ? CalendarProc : DateTimeProc;
  }
  
  LRESULT wmNotifyChild(NMHDR hdr, int wParam, int lParam)
  {
    switch (code)
    {
    case -753: 
      display.captureChanged = true;
      break;
    case -749: 
      if (!ignoreSelection)
      {
        SYSTEMTIME systime = new SYSTEMTIME();
        OS.SendMessage(handle, 4097, 0, systime);
        sendSelectionEvent(13);
      }
      break;
    case -759: 
      SYSTEMTIME systime = new SYSTEMTIME();
      OS.SendMessage(handle, 4097, 0, systime);
      if ((lastSystemTime == null) || (wDay != lastSystemTime.wDay) || (wMonth != lastSystemTime.wMonth) || (wYear != lastSystemTime.wYear))
      {
        sendSelectionEvent(13);
        if ((style & 0x80) == 0) {
          lastSystemTime = systime;
        }
      }
      break;
    }
    return super.wmNotifyChild(hdr, wParam, lParam);
  }
  
  LRESULT WM_CHAR(int wParam, int lParam)
  {
    LRESULT result = super.WM_CHAR(wParam, lParam);
    if (result != null) {
      return result;
    }
    switch (wParam)
    {
    case 13: 
      sendSelectionEvent(14);
    case 9: 
    case 27: 
      return LRESULT.ZERO;
    }
    return result;
  }
  
  LRESULT WM_LBUTTONDBLCLK(int wParam, int lParam)
  {
    LRESULT result = super.WM_LBUTTONDBLCLK(wParam, lParam);
    if (isDisposed()) {
      return LRESULT.ZERO;
    }
    if ((style & 0x400) != 0)
    {
      MCHITTESTINFO pMCHitTest = new MCHITTESTINFO();
      cbSize = MCHITTESTINFO.sizeof;
      POINT pt = new POINT();
      x = OS.GET_X_LPARAM(lParam);
      y = OS.GET_Y_LPARAM(lParam);
      pt = pt;
      int code = OS.SendMessage(handle, 4110, 0, pMCHitTest);
      if ((code & 0x20001) == 131073) {
        doubleClick = true;
      }
    }
    return result;
  }
  
  LRESULT WM_LBUTTONDOWN(int wParam, int lParam)
  {
    LRESULT result = super.WM_LBUTTONDOWN(wParam, lParam);
    if (result == LRESULT.ZERO) {
      return result;
    }
    doubleClick = false;
    if (((style & 0x400) != 0) && 
      ((style & 0x80000) == 0)) {
      OS.SetFocus(handle);
    }
    return result;
  }
  
  LRESULT WM_LBUTTONUP(int wParam, int lParam)
  {
    LRESULT result = super.WM_LBUTTONUP(wParam, lParam);
    if (isDisposed()) {
      return LRESULT.ZERO;
    }
    if (doubleClick) {
      sendSelectionEvent(14);
    }
    doubleClick = false;
    return result;
  }
  
  LRESULT WM_TIMER(int wParam, int lParam)
  {
    LRESULT result = super.WM_TIMER(wParam, lParam);
    if (result != null) {
      return result;
    }
    ignoreSelection = true;
    int code = callWindowProc(handle, 275, wParam, lParam);
    ignoreSelection = false;
    return code == 0 ? LRESULT.ZERO : new LRESULT(code);
  }
}

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

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.ACCEL;
import org.eclipse.swt.internal.win32.CREATESTRUCT;
import org.eclipse.swt.internal.win32.LRESULT;
import org.eclipse.swt.internal.win32.MENUITEMINFO;
import org.eclipse.swt.internal.win32.MSG;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.STARTUPINFO;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.internal.win32.WINDOWPLACEMENT;
import org.eclipse.swt.internal.win32.WINDOWPOS;

public class Decorations
  extends Canvas
{
  int oldX = Integer.MIN_VALUE;
  int oldY = Integer.MIN_VALUE;
  int oldWidth = Integer.MIN_VALUE;
  int oldHeight = Integer.MIN_VALUE;
  Image image;
  Image smallImage;
  Image largeImage;
  Image[] images;
  Menu menuBar;
  Menu[] menus;
  Control savedFocus;
  Button defaultButton;
  Button saveDefault;
  int swFlags;
  int nAccel;
  int hAccel;
  boolean moved;
  boolean resized;
  boolean opened;
  
  Decorations() {}
  
  public Decorations(Composite parent, int style)
  {
    super(parent, checkStyle(style));
  }
  
  void _setMaximized(boolean maximized)
  {
    swFlags = (maximized ? OS.SW_SHOWMAXIMIZED : OS.SW_RESTORE);
    if (OS.IsWinCE)
    {
      if (maximized)
      {
        RECT rect = new RECT();
        OS.SystemParametersInfo(48, 0, rect, 0);
        int width = right - left;int height = bottom - top;
        if (OS.IsPPC) {
          if (menuBar != null)
          {
            int hwndCB = menuBar.hwndCB;
            RECT rectCB = new RECT();
            OS.GetWindowRect(hwndCB, rectCB);
            height -= bottom - top;
          }
        }
        int flags = 52;
        SetWindowPos(handle, 0, left, top, width, height, flags);
      }
    }
    else
    {
      if (!OS.IsWindowVisible(handle)) {
        return;
      }
      if (maximized == OS.IsZoomed(handle)) {
        return;
      }
      OS.ShowWindow(handle, swFlags);
      OS.UpdateWindow(handle);
    }
  }
  
  void _setMinimized(boolean minimized)
  {
    if (OS.IsWinCE) {
      return;
    }
    swFlags = (minimized ? 7 : OS.SW_RESTORE);
    if (!OS.IsWindowVisible(handle)) {
      return;
    }
    if (minimized == OS.IsIconic(handle)) {
      return;
    }
    int flags = swFlags;
    if ((flags == 7) && (handle == OS.GetActiveWindow())) {
      flags = 6;
    }
    OS.ShowWindow(handle, flags);
    OS.UpdateWindow(handle);
  }
  
  void addMenu(Menu menu)
  {
    if (menus == null) {
      menus = new Menu[4];
    }
    for (int i = 0; i < menus.length; i++) {
      if (menus[i] == null)
      {
        menus[i] = menu;
        return;
      }
    }
    Menu[] newMenus = new Menu[menus.length + 4];
    newMenus[menus.length] = menu;
    System.arraycopy(menus, 0, newMenus, 0, menus.length);
    menus = newMenus;
  }
  
  void bringToTop()
  {
    OS.BringWindowToTop(handle);
  }
  
  static int checkStyle(int style)
  {
    if ((style & 0x8) != 0) {
      style &= 0xF30F;
    }
    if (OS.IsWinCE)
    {
      if ((style & 0x80) != 0) {
        style &= 0xFF7F;
      }
      if ((style & 0x400) != 0) {
        style &= 0xFBFF;
      }
      return style;
    }
    if ((style & 0x4C0) != 0) {
      style |= 0x20;
    }
    if ((style & 0x480) != 0) {
      style |= 0x40;
    }
    if ((style & 0x40) != 0) {
      style |= 0x20;
    }
    return style;
  }
  
  void checkBorder() {}
  
  void checkComposited(Composite parent) {}
  
  void checkOpened()
  {
    if (!opened) {
      resized = false;
    }
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  int callWindowProc(int hwnd, int msg, int wParam, int lParam)
  {
    if (handle == 0) {
      return 0;
    }
    return OS.DefMDIChildProc(hwnd, msg, wParam, lParam);
  }
  
  void closeWidget()
  {
    Event event = new Event();
    sendEvent(21, event);
    if ((doit) && (!isDisposed())) {
      dispose();
    }
  }
  
  int compare(ImageData data1, ImageData data2, int width, int height, int depth)
  {
    int value1 = Math.abs(width - width);int value2 = Math.abs(width - width);
    if (value1 == value2)
    {
      int transparent1 = data1.getTransparencyType();
      int transparent2 = data2.getTransparencyType();
      if (transparent1 == transparent2)
      {
        if (depth == depth) {
          return 0;
        }
        return (depth > depth) && (depth <= depth) ? -1 : 1;
      }
      if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(5, 1)))
      {
        if (transparent1 == 1) {
          return -1;
        }
        if (transparent2 == 1) {
          return 1;
        }
      }
      if (transparent1 == 2) {
        return -1;
      }
      if (transparent2 == 2) {
        return 1;
      }
      if (transparent1 == 4) {
        return -1;
      }
      if (transparent2 == 4) {
        return 1;
      }
      return 0;
    }
    return value1 < value2 ? -1 : 1;
  }
  
  Widget computeTabGroup()
  {
    return this;
  }
  
  Control computeTabRoot()
  {
    return this;
  }
  
  public Rectangle computeTrim(int x, int y, int width, int height)
  {
    checkWidget();
    
    RECT rect = new RECT();
    OS.SetRect(rect, x, y, x + width, y + height);
    int bits1 = OS.GetWindowLong(handle, -16);
    int bits2 = OS.GetWindowLong(handle, -20);
    boolean hasMenu = !OS.IsWinCE;
    OS.AdjustWindowRectEx(rect, bits1, hasMenu, bits2);
    if (horizontalBar != null) {
      bottom += OS.GetSystemMetrics(3);
    }
    if (verticalBar != null) {
      right += OS.GetSystemMetrics(2);
    }
    if (hasMenu)
    {
      RECT testRect = new RECT();
      OS.SetRect(testRect, 0, 0, right - left, bottom - top);
      OS.SendMessage(handle, 131, 0, testRect);
      while (bottom - top < height)
      {
        if (bottom - top == 0) {
          break;
        }
        top -= OS.GetSystemMetrics(15) - OS.GetSystemMetrics(6);
        OS.SetRect(testRect, 0, 0, right - left, bottom - top);
        OS.SendMessage(handle, 131, 0, testRect);
      }
    }
    return new Rectangle(left, top, right - left, bottom - top);
  }
  
  void createAccelerators()
  {
    hAccel = (nAccel = 0);
    int maxAccel = 0;
    MenuItem[] items = display.items;
    if ((menuBar == null) || (items == null))
    {
      if (!OS.IsPPC) {
        return;
      }
      maxAccel = 1;
    }
    else
    {
      maxAccel = OS.IsPPC ? items.length + 1 : items.length;
    }
    ACCEL accel = new ACCEL();
    byte[] buffer1 = new byte[ACCEL.sizeof];
    byte[] buffer2 = new byte[maxAccel * ACCEL.sizeof];
    if ((menuBar != null) && (items != null)) {
      for (int i = 0; i < items.length; i++)
      {
        MenuItem item = items[i];
        if ((item != null) && (accelerator != 0))
        {
          Menu menu = parent;
          if (parent == this)
          {
            while ((menu != null) && (menu != menuBar)) {
              menu = menu.getParentMenu();
            }
            if ((menu == menuBar) && (item.fillAccel(accel)))
            {
              OS.MoveMemory(buffer1, accel, ACCEL.sizeof);
              System.arraycopy(buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof);
              nAccel += 1;
            }
          }
        }
      }
    }
    if (OS.IsPPC)
    {
      fVirt = 9;
      key = 81;
      cmd = 1;
      OS.MoveMemory(buffer1, accel, ACCEL.sizeof);
      System.arraycopy(buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof);
      nAccel += 1;
    }
    if (nAccel != 0) {
      hAccel = OS.CreateAcceleratorTable(buffer2, nAccel);
    }
  }
  
  void createHandle()
  {
    super.createHandle();
    if ((parent != null) || ((style & 0x4) != 0))
    {
      setParent();
      setSystemMenu();
    }
  }
  
  void createWidget()
  {
    super.createWidget();
    swFlags = (OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : 4);
    hAccel = -1;
  }
  
  void destroyAccelerators()
  {
    if ((hAccel != 0) && (hAccel != -1)) {
      OS.DestroyAcceleratorTable(hAccel);
    }
    hAccel = -1;
  }
  
  public void dispose()
  {
    if (isDisposed()) {
      return;
    }
    if (!isValidThread()) {
      error(22);
    }
    if (!(this instanceof Shell))
    {
      if (!traverseDecorations(true))
      {
        Shell shell = getShell();
        shell.setFocus();
      }
      setVisible(false);
    }
    super.dispose();
  }
  
  Menu findMenu(int hMenu)
  {
    if (menus 
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