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

mposite parent;
  Cursor cursor;
  Menu menu;
  String toolTipText;
  Object layoutData;
  Accessible accessible;
  Image backgroundImage;
  Region region;
  Font font;
  int drawCount;
  int foreground;
  int background;
  
  Control() {}
  
  public Control(Composite parent, int style)
  {
    super(parent, style);
    this.parent = parent;
    createWidget();
  }
  
  public void addControlListener(ControlListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(11, typedListener);
    addListener(10, typedListener);
  }
  
  public void addDragDetectListener(DragDetectListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(29, typedListener);
  }
  
  public void addFocusListener(FocusListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(15, typedListener);
    addListener(16, typedListener);
  }
  
  public void addGestureListener(GestureListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(48, typedListener);
  }
  
  public void addHelpListener(HelpListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(28, typedListener);
  }
  
  public void addKeyListener(KeyListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(2, typedListener);
    addListener(1, typedListener);
  }
  
  public void addMenuDetectListener(MenuDetectListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(35, typedListener);
  }
  
  public void addMouseListener(MouseListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(3, typedListener);
    addListener(4, typedListener);
    addListener(8, typedListener);
  }
  
  public void addMouseTrackListener(MouseTrackListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(6, typedListener);
    addListener(7, typedListener);
    addListener(32, typedListener);
  }
  
  public void addMouseMoveListener(MouseMoveListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(5, typedListener);
  }
  
  public void addMouseWheelListener(MouseWheelListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(37, typedListener);
  }
  
  public void addPaintListener(PaintListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(9, typedListener);
  }
  
  public void addTouchListener(TouchListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(47, typedListener);
  }
  
  public void addTraverseListener(TraverseListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    TypedListener typedListener = new TypedListener(listener);
    addListener(31, typedListener);
  }
  
  int binarySearch(int[] indices, int start, int end, int index)
  {
    int low = start;int high = end - 1;
    while (low <= high)
    {
      int mid = low + high >>> 1;
      if (indices[mid] == index) {
        return mid;
      }
      if (indices[mid] < index) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    return -low - 1;
  }
  
  int borderHandle()
  {
    return handle;
  }
  
  void checkBackground()
  {
    Shell shell = getShell();
    if (this == shell) {
      return;
    }
    state &= 0xFBFF;
    Composite composite = parent;
    for (;;)
    {
      int mode = backgroundMode;
      if (mode != 0)
      {
        if (mode == 1)
        {
          Control control = this;
          do
          {
            if ((state & 0x100) == 0) {
              return;
            }
            control = parent;
          } while (control != composite);
        }
        state |= 0x400;
        return;
      }
      if (composite == shell) {
        break;
      }
      composite = parent;
    }
  }
  
  void checkBorder()
  {
    if (getBorderWidth() == 0) {
      style &= 0xF7FF;
    }
  }
  
  void checkBuffered()
  {
    style &= 0xDFFFFFFF;
  }
  
  void checkComposited() {}
  
  boolean checkHandle(int hwnd)
  {
    return hwnd == handle;
  }
  
  void checkMirrored()
  {
    if ((style & 0x4000000) != 0)
    {
      int bits = OS.GetWindowLong(handle, -20);
      if ((bits & 0x400000) != 0) {
        style |= 0x8000000;
      }
    }
  }
  
  public Point computeSize(int wHint, int hHint)
  {
    return computeSize(wHint, hHint, true);
  }
  
  public Point computeSize(int wHint, int hHint, boolean changed)
  {
    checkWidget();
    int width = 64;
    int 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);
  }
  
  Widget computeTabGroup()
  {
    if (isTabGroup()) {
      return this;
    }
    return parent.computeTabGroup();
  }
  
  Control computeTabRoot()
  {
    Control[] tabList = parent._getTabList();
    if (tabList != null)
    {
      int index = 0;
      while (index < tabList.length)
      {
        if (tabList[index] == this) {
          break;
        }
        index++;
      }
      if ((index == tabList.length) && 
        (isTabGroup())) {
        return this;
      }
    }
    return parent.computeTabRoot();
  }
  
  Widget[] computeTabList()
  {
    if ((isTabGroup()) && 
      (getVisible()) && (getEnabled())) {
      return new Widget[] { this };
    }
    return new Widget[0];
  }
  
  void createHandle()
  {
    int hwndParent = widgetParent();
    handle = OS.CreateWindowEx(
      widgetExtStyle(), 
      windowClass(), 
      null, 
      widgetStyle(), 
      Integer.MIN_VALUE, 0, Integer.MIN_VALUE, 0, 
      hwndParent, 
      0, 
      OS.GetModuleHandle(null), 
      widgetCreateStruct());
    if (handle == 0) {
      error(2);
    }
    int bits = OS.GetWindowLong(handle, -16);
    if ((bits & 0x40000000) != 0) {
      OS.SetWindowLongPtr(handle, -12, handle);
    }
    if ((OS.IsDBLocale) && (hwndParent != 0))
    {
      int hIMC = OS.ImmGetContext(hwndParent);
      OS.ImmAssociateContext(handle, hIMC);
      OS.ImmReleaseContext(hwndParent, hIMC);
    }
  }
  
  void checkGesture()
  {
    if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 1)))
    {
      int value = OS.GetSystemMetrics(94);
      if ((value & 0xC0) != 0)
      {
        int hHeap = OS.GetProcessHeap();
        int pConfigs = OS.HeapAlloc(hHeap, 8, GESTURECONFIG.sizeof);
        if (pConfigs != 0)
        {
          GESTURECONFIG config = new GESTURECONFIG();
          dwID = 5;
          dwWant = 1;
          dwBlock = 0;
          OS.MoveMemory(pConfigs, config, GESTURECONFIG.sizeof);
          OS.SetGestureConfig(handle, 0, 1, pConfigs, GESTURECONFIG.sizeof);
          OS.HeapFree(hHeap, 0, pConfigs);
        }
      }
    }
  }
  
  void createWidget()
  {
    state |= 0x8000;
    foreground = (background = -1);
    checkOrientation(parent);
    createHandle();
    checkBackground();
    checkBuffered();
    checkComposited();
    register();
    subclass();
    setDefaultFont();
    checkMirrored();
    checkBorder();
    checkGesture();
    if ((state & 0x400) != 0) {
      setBackground();
    }
  }
  
  int defaultBackground()
  {
    if (OS.IsWinCE) {
      return OS.GetSysColor(OS.COLOR_WINDOW);
    }
    return OS.GetSysColor(OS.COLOR_BTNFACE);
  }
  
  int defaultFont()
  {
    return display.getSystemFont().handle;
  }
  
  int defaultForeground()
  {
    return OS.GetSysColor(OS.COLOR_WINDOWTEXT);
  }
  
  void deregister()
  {
    display.removeControl(handle);
  }
  
  void destroyWidget()
  {
    int hwnd = topHandle();
    releaseHandle();
    if (hwnd != 0) {
      OS.DestroyWindow(hwnd);
    }
  }
  
  public boolean dragDetect(Event event)
  {
    checkWidget();
    if (event == null) {
      error(4);
    }
    return dragDetect(button, count, stateMask, x, y);
  }
  
  public boolean dragDetect(MouseEvent event)
  {
    checkWidget();
    if (event == null) {
      error(4);
    }
    return dragDetect(button, count, stateMask, x, y);
  }
  
  boolean dragDetect(int button, int count, int stateMask, int x, int y)
  {
    if ((button != 1) || (count != 1)) {
      return false;
    }
    boolean dragging = dragDetect(handle, x, y, false, null, null);
    if ((OS.GetKeyState(1) < 0) && 
      (OS.GetCapture() != handle)) {
      OS.SetCapture(handle);
    }
    if (!dragging)
    {
      if ((button == 1) && (OS.GetKeyState(27) >= 0))
      {
        int wParam = 0;
        if ((stateMask & 0x40000) != 0) {
          wParam |= 0x8;
        }
        if ((stateMask & 0x20000) != 0) {
          wParam |= 0x4;
        }
        if ((stateMask & 0x10000) != 0) {
          wParam |= 0x20;
        }
        if ((stateMask & 0x80000) != 0) {
          wParam |= 0x1;
        }
        if ((stateMask & 0x100000) != 0) {
          wParam |= 0x10;
        }
        if ((stateMask & 0x200000) != 0) {
          wParam |= 0x2;
        }
        if ((stateMask & 0x800000) != 0) {
          wParam |= 0x20;
        }
        if ((stateMask & 0x2000000) != 0) {
          wParam |= 0x40;
        }
        int lParam = OS.MAKELPARAM(x, y);
        OS.SendMessage(handle, 514, wParam, lParam);
      }
      return false;
    }
    return sendDragEvent(button, stateMask, x, y);
  }
  
  void drawBackground(int hDC)
  {
    RECT rect = new RECT();
    OS.GetClientRect(handle, rect);
    drawBackground(hDC, rect);
  }
  
  void drawBackground(int hDC, RECT rect)
  {
    drawBackground(hDC, rect, -1, 0, 0);
  }
  
  void drawBackground(int hDC, RECT rect, int pixel, int tx, int ty)
  {
    Control control = findBackgroundControl();
    if (control != null)
    {
      if (backgroundImage != null)
      {
        fillImageBackground(hDC, control, rect, tx, ty);
        return;
      }
      pixel = control.getBackgroundPixel();
    }
    if ((pixel == -1) && 
      ((state & 0x100) != 0) && 
      (OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()))
    {
      control = findThemeControl();
      if (control != null)
      {
        fillThemeBackground(hDC, control, rect);
        return;
      }
    }
    if (pixel == -1) {
      pixel = getBackgroundPixel();
    }
    fillBackground(hDC, pixel, rect);
  }
  
  void drawImageBackground(int hDC, int hwnd, int hBitmap, RECT rect, int tx, int ty)
  {
    RECT rect2 = new RECT();
    OS.GetClientRect(hwnd, rect2);
    OS.MapWindowPoints(hwnd, handle, rect2, 2);
    int hBrush = findBrush(hBitmap, 3);
    POINT lpPoint = new POINT();
    OS.GetWindowOrgEx(hDC, lpPoint);
    OS.SetBrushOrgEx(hDC, -left - x - tx, -top - y - ty, lpPoint);
    int hOldBrush = OS.SelectObject(hDC, hBrush);
    OS.PatBlt(hDC, left, top, right - left, bottom - top, 15728673);
    OS.SetBrushOrgEx(hDC, x, y, null);
    OS.SelectObject(hDC, hOldBrush);
  }
  
  void drawThemeBackground(int hDC, int hwnd, RECT rect) {}
  
  void enableDrag(boolean enabled) {}
  
  void enableWidget(boolean enabled)
  {
    OS.EnableWindow(handle, enabled);
  }
  
  void fillBackground(int hDC, int pixel, RECT rect)
  {
    if ((left > right) || (top > bottom)) {
      return;
    }
    int hPalette = display.hPalette;
    if (hPalette != 0)
    {
      OS.SelectPalette(hDC, hPalette, false);
      OS.RealizePalette(hDC);
    }
    OS.FillRect(hDC, rect, findBrush(pixel, 0));
  }
  
  void fillImageBackground(int hDC, Control control, RECT rect, int tx, int ty)
  {
    if ((left > right) || (top > bottom)) {
      return;
    }
    if (control != null)
    {
      Image image = backgroundImage;
      if (image != null) {
        control.drawImageBackground(hDC, handle, handle, rect, tx, ty);
      }
    }
  }
  
  void fillThemeBackground(int hDC, Control control, RECT rect)
  {
    if ((left > right) || (top > bottom)) {
      return;
    }
    if (control != null) {
      control.drawThemeBackground(hDC, handle, rect);
    }
  }
  
  Control findBackgroundControl()
  {
    if ((background != -1) || (backgroundImage != null)) {
      return this;
    }
    return (state & 0x400) != 0 ? parent.findBackgroundControl() : null;
  }
  
  int findBrush(int value, int lbStyle)
  {
    return parent.findBrush(value, lbStyle);
  }
  
  Cursor findCursor()
  {
    if (cursor != null) {
      return cursor;
    }
    return parent.findCursor();
  }
  
  Control findImageControl()
  {
    Control control = findBackgroundControl();
    return (control != null) && (backgroundImage != null) ? control : null;
  }
  
  Control findThemeControl()
  {
    return (background == -1) && (backgroundImage == null) ? parent.findThemeControl() : null;
  }
  
  Menu[] findMenus(Control control)
  {
    if ((menu != null) && (this != control)) {
      return new Menu[] { menu };
    }
    return new Menu[0];
  }
  
  char findMnemonic(String string)
  {
    int index = 0;
    int length = string.length();
    do
    {
      while ((index < length) && (string.charAt(index) != '&')) {
        index++;
      }
      index++;
      if (index >= length) {
        return '\000';
      }
      if (string.charAt(index) != '&') {
        return string.charAt(index);
      }
      index++;
    } while (index < length);
    return '\000';
  }
  
  void fixChildren(Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu[] menus)
  {
    oldShell.fixShell(newShell, this);
    oldDecorations.fixDecorations(newDecorations, this, menus);
  }
  
  void fixFocus(Control focusControl)
  {
    Shell shell = getShell();
    Control control = this;
    Display display = this.display;
    boolean oldFixFocus = fixFocus;
    fixFocus = true;
    try
    {
      do
      {
        if (control.setFocus()) {
          return;
        }
        if (control == shell) {
          break;
        }
      } while ((control = parent) != null);
    }
    finally
    {
      fixFocus = oldFixFocus;
    }
    fixFocus = oldFixFocus;
    
    shell.setSavedFocus(focusControl);
    OS.SetFocus(0);
  }
  
  public boolean forceFocus()
  {
    checkWidget();
    if (display.focusEvent == 16) {
      return false;
    }
    Decorations shell = menuShell();
    shell.setSavedFocus(this);
    if ((!isEnabled()) || (!isVisible()) || (!isActive())) {
      return false;
    }
    if (isFocusControl()) {
      return true;
    }
    shell.setSavedFocus(null);
    
    OS.SetFocus(handle);
    if (isDisposed()) {
      return false;
    }
    shell.setSavedFocus(this);
    return isFocusControl();
  }
  
  void forceResize()
  {
    if (parent == null) {
      return;
    }
    WINDOWPOS[] lpwp = parent.lpwp;
    if (lpwp == null) {
      return;
    }
    for (int i = 0; i < lpwp.length; i++)
    {
      WINDOWPOS wp = lpwp[i];
      if ((wp != null) && (hwnd == handle))
      {
        SetWindowPos(hwnd, 0, x, y, cx, cy, flags);
        lpwp[i] = null;
        return;
      }
    }
  }
  
  public Accessible getAccessible()
  {
    checkWidget();
    if (accessible == null) {
      accessible = new_Accessible(this);
    }
    return accessible;
  }
  
  public Color getBackground()
  {
    checkWidget();
    Control control = findBackgroundControl();
    if (control == null) {
      control = this;
    }
    return Color.win32_new(display, control.getBackgroundPixel());
  }
  
  public Image getBackgroundImage()
  {
    checkWidget();
    Control control = findBackgroundControl();
    if (control == null) {
      control = this;
    }
    return backgroundImage;
  }
  
  int getBackgroundPixel()
  {
    return background != -1 ? background : defaultBackground();
  }
  
  public int getBorderWidth()
  {
    checkWidget();
    int borderHandle = borderHandle();
    int bits1 = OS.GetWindowLong(borderHandle, -20);
    if ((bits1 & 0x200) != 0) {
      return OS.GetSystemMetrics(45);
    }
    if ((bits1 & 0x20000) != 0) {
      return OS.GetSystemMetrics(5);
    }
    int bits2 = OS.GetWindowLong(borderHandle, -16);
    if ((bits2 & 0x800000) != 0) {
      return OS.GetSystemMetrics(5);
    }
    return 0;
  }
  
  public Rectangle getBounds()
  {
    checkWidget();
    forceResize();
    RECT rect = new RECT();
    OS.GetWindowRect(topHandle(), rect);
    int hwndParent = parent == null ? 0 : parent.handle;
    OS.MapWindowPoints(0, hwndParent, rect, 2);
    int width = right - left;
    int height = bottom - top;
    return new Rectangle(left, top, width, height);
  }
  
  int getCodePage()
  {
    if (OS.IsUnicode) {
      return 0;
    }
    int hFont = OS.SendMessage(handle, 49, 0, 0);
    LOGFONT logFont = OS.IsUnicode ? new LOGFONTW() : new LOGFONTA();
    OS.GetObject(hFont, LOGFONT.sizeof, logFont);
    int cs = lfCharSet & 0xFF;
    int[] lpCs = new int[8];
    if (OS.TranslateCharsetInfo(cs, lpCs, 1)) {
      return lpCs[1];
    }
    return OS.GetACP();
  }
  
  String getClipboardText()
  {
    String string = "";
    if (OS.OpenClipboard(0))
    {
      int hMem = OS.GetClipboardData(OS.IsUnicode ? 13 : 1);
      if (hMem != 0)
      {
        int byteCount = OS.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
        int ptr = OS.GlobalLock(hMem);
        if (ptr != 0)
        {
          TCHAR buffer = new TCHAR(0, byteCount / TCHAR.sizeof);
          OS.MoveMemory(buffer, ptr, byteCount);
          string = buffer.toString(0, buffer.strlen());
          OS.GlobalUnlock(hMem);
        }
      }
      OS.CloseClipboard();
    }
    return string;
  }
  
  public Cursor getCursor()
  {
    checkWidget();
    return cursor;
  }
  
  public boolean getDragDetect()
  {
    checkWidget();
    return (state & 0x8000) != 0;
  }
  
  boolean getDrawing()
  {
    return drawCount <= 0;
  }
  
  public boolean getEnabled()
  {
    checkWidget();
    return OS.IsWindowEnabled(handle);
  }
  
  public Font getFont()
  {
    checkWidget();
    if (font != null) {
      return font;
    }
    int hFont = OS.SendMessage(handle, 49, 0, 0);
    if (hFont == 0) {
      hFont = defaultFont();
    }
    return Font.win32_new(display, hFont);
  }
  
  public Color getForeground()
  {
    checkWidget();
    return Color.win32_new(display, getForegroundPixel());
  }
  
  int getForegroundPixel()
  {
    return foreground != -1 ? foreground : defaultForeground();
  }
  
  public Object getLayoutData()
  {
    checkWidget();
    return layoutData;
  }
  
  public Point getLocation()
  {
    checkWidget();
    forceResize();
    RECT rect = new RECT();
    OS.GetWindowRect(topHandle(), rect);
    int hwndParent = parent == null ? 0 : parent.handle;
    OS.MapWindowPoints(0, hwndParent, rect, 2);
    return new Point(left, top);
  }
  
  public Menu getMenu()
  {
    checkWidget();
    return menu;
  }
  
  public Monitor getMonitor()
  {
    checkWidget();
    if ((OS.IsWinCE) || (OS.WIN32_VERSION < OS.VERSION(4, 10))) {
      return display.getPrimaryMonitor();
    }
    int hmonitor = OS.MonitorFromWindow(handle, 2);
    MONITORINFO lpmi = new MONITORINFO();
    cbSize = MONITORINFO.sizeof;
    OS.GetMonitorInfo(hmonitor, lpmi);
    Monitor monitor = new Monitor();
    handle = hmonitor;
    x = rcMonitor_left;
    y = rcMonitor_top;
    width = (rcMonitor_right - rcMonitor_left);
    height = (rcMonitor_bottom - rcMonitor_top);
    clientX = rcWork_left;
    clientY = rcWork_top;
    clientWidth = (rcWork_right - rcWork_left);
    clientHeight = (rcWork_bottom - rcWork_top);
    return monitor;
  }
  
  public int getOrientation()
  {
    checkWidget();
    return style & 0x6000000;
  }
  
  public Composite getParent()
  {
    checkWidget();
    return parent;
  }
  
  Control[] getPath()
  {
    int count = 0;
    Shell shell = getShell();
    Control control = this;
    while (control != shell)
    {
      count++;
      control = parent;
    }
    control = this;
    Control[] result = new Control[count];
    while (control != shell)
    {
      result[(--count)] = control;
      control = parent;
    }
    return result;
  }
  
  public Region getRegion()
  {
    checkWidget();
    return region;
  }
  
  public Shell getShell()
  {
    checkWidget();
    return parent.getShell();
  }
  
  public Point getSize()
  {
    checkWidget();
    forceResize();
    RECT rect = new RECT();
    OS.GetWindowRect(topHandle(), rect);
    int width = right - left;
    int height = bottom - top;
    return new Point(width, height);
  }
  
  public String getToolTipText()
  {
    checkWidget();
    return toolTipText;
  }
  
  public boolean getTouchEnabled()
  {
    checkWidget();
    return OS.IsTouchWindow(handle, null);
  }
  
  public boolean getVisible()
  {
    checkWidget();
    if (!getDrawing()) {
      return (state & 0x10) == 0;
    }
    int bits = OS.GetWindowLong(handle, -16);
    return (bits & 0x10000000) != 0;
  }
  
  boolean hasCursor()
  {
    RECT rect = new RECT();
    if (!OS.GetClientRect(handle, rect)) {
      return false;
    }
    OS.MapWindowPoints(handle, 0, rect, 2);
    POINT pt = new POINT();
    return (OS.GetCursorPos(pt)) && (OS.PtInRect(rect, pt));
  }
  
  boolean hasFocus()
  {
    int hwndFocus = OS.GetFocus();
    while (hwndFocus != 0)
    {
      if (hwndFocus == handle) {
        return true;
      }
      if (display.getControl(hwndFocus) != null) {
        return false;
      }
      hwndFocus = OS.GetParent(hwndFocus);
    }
    return false;
  }
  
  public int internal_new_GC(GCData data)
  {
    checkWidget();
    int hwnd = handle;
    if ((data != null) && (hwnd != 0)) {
      hwnd = hwnd;
    }
    if (data != null) {
      hwnd = hwnd;
    }
    int hDC = 0;
    if ((data == null) || (ps == null)) {
      hDC = OS.GetDC(hwnd);
    } else {
      hDC = OS.BeginPaint(hwnd, ps);
    }
    if (hDC == 0) {
      SWT.error(2);
    }
    if (data != null)
    {
      if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(4, 10)))
      {
        int mask = 100663296;
        if ((style & mask) != 0)
        {
          layout = ((style & 0x4000000) != 0 ? 1 : 0);
        }
        else
        {
          int flags = OS.GetLayout(hDC);
          if ((flags & 0x1) != 0) {
            style |= 0xC000000;
          } else {
            style |= 0x2000000;
          }
        }
      }
      else
      {
        style |= 0x2000000;
      }
      device = display;
      int foreground = getForegroundPixel();
      if (foreground != OS.GetTextColor(hDC)) {
        foreground = foreground;
      }
      Control control = findBackgroundControl();
      if (control == null) {
        control = this;
      }
      int background = control.getBackgroundPixel();
      if (background != OS.GetBkColor(hDC)) {
        background = background;
      }
      font = (font != null ? font : Font.win32_new(display, OS.SendMessage(hwnd, 49, 0, 0)));
      uiState = OS.SendMessage(hwnd, 297, 0, 0);
    }
    return hDC;
  }
  
  public void internal_dispose_GC(int hDC, GCData data)
  {
    checkWidget();
    int hwnd = handle;
    if ((data != null) && (hwnd != 0)) {
      hwnd = hwnd;
    }
    if ((data == null) || (ps == null)) {
      OS.ReleaseDC(hwnd, hDC);
    } else {
      OS.EndPaint(hwnd, ps);
    }
  }
  
  boolean isActive()
  {
    Dialog dialog = display.getModalDialog();
    if (dialog != null)
    {
      Shell dialogShell = parent;
      if ((dialogShell != null) && (!dialogShell.isDisposed()) && 
        (dialogShell != getShell())) {
        return false;
      }
    }
    Shell shell = null;
    Shell[] modalShells = display.modalShells;
    if (modalShells != null)
    {
      int bits = 196608;
      int index = modalShells.length;
      do
      {
        Shell modal = modalShells[index];
        if (modal != null)
        {
          if ((style & bits) != 0)
          {
            Control control = this;
            while (control != null)
            {
              if (control == modal) {
                break;
              }
              control = parent;
            }
            if (control == modal) {
              break;
            }
            return false;
          }
          if ((style & 0x8000) != 0)
          {
            if (shell == null) {
              shell = getShell();
            }
            if (parent == shell) {
              return false;
            }
          }
        }
        index--;
      } while (index >= 0);
    }
    if (shell == null) {
      shell = getShell();
    }
    return shell.getEnabled();
  }
  
  public boolean isEnabled()
  {
    checkWidget();
    return (getEnabled()) && (parent.isEnabled());
  }
  
  public boolean isFocusControl()
  {
    checkWidget();
    Control focusControl = display.focusControl;
    if ((focusControl != null) && (!focusControl.isDisposed())) {
      return this == focusControl;
    }
    return hasFocus();
  }
  
  boolean isFocusAncestor(Control control)
  {
    while ((control != null) && (control != this) && (!(control instanceof Shell))) {
      control = parent;
    }
    return control == this;
  }
  
  public boolean isReparentable()
  {
    checkWidget();
    return true;
  }
  
  boolean isShowing()
  {
    if (!isVisible()) {
      return false;
    }
    Control control = this;
    while (control != null)
    {
      Point size = control.getSize();
      if ((x == 0) || (y == 0)) {
        return false;
      }
      control = parent;
    }
    return true;
  }
  
  boolean isTabGroup()
  {
    Control[] tabList = parent._getTabList();
    if (tabList != null) {
      for (int i = 0; i < tabList.length; i++) {
        if (tabList[i] == this) {
          return true;
        }
      }
    }
    int bits = OS.GetWindowLong(handle, -16);
    return (bits & 0x10000) != 0;
  }
  
  boolean isTabItem()
  {
    Control[] tabList = parent._getTabList();
    if (tabList != null) {
      for (int i = 0; i < tabList.length; i++) {
        if (tabList[i] == this) {
          return false;
        }
      }
    }
    int bits = OS.GetWindowLong(handle, -16);
    if ((bits & 0x10000) != 0) {
      return false;
    }
    int code = OS.SendMessage(handle, 135, 0, 0);
    if ((code & 0x100) != 0) {
      return false;
    }
    if ((code & 0x4) != 0) {
      return false;
    }
    if ((code & 0x1) != 0) {
      return false;
    }
    if ((code & 0x2) != 0) {
      return false;
    }
    return true;
  }
  
  public boolean isVisible()
  {
    checkWidget();
    if (OS.IsWindowVisible(handle)) {
      return true;
    }
    return (getVisible()) && (parent.isVisible());
  }
  
  void mapEvent(int hwnd, Event event)
  {
    if (hwnd != handle)
    {
      POINT point = new POINT();
      x = x;
      y = y;
      OS.MapWindowPoints(hwnd, handle, point, 1);
      x = x;
      y = y;
    }
  }
  
  void markLayout(boolean changed, boolean all) {}
  
  Decorations menuShell()
  {
    return parent.menuShell();
  }
  
  boolean mnemonicHit(char key)
  {
    return false;
  }
  
  boolean mnemonicMatch(char key)
  {
    return false;
  }
  
  public void moveAbove(Control control)
  {
    checkWidget();
    int topHandle = topHandle();int hwndAbove = 0;
    if (control != null)
    {
      if (control.isDisposed()) {
        error(5);
      }
      if (parent != parent) {
        return;
      }
      int hwnd = control.topHandle();
      if ((hwnd == 0) || (hwnd == topHandle)) {
        return;
      }
      hwndAbove = OS.GetWindow(hwnd, 3);
      if ((hwndAbove == 0) || (hwndAbove == hwnd)) {
        hwndAbove = 0;
      }
    }
    int flags = 19;
    SetWindowPos(topHandle, hwndAbove, 0, 0, 0, 0, flags);
  }
  
  public void moveBelow(Control control)
  {
    checkWidget();
    int topHandle = topHandle();int hwndAbove = 1;
    if (control != null)
    {
      if (control.isDisposed()) {
        error(5);
      }
      if (parent != parent) {
        return;
      }
      hwndAbove = control.topHandle();
    }
    else
    {
      Shell shell = getShell();
      if ((this == shell) && (parent != null))
      {
        int hwndParent = parent.handle;int hwnd = hwndParent;
        hwndAbove = OS.GetWindow(hwnd, 3);
        while ((hwndAbove != 0) && (hwndAbove != hwnd))
        {
          if (OS.GetWindow(hwndAbove, 4) == hwndParent) {
            break;
          }
          hwndAbove = OS.GetWindow(hwnd = hwndAbove, 3);
        }
        if (hwndAbove == hwnd) {
          return;
        }
      }
    }
    if ((hwndAbove == 0) || (hwndAbove == topHandle)) {
      return;
    }
    int flags = 19;
    SetWindowPos(topHandle, hwndAbove, 0, 0, 0, 0, flags);
  }
  
  Accessible new_Accessible(Control control)
  {
    return Accessible.internal_new_Accessible(this);
  }
  
  GC new_GC(GCData data)
  {
    return GC.win32_new(this, data);
  }
  
  public void pack()
  {
    checkWidget();
    pack(true);
  }
  
  public void pack(boolean changed)
  {
    checkWidget();
    setSize(computeSize(-1, -1, changed));
  }
  
  public boolean print(GC gc)
  {
    checkWidget();
    if (gc == null) {
      error(4);
    }
    if (gc.isDisposed()) {
      error(5);
    }
    if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(5, 1)))
    {
      int topHandle = topHandle();
      int hdc = handle;
      int state = 0;
      int gdipGraphics = getGCDatagdipGraphics;
      if (gdipGraphics != 0)
      {
        int clipRgn = 0;
        Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, 3);
        int rgn = Gdip.Region_new();
        if (rgn == 0) {
          SWT.error(2);
        }
        Gdip.Graphics_GetClip(gdipGraphics, rgn);
        if (!Gdip.Region_IsInfinite(rgn, gdipGraphics)) {
          clipRgn = Gdip.Region_GetHRGN(rgn, gdipGraphics);
        }
        Gdip.Region_delete(rgn);
        Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, 4);
        float[] lpXform = (float[])null;
        int matrix = Gdip.Matrix_new(1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F);
        if (matrix == 0) {
          SWT.error(2);
        }
        Gdip.Graphics_GetTransform(gdipGraphics, matrix);
        if (!Gdip.Matrix_IsIdentity(matrix))
        {
          lpXform = new float[6];
          Gdip.Matrix_GetElements(matrix, lpXform);
        }
        Gdip.Matrix_delete(matrix);
        hdc = Gdip.Graphics_GetHDC(gdipGraphics);
        state = OS.SaveDC(hdc);
        if (lpXform != null)
        {
          OS.SetGraphicsMode(hdc, 2);
          OS.SetWorldTransform(hdc, lpXform);
        }
        if (clipRgn != 0)
        {
          OS.SelectClipRgn(hdc, clipRgn);
          OS.DeleteObject(clipRgn);
        }
      }
      if (OS.IsWinCE)
      {
        OS.UpdateWindow(topHandle);
      }
      else
      {
        int flags = 384;
        OS.RedrawWindow(topHandle, null, 0, flags);
      }
      printWidget(topHandle, hdc, gc);
      if (gdipGraphics != 0)
      {
        OS.RestoreDC(hdc, state);
        Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc);
      }
      return true;
    }
    return false;
  }
  
  void printWidget(int hwnd, int hdc, GC gc)
  {
    boolean success = false;
    if (OS.GetDeviceCaps(handle, 2) != 2)
    {
      int hwndParent = OS.GetParent(hwnd);
      int hwndShell = hwndParent;
      while (OS.GetParent(hwndShell) != 0)
      {
        if (OS.GetWindow(hwndShell, 4) != 0) {
          break;
        }
        hwndShell = OS.GetParent(hwndShell);
      }
      RECT rect1 = new RECT();
      OS.GetWindowRect(hwnd, rect1);
      boolean fixPrintWindow = !OS.IsWindowVisible(hwnd);
      if (!fixPrintWindow)
      {
        RECT rect2 = new RECT();
        OS.GetWindowRect(hwndShell, rect2);
        OS.IntersectRect(rect2, rect1, rect2);
        fixPrintWindow = !OS.EqualRect(rect2, rect1);
      }
      if (!fixPrintWindow)
      {
        int rgn = OS.CreateRectRgn(0, 0, 0, 0);
        int parent = OS.GetParent(hwnd);
        while ((parent != hwndShell) && (!fixPrintWindow))
        {
          if (OS.GetWindowRgn(parent, rgn) != 0) {
            fixPrintWindow = true;
          }
          parent = OS.GetParent(parent);
        }
        OS.DeleteObject(rgn);
      }
      int bits1 = OS.GetWindowLong(hwnd, -16);
      int bits2 = OS.GetWindowLong(hwnd, -20);
      int hwndInsertAfter = OS.GetWindow(hwnd, 3);
      if ((hwndInsertAfter == 0) || (hwndInsertAfter == hwnd)) {
        hwndInsertAfter = 0;
      }
      if (fixPrintWindow)
      {
        int x = OS.GetSystemMetrics(76);
        int y = OS.GetSystemMetrics(77);
        int width = OS.GetSystemMetrics(78);
        int height = OS.GetSystemMetrics(79);
        int flags = 53;
        if ((bits1 & 0x10000000) != 0) {
          OS.DefWindowProc(hwnd, 11, 0, 0);
        }
        SetWindowPos(hwnd, 0, x + width, y + height, 0, 0, flags);
        if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0)))
        {
          OS.SetWindowLong(hwnd, -16, bits1 & 0xBFFFFFFF | 0x80000000);
          OS.SetWindowLong(hwnd, -20, bits2 | 0x80);
        }
        Shell shell = getShell();
        Control savedFocus = savedFocus;
        OS.SetParent(hwnd, 0);
        shell.setSavedFocus(savedFocus);
        if ((bits1 & 0x10000000) != 0) {
          OS.DefWindowProc(hwnd, 11, 1, 0);
        }
      }
      if ((bits1 & 0x10000000) == 0) {
        OS.ShowWindow(hwnd, 5);
      }
      success = OS.PrintWindow(hwnd, hdc, 0);
      if ((bits1 & 0x10000000) == 0) {
        OS.ShowWindow(hwnd, 0);
      }
      if (fixPrintWindow)
      {
        if ((bits1 & 0x10000000) != 0) {
          OS.DefWindowProc(hwnd, 11, 0, 0);
        }
        if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0)))
        {
          OS.SetWindowLong(hwnd, -16, bits1);
          OS.SetWindowLong(hwnd, -20, bits2);
        }
        OS.SetParent(hwnd, hwndParent);
        OS.MapWindowPoints(0, hwndParent, rect1, 2);
        int flags = 49;
        SetWindowPos(hwnd, hwndInsertAfter, left, top, right - left, bottom - top, flags);
        if ((bits1 & 0x10000000) != 0) {
          OS.DefWindowProc(hwnd, 11, 1, 0);
        }
      }
    }
    if (!success)
    {
      int flags = 30;
      OS.SendMessage(hwnd, 791, hdc, flags);
    }
  }
  
  public void redraw()
  {
    checkWidget();
    redraw(false);
  }
  
  void redraw(boolean all)
  {
    if (!OS.IsWindowVisible(handle)) {
      return;
    }
    if (OS.IsWinCE)
    {
      OS.InvalidateRect(handle, null, true);
    }
    else
    {
      int flags = 1029;
      if (all) {
        flags |= 0x80;
      }
      OS.RedrawWindow(handle, null, 0, flags);
    }
  }
  
  public void redraw(int x, int y, int width, int height, boolean all)
  {
    checkWidget();
    if ((width <= 0) || (height <= 0)) {
      return;
    }
    if (!OS.IsWindowVisible(handle)) {
      return;
    }
    RECT rect = new RECT();
    OS.SetRect(rect, x, y, x + width, y + height);
    if (OS.IsWinCE)
    {
      OS.InvalidateRect(handle, rect, true);
    }
    else
    {
      int flags = 1029;
      if (all) {
        flags |= 0x80;
      }
      OS.RedrawWindow(handle, rect, 0, flags);
    }
  }
  
  boolean redrawChildren()
  {
    if (!OS.IsWindowVisible(handle)) {
      return false;
    }
    Control control = findBackgroundControl();
    if (control == null)
    {
      if (((state & 0x100) != 0) && 
        (OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()))
      {
        OS.InvalidateRect(handle, null, true);
        return true;
      }
    }
    else if (backgroundImage != null)
    {
      OS.InvalidateRect(handle, null, true);
      return true;
    }
    return false;
  }
  
  void register()
  {
    display.addControl(handle, this);
  }
  
  void releaseHandle()
  {
    super.releaseHandle();
    handle = 0;
    parent = null;
  }
  
  void releaseParent()
  {
    parent.removeControl(this);
  }
  
  void releaseWidget()
  {
    super.releaseWidget();
    if (OS.IsDBLocale) {
      OS.ImmAssociateContext(handle, 0);
    }
    if (toolTipText != null) {
      setToolTipText(getShell(), null);
    }
    toolTipText = null;
    if ((menu != null) && (!menu.isDisposed())) {
      menu.dispose();
    }
    backgroundImage = null;
    menu = null;
    cursor = null;
    unsubclass();
    deregister();
    layoutData = null;
    if (accessible != null) {
      accessible.internal_dispose_Accessible();
    }
    accessible = null;
    region = null;
    font = null;
  }
  
  public void removeControlListener(ControlListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(10, listener);
    eventTable.unhook(11, listener);
  }
  
  public void removeDragDetectListener(DragDetectListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(29, listener);
  }
  
  public void removeFocusListener(FocusListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(15, listener);
    eventTable.unhook(16, listener);
  }
  
  public void removeGestureListener(GestureListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(48, listener);
  }
  
  public void removeHelpListener(HelpListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(28, listener);
  }
  
  public void removeKeyListener(KeyListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(2, listener);
    eventTable.unhook(1, listener);
  }
  
  public void removeMenuDetectListener(MenuDetectListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(35, listener);
  }
  
  public void removeMouseTrackListener(MouseTrackListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(6, listener);
    eventTable.unhook(7, listener);
    eventTable.unhook(32, listener);
  }
  
  public void removeMouseListener(MouseListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(3, listener);
    eventTable.unhook(4, listener);
    eventTable.unhook(8, listener);
  }
  
  public void removeMouseMoveListener(MouseMoveListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    if (eventTable == null) {
      return;
    }
    eventTable.unhook(5, listener);
  }
  
  public void removeMouseWheelListener(MouseWheelListener listener)
  {
    checkWidget();
    if (listener == null) {
      error(4);
    }
    
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