コード例 #1
0
 /**
  * Calculates the proper trim for the ruler.
  *
  * @param canvas The canvas.
  * @since 3.6
  */
 public static Rectangle calculateRulerTrim(Composite canvas) {
   // IMPORTANT: As stated in bug #314750, this is a Mac Carbon related
   // workaround that is not needed on Cocoa.
   if ("carbon".equals(SWT.getPlatform())) { // $NON-NLS-1$
     Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
     trim.width = 0 - trim.x * 2;
     trim.height = 0 - trim.y * 2;
     return trim;
   }
   return new Rectangle(0, 0, 0, 0);
 }
コード例 #2
0
 /**
  * Calculates the proper trim. Includes scrollbars' sizes only if they're visible.
  *
  * @param canvas The canvas.
  * @since 3.6
  */
 public static Rectangle calculateEditorTrim(Composite canvas) {
   /*
    * Workaround for Bug# 87712 Calculating the trim using the clientArea.
    */
   Rectangle bounds = canvas.getBounds();
   Rectangle clientArea = canvas.getClientArea();
   Rectangle result =
       new Rectangle(0, 0, bounds.width - clientArea.width, bounds.height - clientArea.height);
   if (result.width != 0 || result.height != 0) {
     Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
     result.x = result.height == 0 ? 0 : trim.x;
     result.y = result.width == 0 ? 0 : trim.y;
   }
   return result;
 }