Exemple #1
0
 LRESULT WM_GETDLGCODE(int /*long*/ wParam, int /*long*/ lParam) {
   LRESULT result = super.WM_GETDLGCODE(wParam, lParam);
   if (result != null) return result;
   int index, count;
   int /*long*/ code = 0;
   if (OS.COMCTL32_MAJOR >= 6) {
     LITEM item = new LITEM();
     item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
     item.stateMask = OS.LIS_FOCUSED;
     index = 0;
     while (OS.SendMessage(handle, OS.LM_GETITEM, 0, item) != 0) {
       if ((item.state & OS.LIS_FOCUSED) != 0) {
         index = item.iLink;
       }
       item.iLink++;
     }
     count = item.iLink;
     code = callWindowProc(handle, OS.WM_GETDLGCODE, wParam, lParam);
   } else {
     index = focusIndex;
     count = offsets.length;
   }
   if (count == 0) {
     return new LRESULT(code | OS.DLGC_STATIC);
   }
   boolean next = OS.GetKeyState(OS.VK_SHIFT) >= 0;
   if (next && index < count - 1) {
     return new LRESULT(code | OS.DLGC_WANTTAB);
   }
   if (!next && index > 0) {
     return new LRESULT(code | OS.DLGC_WANTTAB);
   }
   return result;
 }
Exemple #2
0
 void enableWidget(boolean enabled) {
   if (OS.COMCTL32_MAJOR >= 6) {
     LITEM item = new LITEM();
     item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
     item.stateMask = OS.LIS_ENABLED;
     item.state = enabled ? OS.LIS_ENABLED : 0;
     while (OS.SendMessage(handle, OS.LM_SETITEM, 0, item) != 0) {
       item.iLink++;
     }
   } else {
     TextStyle linkStyle = new TextStyle(null, enabled ? linkColor : disabledColor, null);
     linkStyle.underline = true;
     for (int i = 0; i < offsets.length; i++) {
       Point point = offsets[i];
       layout.setStyle(linkStyle, point.x, point.y);
     }
     redraw();
   }
   /*
    * Feature in Windows.  For some reason, setting
    * LIS_ENABLED state using LM_SETITEM causes the
    * SysLink to become enabled.  To be specific,
    * calling IsWindowEnabled() returns true.  The
    * fix is disable the SysLink after LM_SETITEM.
    */
   super.enableWidget(enabled);
 }
Exemple #3
0
 public Point computeSize(int wHint, int hHint, boolean changed) {
   checkWidget();
   if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
   if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
   int width, height;
   if (OS.COMCTL32_MAJOR >= 6) {
     int /*long*/ hDC = OS.GetDC(handle);
     int /*long*/ newFont = OS.SendMessage(handle, OS.WM_GETFONT, 0, 0);
     int /*long*/ oldFont = OS.SelectObject(hDC, newFont);
     if (text.length() > 0) {
       TCHAR buffer = new TCHAR(getCodePage(), parse(text), false);
       RECT rect = new RECT();
       int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
       if (wHint != SWT.DEFAULT) {
         flags |= OS.DT_WORDBREAK;
         rect.right = wHint;
       }
       OS.DrawText(hDC, buffer, buffer.length(), rect, flags);
       width = rect.right - rect.left;
       height = rect.bottom;
     } else {
       TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC) new TEXTMETRICW() : new TEXTMETRICA();
       OS.GetTextMetrics(hDC, lptm);
       width = 0;
       height = lptm.tmHeight;
     }
     if (newFont != 0) OS.SelectObject(hDC, oldFont);
     OS.ReleaseDC(handle, hDC);
   } else {
     int layoutWidth = layout.getWidth();
     // TEMPORARY CODE
     if (wHint == 0) {
       layout.setWidth(1);
       Rectangle rect = layout.getBounds();
       width = 0;
       height = rect.height;
     } else {
       layout.setWidth(wHint);
       Rectangle rect = layout.getBounds();
       width = rect.width;
       height = rect.height;
     }
     layout.setWidth(layoutWidth);
   }
   if (wHint != SWT.DEFAULT) width = wHint;
   if (hHint != SWT.DEFAULT) height = hHint;
   int border = getBorderWidth();
   width += border * 2;
   height += border * 2;
   return new Point(width, height);
 }
Exemple #4
0
  boolean mnemonicHit(char key) {
    if (mnemonics != null) {
      char uckey = Character.toUpperCase(key);
      String parsedText = parse(text);
      for (int i = 0; i < mnemonics.length - 1; i++) {
        if (mnemonics[i] != -1) {
          char mnemonic = parsedText.charAt(mnemonics[i]);
          if (uckey == Character.toUpperCase(mnemonic)) {
            if (!setFocus()) return false;
            if (OS.COMCTL32_MAJOR >= 6) {
              int bits = OS.GetWindowLong(handle, OS.GWL_STYLE);
              LITEM item = new LITEM();
              item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
              item.stateMask = OS.LIS_FOCUSED;
              while (item.iLink < mnemonics.length) {
                if (item.iLink != i) OS.SendMessage(handle, OS.LM_SETITEM, 0, item);
                item.iLink++;
              }
              item.iLink = i;
              item.state = OS.LIS_FOCUSED;
              OS.SendMessage(handle, OS.LM_SETITEM, 0, item);

              /* Feature in Windows. For some reason, setting the focus to
               * any item but first causes the control to clear the WS_TABSTOP
               * bit. The fix is always to reset the bit.
               */
              OS.SetWindowLong(handle, OS.GWL_STYLE, bits);
            } else {
              focusIndex = i;
              redraw();
            }
            return true;
          }
        }
      }
    }
    return false;
  }
Exemple #5
0
 int /*long*/ callWindowProc(
     int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) {
   if (handle == 0) return 0;
   if (LinkProc != 0) {
     /*
      * Feature in Windows.  By convention, native Windows controls
      * check for a non-NULL wParam, assume that it is an HDC and
      * paint using that device.  The SysLink control does not.
      * The fix is to check for an HDC and use WM_PRINTCLIENT.
      */
     switch (msg) {
       case OS.WM_PAINT:
         if (wParam != 0) {
           OS.SendMessage(hwnd, OS.WM_PRINTCLIENT, wParam, 0);
           return 0;
         }
         break;
     }
     return OS.CallWindowProc(LinkProc, hwnd, msg, wParam, lParam);
   }
   return OS.DefWindowProc(hwnd, msg, wParam, lParam);
 }