コード例 #1
0
 @Override
 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;
   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);
 }
コード例 #2
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);
 }
コード例 #3
0
 @Override
 int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
   int result = super.setBounds(x, y, width, height, move, resize);
   if ((result & RESIZED) != 0) {
     layout.setWidth(width > 0 ? width : -1);
     redraw();
   }
   return result;
 }
コード例 #4
0
 LRESULT WM_SIZE(int /*long*/ wParam, int /*long*/ lParam) {
   LRESULT result = super.WM_SIZE(wParam, lParam);
   if (OS.COMCTL32_MAJOR < 6) {
     RECT rect = new RECT();
     OS.GetClientRect(handle, rect);
     layout.setWidth(rect.right > 0 ? rect.right : -1);
     redraw();
   }
   return result;
 }