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

  {
    return null;
  }
  
  LRESULT WM_IME_COMPOSITION_START(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_IME_ENDCOMPOSITION(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_UNINITMENUPOPUP(int wParam, int lParam)
  {
    Menu hiddenMenu = menuShell().findMenu(wParam);
    if (hiddenMenu != null)
    {
      Shell shell = getShell();
      hiddenMenu.sendEvent(23);
      if (hiddenMenu == activeMenu) {
        activeMenu = null;
      }
    }
    return null;
  }
  
  LRESULT WM_INITMENUPOPUP(int wParam, int lParam)
  {
    if (display.accelKeyHit) {
      return null;
    }
    Shell shell = getShell();
    Menu oldMenu = activeMenu;Menu newMenu = null;
    if (OS.HIWORD(lParam) == 0)
    {
      newMenu = menuShell().findMenu(wParam);
      if (newMenu != null) {
        newMenu.update();
      }
    }
    Menu menu = newMenu;
    while ((menu != null) && (menu != oldMenu)) {
      menu = menu.getParentMenu();
    }
    if (menu == null)
    {
      menu = activeMenu;
      while (menu != null)
      {
        menu.sendEvent(23);
        if (menu.isDisposed()) {
          break;
        }
        menu = menu.getParentMenu();
        Menu ancestor = newMenu;
        while ((ancestor != null) && (ancestor != menu)) {
          ancestor = ancestor.getParentMenu();
        }
        if (ancestor != null) {
          break;
        }
      }
    }
    if ((newMenu != null) && (newMenu.isDisposed())) {
      newMenu = null;
    }
    activeMenu = newMenu;
    if ((newMenu != null) && (newMenu != oldMenu)) {
      newMenu.sendEvent(22);
    }
    return null;
  }
  
  LRESULT WM_INPUTLANGCHANGE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_KEYDOWN(int wParam, int lParam)
  {
    return wmKeyDown(handle, wParam, lParam);
  }
  
  LRESULT WM_KEYUP(int wParam, int lParam)
  {
    return wmKeyUp(handle, wParam, lParam);
  }
  
  LRESULT WM_KILLFOCUS(int wParam, int lParam)
  {
    return wmKillFocus(handle, wParam, lParam);
  }
  
  LRESULT WM_LBUTTONDBLCLK(int wParam, int lParam)
  {
    return wmLButtonDblClk(handle, wParam, lParam);
  }
  
  LRESULT WM_LBUTTONDOWN(int wParam, int lParam)
  {
    return wmLButtonDown(handle, wParam, lParam);
  }
  
  LRESULT WM_LBUTTONUP(int wParam, int lParam)
  {
    return wmLButtonUp(handle, wParam, lParam);
  }
  
  LRESULT WM_MBUTTONDBLCLK(int wParam, int lParam)
  {
    return wmMButtonDblClk(handle, wParam, lParam);
  }
  
  LRESULT WM_MBUTTONDOWN(int wParam, int lParam)
  {
    return wmMButtonDown(handle, wParam, lParam);
  }
  
  LRESULT WM_MBUTTONUP(int wParam, int lParam)
  {
    return wmMButtonUp(handle, wParam, lParam);
  }
  
  LRESULT WM_MEASUREITEM(int wParam, int lParam)
  {
    MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT();
    OS.MoveMemory(struct, lParam, MEASUREITEMSTRUCT.sizeof);
    if (CtlType == 1)
    {
      MenuItem item = display.getMenuItem(itemID);
      if (item == null) {
        return null;
      }
      return item.wmMeasureChild(wParam, lParam);
    }
    int hwnd = OS.GetDlgItem(handle, CtlID);
    Control control = display.getControl(hwnd);
    if (control == null) {
      return null;
    }
    return control.wmMeasureChild(wParam, lParam);
  }
  
  LRESULT WM_MENUCHAR(int wParam, int lParam)
  {
    int type = OS.HIWORD(wParam);
    if ((type == 0) || (type == 8192))
    {
      display.mnemonicKeyHit = false;
      return new LRESULT(OS.MAKELRESULT(0, 1));
    }
    return null;
  }
  
  LRESULT WM_MENUSELECT(int wParam, int lParam)
  {
    int code = OS.HIWORD(wParam);
    Shell shell = getShell();
    if ((code == 65535) && (lParam == 0))
    {
      Menu menu = activeMenu;
      while (menu != null)
      {
        display.mnemonicKeyHit = true;
        
        menu.sendEvent(23);
        if (menu.isDisposed()) {
          break;
        }
        menu = menu.getParentMenu();
      }
      activeMenu = null;
      return null;
    }
    if ((code & 0x2000) != 0) {
      return null;
    }
    if ((code & 0x80) != 0)
    {
      MenuItem item = null;
      Decorations menuShell = menuShell();
      if ((code & 0x10) != 0)
      {
        int index = OS.LOWORD(wParam);
        MENUITEMINFO info = new MENUITEMINFO();
        cbSize = MENUITEMINFO.sizeof;
        fMask = 4;
        if (OS.GetMenuItemInfo(lParam, index, true, info))
        {
          Menu newMenu = menuShell.findMenu(hSubMenu);
          if (newMenu != null) {
            item = cascade;
          }
        }
      }
      else
      {
        Menu newMenu = menuShell.findMenu(lParam);
        if (newMenu != null)
        {
          int id = OS.LOWORD(wParam);
          item = display.getMenuItem(id);
        }
      }
      if (item != null) {
        item.sendEvent(30);
      }
    }
    return null;
  }
  
  LRESULT WM_MOUSEACTIVATE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_MOUSEHOVER(int wParam, int lParam)
  {
    return wmMouseHover(handle, wParam, lParam);
  }
  
  LRESULT WM_MOUSELEAVE(int wParam, int lParam)
  {
    if (OS.COMCTL32_MAJOR >= 6) {
      getShell().fixToolTip();
    }
    return wmMouseLeave(handle, wParam, lParam);
  }
  
  LRESULT WM_MOUSEMOVE(int wParam, int lParam)
  {
    return wmMouseMove(handle, wParam, lParam);
  }
  
  LRESULT WM_MOUSEWHEEL(int wParam, int lParam)
  {
    return wmMouseWheel(handle, wParam, lParam);
  }
  
  LRESULT WM_MOUSEHWHEEL(int wParam, int lParam)
  {
    return wmMouseHWheel(handle, wParam, lParam);
  }
  
  LRESULT WM_MOVE(int wParam, int lParam)
  {
    state |= 0x10000;
    if (findImageControl() != null)
    {
      if (this != getShell()) {
        redrawChildren();
      }
    }
    else if (((state & 0x100) != 0) && 
      (OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()) && 
      (OS.IsWindowVisible(handle)) && 
      (findThemeControl() != null)) {
      redrawChildren();
    }
    if ((state & 0x20000) == 0) {
      sendEvent(10);
    }
    return null;
  }
  
  LRESULT WM_NCACTIVATE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_NCCALCSIZE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_NCHITTEST(int wParam, int lParam)
  {
    if (!OS.IsWindowEnabled(handle)) {
      return null;
    }
    if (!isActive()) {
      return new LRESULT(-1);
    }
    return null;
  }
  
  LRESULT WM_NCLBUTTONDOWN(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_NCPAINT(int wParam, int lParam)
  {
    return wmNCPaint(handle, wParam, lParam);
  }
  
  LRESULT WM_NOTIFY(int wParam, int lParam)
  {
    NMHDR hdr = new NMHDR();
    OS.MoveMemory(hdr, lParam, NMHDR.sizeof);
    return wmNotify(hdr, wParam, lParam);
  }
  
  LRESULT WM_PAINT(int wParam, int lParam)
  {
    return wmPaint(handle, wParam, lParam);
  }
  
  LRESULT WM_PALETTECHANGED(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_PARENTNOTIFY(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_PASTE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_PRINT(int wParam, int lParam)
  {
    return wmPrint(handle, wParam, lParam);
  }
  
  LRESULT WM_PRINTCLIENT(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_QUERYENDSESSION(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_QUERYNEWPALETTE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_QUERYOPEN(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_RBUTTONDBLCLK(int wParam, int lParam)
  {
    return wmRButtonDblClk(handle, wParam, lParam);
  }
  
  LRESULT WM_RBUTTONDOWN(int wParam, int lParam)
  {
    return wmRButtonDown(handle, wParam, lParam);
  }
  
  LRESULT WM_RBUTTONUP(int wParam, int lParam)
  {
    return wmRButtonUp(handle, wParam, lParam);
  }
  
  LRESULT WM_SETCURSOR(int wParam, int lParam)
  {
    int hitTest = (short)OS.LOWORD(lParam);
    if (hitTest == 1)
    {
      Control control = display.getControl(wParam);
      if (control == null) {
        return null;
      }
      Cursor cursor = control.findCursor();
      if (cursor != null)
      {
        OS.SetCursor(handle);
        return LRESULT.ONE;
      }
    }
    return null;
  }
  
  LRESULT WM_SETFOCUS(int wParam, int lParam)
  {
    return wmSetFocus(handle, wParam, lParam);
  }
  
  LRESULT WM_SETTINGCHANGE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_SETFONT(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_SETREDRAW(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_SHOWWINDOW(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_SIZE(int wParam, int lParam)
  {
    state |= 0x40000;
    if ((state & 0x80000) == 0) {
      sendEvent(11);
    }
    return null;
  }
  
  LRESULT WM_SYSCHAR(int wParam, int lParam)
  {
    return wmSysChar(handle, wParam, lParam);
  }
  
  LRESULT WM_SYSCOLORCHANGE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_SYSCOMMAND(int wParam, int lParam)
  {
    if ((wParam & 0xF000) == 0)
    {
      Decorations shell = menuShell();
      if (shell.isEnabled())
      {
        MenuItem item = display.getMenuItem(OS.LOWORD(wParam));
        if (item != null) {
          item.wmCommandChild(wParam, lParam);
        }
      }
      return LRESULT.ZERO;
    }
    int cmd = wParam & 0xFFF0;
    switch (cmd)
    {
    case 61536: 
      int hwndShell = menuShellhandle;
      int bits = OS.GetWindowLong(hwndShell, -16);
      if ((bits & 0x80000) == 0) {
        return LRESULT.ZERO;
      }
      break;
    case 61696: 
      if (lParam == 0)
      {
        Decorations shell = menuShell();
        Menu menu = shell.getMenuBar();
        if (menu == null)
        {
          Control control = display._getFocusControl();
          if ((control != null) && (
            (control.hooks(1)) || (control.hooks(2))))
          {
            display.mnemonicKeyHit = false;
            return LRESULT.ZERO;
          }
        }
      }
      else if (((hooks(1)) || (hooks(2))) && 
        (lParam != 32))
      {
        Decorations shell = menuShell();
        Menu menu = shell.getMenuBar();
        if (menu != null)
        {
          char key = Display.mbcsToWcs(lParam);
          if (key != 0)
          {
            key = Character.toUpperCase(key);
            MenuItem[] items = menu.getItems();
            for (int i = 0; i < items.length; i++)
            {
              MenuItem item = items[i];
              String text = item.getText();
              char mnemonic = findMnemonic(text);
              if ((text.length() > 0) && (mnemonic == 0))
              {
                char ch = text.charAt(0);
                if (Character.toUpperCase(ch) == key)
                {
                  display.mnemonicKeyHit = false;
                  return LRESULT.ZERO;
                }
              }
            }
          }
        }
        else
        {
          display.mnemonicKeyHit = false;
        }
      }
    case 61552: 
    case 61568: 
      Decorations shell = menuShell();
      if ((!shell.isEnabled()) || (!shell.isActive())) {
        return LRESULT.ZERO;
      }
      break;
    case 61472: 
      menuShell().saveFocus();
    }
    return null;
  }
  
  LRESULT WM_SYSKEYDOWN(int wParam, int lParam)
  {
    return wmSysKeyDown(handle, wParam, lParam);
  }
  
  LRESULT WM_SYSKEYUP(int wParam, int lParam)
  {
    return wmSysKeyUp(handle, wParam, lParam);
  }
  
  LRESULT WM_TABLET_FLICK(int wParam, int lParam)
  {
    if ((!hooks(48)) && (!filters(48))) {
      return null;
    }
    Event event = new Event();
    FLICK_DATA fData = new FLICK_DATA();
    int[] source = new int[1];
    source[0] = wParam;
    OS.MoveMemory(fData, source, OS.FLICK_DATA_sizeof());
    FLICK_POINT fPoint = new FLICK_POINT();
    source[0] = lParam;
    OS.MoveMemory(fPoint, source, OS.FLICK_POINT_sizeof());
    switch (iFlickDirection)
    {
    case 0: 
      xDirection = 1;
      yDirection = 0;
      break;
    case 1: 
      xDirection = 1;
      yDirection = -1;
      break;
    case 2: 
      xDirection = 0;
      yDirection = -1;
      break;
    case 3: 
      xDirection = -1;
      yDirection = -1;
      break;
    case 4: 
      xDirection = -1;
      yDirection = 0;
      break;
    case 5: 
      xDirection = -1;
      yDirection = 1;
      break;
    case 6: 
      xDirection = 0;
      yDirection = 1;
      break;
    case 7: 
      xDirection = 1;
      yDirection = 1;
    }
    x = x;
    y = y;
    type = 48;
    detail = 16;
    setInputState(event, 48);
    sendEvent(48, event);
    return doit ? null : LRESULT.ONE;
  }
  
  LRESULT WM_TOUCH(int wParam, int lParam)
  {
    LRESULT result = null;
    if ((hooks(47)) || (filters(47)))
    {
      int cInputs = OS.LOWORD(wParam);
      int hHeap = OS.GetProcessHeap();
      int pInputs = OS.HeapAlloc(hHeap, 8, cInputs * TOUCHINPUT.sizeof);
      if (pInputs != 0)
      {
        if (OS.GetTouchInputInfo(lParam, cInputs, pInputs, TOUCHINPUT.sizeof))
        {
          TOUCHINPUT[] ti = new TOUCHINPUT[cInputs];
          for (int i = 0; i < cInputs; i++)
          {
            ti[i] = new TOUCHINPUT();
            OS.MoveMemory(ti[i], pInputs + i * TOUCHINPUT.sizeof, TOUCHINPUT.sizeof);
          }
          sendTouchEvent(ti);
          OS.CloseTouchInputHandle(lParam);
          result = LRESULT.ZERO;
        }
        OS.HeapFree(hHeap, 0, pInputs);
      }
    }
    return result;
  }
  
  LRESULT WM_TIMER(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_UNDO(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_UPDATEUISTATE(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT WM_VSCROLL(int wParam, int lParam)
  {
    Control control = display.getControl(lParam);
    if (control == null) {
      return null;
    }
    return control.wmScrollChild(wParam, lParam);
  }
  
  LRESULT WM_WINDOWPOSCHANGED(int wParam, int lParam)
  {
    try
    {
      display.resizeCount += 1;
      int code = callWindowProc(handle, 71, wParam, lParam);
      LRESULT localLRESULT = code == 0 ? LRESULT.ZERO : new LRESULT(code);
      
      display.resizeCount -= 1;return localLRESULT;
    }
    finally
    {
      display.resizeCount -= 1;
    }
  }
  
  LRESULT WM_WINDOWPOSCHANGING(int wParam, int lParam)
  {
    if (!getDrawing())
    {
      Shell shell = getShell();
      if (shell != this)
      {
        WINDOWPOS lpwp = new WINDOWPOS();
        OS.MoveMemory(lpwp, lParam, WINDOWPOS.sizeof);
        if (((flags & 0x2) == 0) || ((flags & 0x1) == 0))
        {
          RECT rect = new RECT();
          OS.GetWindowRect(topHandle(), rect);
          int width = right - left;
          int height = bottom - top;
          if ((width != 0) && (height != 0))
          {
            int hwndParent = parent == null ? 0 : parent.handle;
            OS.MapWindowPoints(0, hwndParent, rect, 2);
            if (OS.IsWinCE)
            {
              OS.InvalidateRect(hwndParent, rect, true);
            }
            else
            {
              int rgn1 = OS.CreateRectRgn(left, top, right, bottom);
              int rgn2 = OS.CreateRectRgn(x, y, x + cx, y + cy);
              OS.CombineRgn(rgn1, rgn1, rgn2, 4);
              int flags = 1157;
              OS.RedrawWindow(hwndParent, null, rgn1, flags);
              OS.DeleteObject(rgn1);
              OS.DeleteObject(rgn2);
            }
          }
        }
      }
    }
    return null;
  }
  
  LRESULT WM_XBUTTONDBLCLK(int wParam, int lParam)
  {
    return wmXButtonDblClk(handle, wParam, lParam);
  }
  
  LRESULT WM_XBUTTONDOWN(int wParam, int lParam)
  {
    return wmXButtonDown(handle, wParam, lParam);
  }
  
  LRESULT WM_XBUTTONUP(int wParam, int lParam)
  {
    return wmXButtonUp(handle, wParam, lParam);
  }
  
  LRESULT wmColorChild(int wParam, int lParam)
  {
    Control control = findBackgroundControl();
    if (control == null)
    {
      if (((state & 0x100) != 0) && 
        (OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()))
      {
        control = findThemeControl();
        if (control != null)
        {
          RECT rect = new RECT();
          OS.GetClientRect(handle, rect);
          OS.SetTextColor(wParam, getForegroundPixel());
          OS.SetBkColor(wParam, getBackgroundPixel());
          fillThemeBackground(wParam, control, rect);
          OS.SetBkMode(wParam, 1);
          return new LRESULT(OS.GetStockObject(5));
        }
      }
      if (foreground == -1) {
        return null;
      }
    }
    if (control == null) {
      control = this;
    }
    int forePixel = getForegroundPixel();
    int backPixel = control.getBackgroundPixel();
    OS.SetTextColor(wParam, forePixel);
    OS.SetBkColor(wParam, backPixel);
    if (backgroundImage != null)
    {
      RECT rect = new RECT();
      OS.GetClientRect(handle, rect);
      int hwnd = handle;
      int hBitmap = backgroundImage.handle;
      OS.MapWindowPoints(handle, hwnd, rect, 2);
      POINT lpPoint = new POINT();
      OS.GetWindowOrgEx(wParam, lpPoint);
      OS.SetBrushOrgEx(wParam, -left - x, -top - y, lpPoint);
      int hBrush = findBrush(hBitmap, 3);
      if ((state & 0x200) != 0)
      {
        int hOldBrush = OS.SelectObject(wParam, hBrush);
        OS.MapWindowPoints(hwnd, handle, rect, 2);
        OS.PatBlt(wParam, left, top, right - left, bottom - top, 15728673);
        OS.SelectObject(wParam, hOldBrush);
      }
      OS.SetBkMode(wParam, 1);
      return new LRESULT(hBrush);
    }
    int hBrush = findBrush(backPixel, 0);
    if ((state & 0x200) != 0)
    {
      RECT rect = new RECT();
      OS.GetClientRect(handle, rect);
      int hOldBrush = OS.SelectObject(wParam, hBrush);
      OS.PatBlt(wParam, left, top, right - left, bottom - top, 15728673);
      OS.SelectObject(wParam, hOldBrush);
    }
    return new LRESULT(hBrush);
  }
  
  LRESULT wmCommandChild(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT wmDrawChild(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT wmMeasureChild(int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT wmNotify(NMHDR hdr, int wParam, int lParam)
  {
    Control control = display.getControl(hwndFrom);
    if (control == null) {
      return null;
    }
    return control.wmNotifyChild(hdr, wParam, lParam);
  }
  
  LRESULT wmNotifyChild(NMHDR hdr, int wParam, int lParam)
  {
    return null;
  }
  
  LRESULT wmScrollChild(int wParam, int lParam)
  {
    return null;
  }
}

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.win32.INITCOMMONCONTROLSEX;
import org.eclipse.swt.internal.win32.LRESULT;
import org.eclipse.swt.internal.win32.MARGINS;
import org.eclipse.swt.internal.win32.NMCUSTOMDRAW;
import org.eclipse.swt.internal.win32.NMHDR;
import org.eclipse.swt.internal.win32.NMREBARCHEVRON;
import org.eclipse.swt.internal.win32.NMREBARCHILDSIZE;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.POINT;
import org.eclipse.swt.internal.win32.REBARBANDINFO;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.internal.win32.WNDCLASS;

public class CoolBar
  extends Composite
{
  CoolItem[] items;
  CoolItem[] originalItems;
  boolean locked;
  boolean ignoreResize;
  static final int ReBarProc;
  static final TCHAR ReBarClass = new TCHAR(0, "ReBarWindow32", true);
  static final int SEPARATOR_WIDTH = 2;
  static final int MAX_WIDTH = 32767;
  static final int DEFAULT_COOLBAR_WIDTH = 0;
  static final int DEFAULT_COOLBAR_HEIGHT = 0;
  
  static
  {
    INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX();
    dwSize = INITCOMMONCONTROLSEX.sizeof;
    dwICC = 1024;
    OS.InitCommonControlsEx(icex);
    WNDCLASS lpWndClass = new WNDCLASS();
    OS.GetClassInfo(0, ReBarClass, lpWndClass);
    ReBarProc = lpfnWndProc;
  }
  
  public CoolBar(Composite parent, int style)
  {
    super(parent, checkStyle(style));
    if ((style & 0x200) != 0)
    {
      this.style |= 0x200;
      int bits = OS.GetWindowLong(handle, -16);
      OS.SetWindowLong(handle, -16, bits | 0x80);
    }
    else
    {
      this.style |= 0x100;
    }
  }
  
  int callWindowProc(int hwnd, int msg, int wParam, int lParam)
  {
    if (handle == 0) {
      return 0;
    }
    return OS.CallWindowProc(ReBarProc, hwnd, msg, wParam, lParam);
  }
  
  static int checkStyle(int style)
  {
    style |= 0x80000;
    
    return style & 0xFCFF;
  }
  
  protected void checkSubclass()
  {
    if (!isValidSubclass()) {
      error(43);
    }
  }
  
  public Point computeSize(int wHint, int hHint, boolean changed)
  {
    checkWidget();
    int width = 0;int height = 0;
    int border = getBorderWidth();
    int newWidth = wHint == -1 ? 16383 : wHint + border * 2;
    int newHeight = hHint == -1 ? 16383 : hHint + border * 2;
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if (count != 0)
    {
      ignoreResize = true;
      boolean redraw = false;
      if (OS.IsWindowVisible(handle)) {
        if (OS.COMCTL32_MAJOR >= 6)
        {
          redraw = true;
          OS.UpdateWindow(handle);
          OS.DefWindowProc(handle, 11, 0, 0);
        }
        else
        {
          redraw = getDrawing();
          if (redraw)
          {
            OS.UpdateWindow(handle);
            OS.SendMessage(handle, 11, 0, 0);
          }
        }
      }
      RECT oldRect = new RECT();
      OS.GetWindowRect(handle, oldRect);
      int oldWidth = right - left;
      int oldHeight = bottom - top;
      int flags = 30;
      SetWindowPos(handle, 0, 0, 0, newWidth, newHeight, flags);
      RECT rect = new RECT();
      OS.SendMessage(handle, 1033, count - 1, rect);
      height = Math.max(height, bottom);
      SetWindowPos(handle, 0, 0, 0, oldWidth, oldHeight, flags);
      REBARBANDINFO rbBand = new REBARBANDINFO();
      cbSize = REBARBANDINFO.sizeof;
      fMask = 513;
      int rowWidth = 0;
      for (int i = 0; i < count; i++)
      {
        OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
        if ((fStyle & 0x1) != 0)
        {
          width = Math.max(width, rowWidth);
          rowWidth = 0;
        }
        rowWidth += cxIdeal + getMargin(i);
      }
      width = Math.max(width, rowWidth);
      if (redraw) {
        if (OS.COMCTL32_MAJOR >= 6) {
          OS.DefWindowProc(handle, 11, 1, 0);
        } else {
          OS.SendMessage(handle, 11, 1, 0);
        }
      }
      ignoreResize = false;
    }
    if (width == 0) {
      width = 0;
    }
    if (height == 0) {
      height = 0;
    }
    if ((style & 0x200) != 0)
    {
      int tmp = width;
      width = height;
      height = tmp;
    }
    if (wHint != -1) {
      width = wHint;
    }
    if (hHint != -1) {
      height = hHint;
    }
    height += border * 2;
    width += border * 2;
    return new Point(width, height);
  }
  
  void createHandle()
  {
    super.createHandle();
    state &= 0xFEFD;
    
    int hFont = OS.GetStockObject(13);
    OS.SendMessage(handle, 48, hFont, 0);
  }
  
  void createItem(CoolItem item, int index)
  {
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if ((index < 0) || (index > count)) {
      error(6);
    }
    int id = 0;
    while ((id < items.length) && (items[id] != null)) {
      id++;
    }
    if (id == items.length)
    {
      CoolItem[] newItems = new CoolItem[items.length + 4];
      System.arraycopy(items, 0, newItems, 0, items.length);
      items = newItems;
    }
    int hHeap = OS.GetProcessHeap();
    int lpText = OS.HeapAlloc(hHeap, 8, TCHAR.sizeof);
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 261;
    fStyle = 192;
    if ((style & 0x4) != 0) {
      fStyle |= 0x200;
    }
    lpText = lpText;
    wID = id;
    
    int lastIndex = getLastIndexOfRow(index - 1);
    boolean fixLast = index == lastIndex + 1;
    if (fixLast)
    {
      fMask |= 0x40;
      cx = 32767;
    }
    if ((index == 0) && (count > 0)) {
      getItem(0).setWrap(false);
    }
    if (OS.SendMessage(handle, OS.RB_INSERTBAND, index, rbBand) == 0) {
      error(14);
    }
    if (fixLast) {
      resizeToPreferredWidth(lastIndex);
    }
    OS.HeapFree(hHeap, 0, lpText);
    items[(id = id)] = item;
    int length = originalItems.length;
    CoolItem[] newOriginals = new CoolItem[length + 1];
    System.arraycopy(originalItems, 0, newOriginals, 0, index);
    System.arraycopy(originalItems, index, newOriginals, index + 1, length - index);
    newOriginals[index] = item;
    originalItems = newOriginals;
  }
  
  void createWidget()
  {
    super.createWidget();
    items = new CoolItem[4];
    originalItems = new CoolItem[0];
  }
  
  void destroyItem(CoolItem item)
  {
    int index = OS.SendMessage(handle, 1040, id, 0);
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if (count != 0)
    {
      int lastIndex = getLastIndexOfRow(index);
      if (index == lastIndex) {
        resizeToMaximumWidth(lastIndex - 1);
      }
    }
    Control control = control;
    boolean wasVisible = (control != null) && (!control.isDisposed()) && (control.getVisible());
    
    CoolItem nextItem = null;
    if ((item.getWrap()) && 
      (index + 1 < count))
    {
      nextItem = getItem(index + 1);
      ignoreResize = (!nextItem.getWrap());
    }
    if (OS.SendMessage(handle, 1026, index, 0) == 0) {
      error(15);
    }
    items[id] = null;
    id = -1;
    if (ignoreResize)
    {
      nextItem.setWrap(true);
      ignoreResize = false;
    }
    if (wasVisible) {
      control.setVisible(true);
    }
    index = 0;
    while (index < originalItems.length)
    {
      if (originalItems[index] == item) {
        break;
      }
      index++;
    }
    int length = originalItems.length - 1;
    CoolItem[] newOriginals = new CoolItem[length];
    System.arraycopy(originalItems, 0, newOriginals, 0, index);
    System.arraycopy(originalItems, index + 1, newOriginals, index, length - index);
    originalItems = newOriginals;
  }
  
  void drawThemeBackground(int hDC, int hwnd, RECT rect)
  {
    if ((OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed()) && 
      (background == -1) && ((style & 0x800000) != 0))
    {
      Control control = findBackgroundControl();
      if ((control != null) && (backgroundImage != null))
      {
        fillBackground(hDC, control.getBackgroundPixel(), rect);
        return;
      }
    }
    RECT rect2 = new RECT();
    OS.GetClientRect(handle, rect2);
    OS.MapWindowPoints(handle, hwnd, rect2, 2);
    POINT lpPoint = new POINT();
    OS.SetWindowOrgEx(hDC, -left, -top, lpPoint);
    OS.SendMessage(handle, 791, hDC, 12);
    OS.SetWindowOrgEx(hDC, x, y, null);
  }
  
  Control findThemeControl()
  {
    if ((style & 0x800000) != 0) {
      return this;
    }
    return (background == -1) && (backgroundImage == null) ? this : super.findThemeControl();
  }
  
  int getMargin(int index)
  {
    int margin = 0;
    if (OS.COMCTL32_MAJOR >= 6)
    {
      MARGINS margins = new MARGINS();
      OS.SendMessage(handle, 1064, 0, margins);
      margin += cxLeftWidth + cxRightWidth;
    }
    RECT rect = new RECT();
    OS.SendMessage(handle, 1058, index, rect);
    if ((style & 0x800000) != 0)
    {
      if ((style & 0x200) != 0) {
        margin += top + 4;
      } else {
        margin += left + 4;
      }
    }
    else if ((style & 0x200) != 0) {
      margin += top + bottom;
    } else {
      margin += left + right;
    }
    if (((style & 0x800000) == 0) && 
      (!isLastItemOfRow(index))) {
      margin += 2;
    }
    return margin;
  }
  
  public CoolItem getItem(int index)
  {
    checkWidget();
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if ((index < 0) || (index >= count)) {
      error(6);
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 256;
    OS.SendMessage(handle, OS.RB_GETBANDINFO, index, rbBand);
    return items[wID];
  }
  
  public int getItemCount()
  {
    checkWidget();
    return OS.SendMessage(handle, 1036, 0, 0);
  }
  
  public int[] getItemOrder()
  {
    checkWidget();
    int count = OS.SendMessage(handle, 1036, 0, 0);
    int[] indices = new int[count];
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 256;
    for (int i = 0; i < count; i++)
    {
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      CoolItem item = items[wID];
      int index = 0;
      while (index < originalItems.length)
      {
        if (originalItems[index] == item) {
          break;
        }
        index++;
      }
      if (index == originalItems.length) {
        error(8);
      }
      indices[i] = index;
    }
    return indices;
  }
  
  public CoolItem[] getItems()
  {
    checkWidget();
    int count = OS.SendMessage(handle, 1036, 0, 0);
    CoolItem[] result = new CoolItem[count];
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 256;
    for (int i = 0; i < count; i++)
    {
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      result[i] = items[wID];
    }
    return result;
  }
  
  public Point[] getItemSizes()
  {
    checkWidget();
    int count = OS.SendMessage(handle, 1036, 0, 0);
    Point[] sizes = new Point[count];
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 32;
    int separator = (style & 0x800000) == 0 ? 2 : 0;
    MARGINS margins = new MARGINS();
    for (int i = 0; i < count; i++)
    {
      RECT rect = new RECT();
      OS.SendMessage(handle, 1033, i, rect);
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      if (OS.COMCTL32_MAJOR >= 6)
      {
        OS.SendMessage(handle, 1064, 0, margins);
        left -= cxLeftWidth;
        right += cxRightWidth;
      }
      if (!isLastItemOfRow(i)) {
        right += separator;
      }
      if ((style & 0x200) != 0) {
        sizes[i] = new Point(cyChild, right - left);
      } else {
        sizes[i] = new Point(right - left, cyChild);
      }
    }
    return sizes;
  }
  
  int getLastIndexOfRow(int index)
  {
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if (count == 0) {
      return -1;
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 1;
    for (int i = index + 1; i < count; i++)
    {
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      if ((fStyle & 0x1) != 0) {
        return i - 1;
      }
    }
    return count - 1;
  }
  
  boolean isLastItemOfRow(int index)
  {
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if (index + 1 == count) {
      return true;
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 1;
    OS.SendMessage(handle, OS.RB_GETBANDINFO, index + 1, rbBand);
    return (fStyle & 0x1) != 0;
  }
  
  public boolean getLocked()
  {
    checkWidget();
    return locked;
  }
  
  public int[] getWrapIndices()
  {
    checkWidget();
    CoolItem[] items = getItems();
    int[] indices = new int[items.length];
    int count = 0;
    for (int i = 0; i < items.length; i++) {
      if (items[i].getWrap()) {
        indices[(count++)] = i;
      }
    }
    int[] result = new int[count];
    System.arraycopy(indices, 0, result, 0, count);
    return result;
  }
  
  public int indexOf(CoolItem item)
  {
    checkWidget();
    if (item == null) {
      error(4);
    }
    if (item.isDisposed()) {
      error(5);
    }
    return OS.SendMessage(handle, 1040, id, 0);
  }
  
  void resizeToPreferredWidth(int index)
  {
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if ((index >= 0) && (index < count))
    {
      REBARBANDINFO rbBand = new REBARBANDINFO();
      cbSize = REBARBANDINFO.sizeof;
      fMask = 512;
      OS.SendMessage(handle, OS.RB_GETBANDINFO, index, rbBand);
      RECT rect = new RECT();
      OS.SendMessage(handle, 1058, index, rect);
      cx = (cxIdeal + left);
      if ((style & 0x800000) == 0) {
        cx += right;
      }
      fMask = 64;
      OS.SendMessage(handle, OS.RB_SETBANDINFO, index, rbBand);
    }
  }
  
  void resizeToMaximumWidth(int index)
  {
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 64;
    cx = 32767;
    OS.SendMessage(handle, OS.RB_SETBANDINFO, index, rbBand);
  }
  
  void releaseChildren(boolean destroy)
  {
    if (items != null)
    {
      for (int i = 0; i < items.length; i++)
      {
        CoolItem item = items[i];
        if ((item != null) && (!item.isDisposed())) {
          item.release(false);
        }
      }
      items = null;
    }
    super.releaseChildren(destroy);
  }
  
  void removeControl(Control control)
  {
    super.removeControl(control);
    for (int i = 0; i < items.length; i++)
    {
      CoolItem item = items[i];
      if ((item != null) && (control == control)) {
        item.setControl(null);
      }
    }
  }
  
  void reskinChildren(int flags)
  {
    if (items != null) {
      for (int i = 0; i < items.length; i++)
      {
        CoolItem item = items[i];
        if (item != null) {
          item.reskin(flags);
        }
      }
    }
    super.reskinChildren(flags);
  }
  
  void setBackgroundPixel(int pixel)
  {
    if (pixel == -1) {
      pixel = defaultBackground();
    }
    OS.SendMessage(handle, 1043, 0, pixel);
    setItemColors(OS.SendMessage(handle, 1046, 0, 0), pixel);
    if (!OS.IsWindowVisible(handle)) {
      return;
    }
    if (OS.IsWinCE)
    {
      OS.InvalidateRect(handle, null, true);
    }
    else
    {
      int flags = 1157;
      OS.RedrawWindow(handle, null, 0, flags);
    }
  }
  
  void setForegroundPixel(int pixel)
  {
    if (pixel == -1) {
      pixel = defaultForeground();
    }
    OS.SendMessage(handle, 1045, 0, pixel);
    setItemColors(pixel, OS.SendMessage(handle, 1044, 0, 0));
  }
  
  void setItemColors(int foreColor, int backColor)
  {
    int count = OS.SendMessage(handle, 1036, 0, 0);
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 2;
    clrFore = foreColor;
    clrBack = backColor;
    for (int i = 0; i < count; i++) {
      OS.SendMessage(handle, OS.RB_SETBANDINFO, i, rbBand);
    }
  }
  
  public void setItemLayout(int[] itemOrder, int[] wrapIndices, Point[] sizes)
  {
    checkWidget();
    setRedraw(false);
    setItemOrder(itemOrder);
    setWrapIndices(wrapIndices);
    setItemSizes(sizes);
    setRedraw(true);
  }
  
  void setItemOrder(int[] itemOrder)
  {
    if (itemOrder == null) {
      error(4);
    }
    int itemCount = OS.SendMessage(handle, 1036, 0, 0);
    if (itemOrder.length != itemCount) {
      error(5);
    }
    boolean[] set = new boolean[itemCount];
    for (int i = 0; i < itemOrder.length; i++)
    {
      int index = itemOrder[i];
      if ((index < 0) || (index >= itemCount)) {
        error(6);
      }
      if (set[index] != 0) {
        error(5);
      }
      set[index] = true;
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    for (int i = 0; i < itemOrder.length; i++)
    {
      int id = originalItems[itemOrder[i]].id;
      int index = OS.SendMessage(handle, 1040, id, 0);
      if (index != i)
      {
        int lastItemSrcRow = getLastIndexOfRow(index);
        int lastItemDstRow = getLastIndexOfRow(i);
        if (index == lastItemSrcRow) {
          resizeToPreferredWidth(index);
        }
        if (i == lastItemDstRow) {
          resizeToPreferredWidth(i);
        }
        OS.SendMessage(handle, 1063, index, i);
        if ((index == lastItemSrcRow) && (index - 1 >= 0)) {
          resizeToMaximumWidth(index - 1);
        }
        if (i == lastItemDstRow) {
          resizeToMaximumWidth(i);
        }
      }
    }
  }
  
  void setItemSizes(Point[] sizes)
  {
    if (sizes == null) {
      error(4);
    }
    int count = OS.SendMessage(handle, 1036, 0, 0);
    if (sizes.length != count) {
      error(5);
    }
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 256;
    for (int i = 0; i < count; i++)
    {
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      items[wID].setSize(x, y);
    }
  }
  
  public void setLocked(boolean locked)
  {
    checkWidget();
    this.locked = locked;
    int count = OS.SendMessage(handle, 1036, 0, 0);
    REBARBANDINFO rbBand = new REBARBANDINFO();
    cbSize = REBARBANDINFO.sizeof;
    fMask = 1;
    for (int i = 0; i < count; i++)
    {
      OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
      if (locked) {
        fStyle |= 0x100;
      } else {
        fStyle &= 0xFEFF;
      }
      OS.SendMessage(handle, OS.RB_SETBANDINFO, i, rbBand);
    }
  }
  
  public void setWrapIndices(int[] indices)
  {
    checkWidget();
    if (indices == null) {
      indices = new int[0];
    }
    int count = getItemCount();
    for (int i = 0; i < indices.length; i++) {
      if ((indices[i] < 0) || (indices[i] >= count)) {
        error(6);
      }
    }
    setRedraw(false);
    CoolItem[] items = getItems();
    for (int i = 0; i < items.length; i++)
    {
      CoolItem item = items[i];
      if (item.getWrap())
      {
        resizeToPreferredWidth(i - 1);
        item.setWrap(false);
      }
    }
    resizeToMaximumWidth(count - 1);
    for (int i = 0; i < indices.length; i++)
    {
      int index = indices[i];
      if ((index >= 0) && (index < items.length))
      {
        CoolItem item = items[index];
        item.setWrap(true);
        resizeToMaximumWidth(index - 1);
      }
    }
    setRedraw(true);
  }
  
  int widgetStyle()
  {
    int bits = super.widgetStyle() | 0x40 | 0x4;
    bits |= 0x8200;
    if ((style & 0x800000) == 0) {
      bits |= 0x400;
    }
    return bits;
  }
  
  TCHAR windowClass()
  {
    return ReBarClass;
  }
  
  int windowProc()
  {
    return ReBarProc;
  }
  
  LRESULT WM_COMMAND(int wParam, int lParam)
  {
    LRESULT result = super.WM_COMMAND(wParam, lParam);
    if (result != null) {
      return result;
    }
    return LRESULT.ZERO;
  }
  
  LRESULT WM_ERASEBKGND(int wParam, int lParam)
  {
    LRESULT result = super.WM_ERASEBKGND(wParam, lParam);
    if ((OS.COMCTL32_MAJOR < 6) || (!OS.IsAppThemed()))
    {
      drawBackground(wParam);
      return null;
    }
    return result;
  }
  
  LRESULT WM_NOTIFY(int wParam, int lParam)
  {
    LRESULT result = super.WM_NOTIFY(wParam, lParam);
    if (result != null) {
      return result;
    }
    return LRESULT.ZERO;
  }
  
  LRESULT WM_SETREDRAW(int wParam, int lParam)
  {
    LRESULT result = super.WM_SETREDRAW(wParam, lParam);
    if (result != null) {
      return result;
    }
    if (OS.COMCTL32_MAJOR >= 6) {
      return LRESULT.ZERO;
    }
    Rectangle rect = getBounds();
    int code = callWindowProc(handle, 11, wParam, lParam);
    OS.DefWindowProc(handle, 11, wParam, lParam);
    if (!rect.equals(getBounds())) {
      parent.redraw(x, y, width, height, true);
    }
    return new LRESULT(code);
  }
  
  LRESULT WM_SIZE(int wParam, int lParam)
  {
    if (ignoreResize)
    {
      int code = callWindowProc(handle, 5, wParam, lParam);
      if (code == 0) {
        return LRESULT.ZERO;
      }
      return new LRESULT(code);
    }
    return super.WM_SIZE(wParam, lParam);
  }
  
  LRESULT wmNotifyChild(NMHDR hdr, int wParam, int lParam)
  {
    switch (code)
    {
    case -835: 
      int pos = OS.GetMessagePos();
      POINT pt = new POINT();
      OS.POINTSTOPOINT(pt, pos);
      OS.ScreenToClient(handle, pt);
      int button = display.lastButton != 0 ? display.lastButton : 1;
      if (!sendDragEvent(button, x, y)) {
        return LRESULT.ONE;
      }
      break;
    case -839: 
      NMREBARCHILDSIZE lprbcs = new NMREBARCHILDSIZE();
      OS.MoveMemory(lprbcs, lParam, NMREBARCHILDSIZE.sizeof);
   
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