Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
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;
  }