Ejemplo n.º 1
0
 void selectRadio() {
   int index = 0;
   MenuItem[] items = parent.getItems();
   while (index < items.length && items[index] != this) index++;
   int i = index - 1;
   while (i >= 0 && items[i].setRadioSelection(false)) --i;
   int j = index + 1;
   while (j < items.length && items[j].setRadioSelection(false)) j++;
   setSelection(true);
 }
Ejemplo n.º 2
0
 LRESULT wmMeasureChild(long /*int*/ wParam, long /*int*/ lParam) {
   MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT();
   OS.MoveMemory(struct, lParam, MEASUREITEMSTRUCT.sizeof);
   int width = 0, height = 0;
   if (image != null) {
     Rectangle rect = image.getBounds();
     width = rect.width;
     height = rect.height;
   } else {
     /*
      * Bug in Windows.  If a menu contains items that have
      * images and can be checked, Windows does not include
      * the width of the image and the width of the check when
      * computing the width of the menu.  When the longest item
      * does not have an image, the label and the accelerator
      * text can overlap.  The fix is to use SetMenuItemInfo()
      * to indicate that all items have a bitmap and then include
      * the width of the widest bitmap in WM_MEASURECHILD.
      */
     MENUINFO lpcmi = new MENUINFO();
     lpcmi.cbSize = MENUINFO.sizeof;
     lpcmi.fMask = OS.MIM_STYLE;
     long /*int*/ hMenu = parent.handle;
     OS.GetMenuInfo(hMenu, lpcmi);
     if ((lpcmi.dwStyle & OS.MNS_CHECKORBMP) == 0) {
       MenuItem[] items = parent.getItems();
       for (int i = 0; i < items.length; i++) {
         MenuItem item = items[i];
         if (item.image != null) {
           Rectangle rect = item.image.getBounds();
           width = Math.max(width, rect.width);
         }
       }
     }
   }
   if (width != 0 || height != 0) {
     struct.itemWidth = width + MARGIN_WIDTH * 2;
     struct.itemHeight = height + MARGIN_HEIGHT * 2;
     OS.MoveMemory(lParam, struct, MEASUREITEMSTRUCT.sizeof);
   }
   return null;
 }