Java 类com.intellij.util.ui.MacUIUtil 实例源码

项目:tools-idea    文件:BackspaceAction.java   
@Override
public void executeWriteAction(Editor editor, DataContext dataContext) {
  MacUIUtil.hideCursor();
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  final SelectionModel selectionModel = editor.getSelectionModel();
  if (selectionModel.hasBlockSelection()) {
    final LogicalPosition start = selectionModel.getBlockStart();
    final LogicalPosition end = selectionModel.getBlockEnd();
    int column = Math.min(start.column, end.column);
    int startLine = Math.min(start.line, end.line);
    int endLine = Math.max(start.line, end.line);
    EditorModificationUtil.deleteBlockSelection(editor);
    if (column > 0 && start.column == end.column) {
      for (int i = startLine; i <= endLine; i++) {
        editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(i, column));
        doBackSpaceAtCaret(editor);
      }
      column--;
    }
    final int newColumn = Math.max(column, 0);
    selectionModel.setBlockSelection(new LogicalPosition(startLine, newColumn), new LogicalPosition(endLine, newColumn));
    return;
  }

  doBackSpaceAtCaret(editor);
}
项目:tools-idea    文件:EditorImpl.java   
private boolean processKeyTyped(char c) {
  // [vova] This is patch for Mac OS X. Under Mac "input methods"
  // is handled before our EventQueue consume upcoming KeyEvents.
  IdeEventQueue queue = IdeEventQueue.getInstance();
  if (queue.shouldNotTypeInEditor() || ProgressManager.getInstance().hasModalProgressIndicator()) {
    return false;
  }
  FileDocumentManager manager = FileDocumentManager.getInstance();
  if (manager != null) {
    final VirtualFile file = manager.getFile(myDocument);
    if (file != null && !file.isValid()) {
      return false;
    }
  }

  ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
  DataContext dataContext = getDataContext();
  actionManager.fireBeforeEditorTyping(c, dataContext);
  MacUIUtil.hideCursor();
  EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext);

  return true;
}
项目:intellij-ce-playground    文件:ComboBox.java   
@Override
public void paint(Graphics g) {
  try {
    myPaintingNow = true;
    super.paint(g);
    if (Boolean.TRUE != getClientProperty("JComboBox.isTableCellEditor") && isEditable) MacUIUtil.drawComboboxFocusRing(this, g);
  } finally {
    myPaintingNow = false;
  }
}
项目:intellij-ce-playground    文件:CommonActionsPanel.java   
@Override
protected void paintComponent(Graphics g2) {
  final Graphics2D g = (Graphics2D)g2;
  if (myDecorateButtons) {
    MacUIUtil.drawToolbarDecoratorBackground(g, getWidth(), getHeight());
  } else {
    super.paintComponent(g);
  }
}
项目:intellij-ce-playground    文件:BackspaceAction.java   
@Override
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
  MacUIUtil.hideCursor();
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  if (editor instanceof EditorWindow) {
    // manipulate actual document/editor instead of injected
    // since the latter have trouble finding the right location of caret movement in the case of multi-shred injected fragments
    editor = ((EditorWindow)editor).getDelegate();
  }
  doBackSpaceAtCaret(editor);
}
项目:intellij-ce-playground    文件:DeleteAction.java   
@Override
public void executeWriteAction(Editor editor, DataContext dataContext) {
  MacUIUtil.hideCursor();
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  CopyPasteManager.getInstance().stopKillRings();
  SelectionModel selectionModel = editor.getSelectionModel();
  if (!selectionModel.hasSelection()) {
    deleteCharAtCaret(editor);
  }
  else {
    EditorModificationUtil.deleteSelectedText(editor);
  }
}
项目:tools-idea    文件:CommonActionsPanel.java   
@Override
protected void paintComponent(Graphics g2) {
  final Graphics2D g = (Graphics2D)g2;
  if (myDecorateButtons) {
    MacUIUtil.drawToolbarDecoratorBackground(g, getWidth(), getHeight());
  } else {
    super.paintComponent(g);
  }
}
项目:tools-idea    文件:DarculaUIUtil.java   
public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds) {
  int correction = UIUtil.isUnderDarcula() ? 50 : 0;
  final Color[] colors = new Color[]{
    ColorUtil.toAlpha(GLOW_COLOR, 180 - correction),
    ColorUtil.toAlpha(GLOW_COLOR, 120 - correction),
    ColorUtil.toAlpha(GLOW_COLOR, 70  - correction),
    ColorUtil.toAlpha(GLOW_COLOR, 100 - correction),
    ColorUtil.toAlpha(GLOW_COLOR, 50  - correction)
  };

  final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);


  final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);

  g.setColor(colors[0]);
  g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, r.height - 5, r.height - 5);

  g.setColor(colors[1]);
  g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, r.height - 3, r.height - 3);

  g.setColor(colors[2]);
  g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, r.height - 1, r.height - 1);


  g.setColor(colors[3]);
  g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, r.height - 7, r.height - 7);

  g.setColor(colors[4]);
  g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, r.height - 9, r.height - 9);

  // restore rendering hints
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
}
项目:consulo    文件:ComboBox.java   
@Override
public void paint(Graphics g) {
  try {
    myPaintingNow = true;
    super.paint(g);
    if (Boolean.TRUE != getClientProperty("JComboBox.isTableCellEditor")) MacUIUtil.drawComboboxFocusRing(this, g);
  } finally {
    myPaintingNow = false;
  }
}
项目:consulo    文件:CommonActionsPanel.java   
@Override
protected void paintComponent(Graphics g2) {
  final Graphics2D g = (Graphics2D)g2;
  if (myDecorateButtons) {
    MacUIUtil.drawToolbarDecoratorBackground(g, getWidth(), getHeight());
  } else {
    super.paintComponent(g);
  }
}
项目:consulo    文件:EditorUIUtil.java   
public static void hideCursorInEditor(Editor editor) {
  if (SystemInfo.isMac) {
    MacUIUtil.hideCursor();
  }
  else if (editor instanceof EditorImpl) {
    ((EditorImpl)editor).hideCursor();
  }
}
项目:consulo    文件:BackspaceAction.java   
@RequiredWriteAction
@Override
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
  MacUIUtil.hideCursor();
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  if (editor instanceof EditorWindow) {
    // manipulate actual document/editor instead of injected
    // since the latter have trouble finding the right location of caret movement in the case of multi-shred injected fragments
    editor = ((EditorWindow)editor).getDelegate();
  }
  doBackSpaceAtCaret(editor);
}
项目:consulo    文件:DeleteAction.java   
@RequiredWriteAction
@Override
public void executeWriteAction(Editor editor, DataContext dataContext) {
  MacUIUtil.hideCursor();
  CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
  CopyPasteManager.getInstance().stopKillRings();
  SelectionModel selectionModel = editor.getSelectionModel();
  if (!selectionModel.hasSelection()) {
    deleteCharAtCaret(editor);
  }
  else {
    EditorModificationUtil.deleteSelectedText(editor);
  }
}
项目:consulo    文件:MacIntelliJTextFieldUI.java   
public static void paintAquaSearchFocusRing(Graphics2D g, Rectangle r, Component c) {
  Graphics2D g2 = (Graphics2D)g.create();
  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.translate(r.x, r.y);

    int arc = JBUI.scale(6);
    double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
    Shape outerShape = new RoundRectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
                                                   r.width - JBUI.scale(6),
                                                   r.height - JBUI.scale(6),
                                                   arc, arc);
    g2.setColor(c.getBackground());
    g2.fill(outerShape);

    Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
    path.append(outerShape, false);
    path.append(new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
                                            r.width - JBUI.scale(6) - lw*2,
                                            r.height - JBUI.scale(6) - lw*2,
                                            arc-lw, arc-lw), false);

    g2.setColor(Gray.xBC);
    g2.fill(path);

    if (c.hasFocus()) {
      DarculaUIUtil.paintFocusBorder(g2, r.width, r.height, arc, true);
    }
  }
  finally {
    g2.dispose();
  }
}
项目:consulo    文件:DarculaUIUtil.java   
@SuppressWarnings("SuspiciousNameCombination")
private static void doPaint(Graphics2D g, int width, int height, int arc, boolean symmetric) {
  double bw = UIUtil.isRetina(g) ? 0.5 : 1.0;
  double lw = JBUI.scale(UIUtil.isUnderDefaultMacTheme() ? 3 : 2);

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

  double outerArc = arc > 0 ? arc + lw - JBUI.scale(2) : lw;
  double rightOuterArc = symmetric ? outerArc : JBUI.scale(6);
  Path2D outerRect = new Path2D.Double(Path2D.WIND_EVEN_ODD);
  outerRect.moveTo(width - rightOuterArc, 0);
  outerRect.quadTo(width, 0, width, rightOuterArc);
  outerRect.lineTo(width, height - rightOuterArc);
  outerRect.quadTo(width, height, width - rightOuterArc, height);
  outerRect.lineTo(outerArc, height);
  outerRect.quadTo(0, height, 0, height - outerArc);
  outerRect.lineTo(0, outerArc);
  outerRect.quadTo(0, 0, outerArc, 0);
  outerRect.closePath();

  lw += bw;
  double rightInnerArc = symmetric ? outerArc : JBUI.scale(7);
  Path2D innerRect = new Path2D.Double(Path2D.WIND_EVEN_ODD);
  innerRect.moveTo(width - rightInnerArc, lw);
  innerRect.quadTo(width - lw, lw, width - lw, rightInnerArc);
  innerRect.lineTo(width - lw, height - rightInnerArc);
  innerRect.quadTo(width - lw, height - lw, width - rightInnerArc, height - lw);
  innerRect.lineTo(outerArc, height - lw);
  innerRect.quadTo(lw, height - lw, lw, height - outerArc);
  innerRect.lineTo(lw, outerArc);
  innerRect.quadTo(lw, lw, outerArc, lw);
  innerRect.closePath();

  Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
  path.append(outerRect, false);
  path.append(innerRect, false);
  g.fill(path);
}
项目:intellij-ce-playground    文件:FixedComboBoxEditor.java   
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  Color topColor;
  Color secondTopColor;
  Color leftRightColor;
  Color bottomColor;

  if (myDisabled) {
    topColor = Gray._200;
    secondTopColor = Gray._250;
    leftRightColor = Gray._205;
    bottomColor = Gray._220;
  }
  else {
    topColor = Gray._150;
    secondTopColor = Gray._230;
    leftRightColor = Gray._175;
    bottomColor = Gray._200;
  }

  int _y = y + MacUIUtil.MAC_COMBO_BORDER_V_OFFSET;

  g.setColor(topColor);
  g.drawLine(x + 3, _y + 3, x + width - 1, _y + 3);

  g.setColor(secondTopColor);
  g.drawLine(x + 3, _y + 4, x + width - 1, _y + 4);

  g.setColor(leftRightColor);
  g.drawLine(x + 3, _y + 4, x + 3, _y + height - 4);
  g.drawLine(x + width - 1, _y + 4, x + width - 1, _y + height - 4);

  g.setColor(bottomColor);
  g.drawLine(x + 4, _y + height - 4, x + width - 2, _y + height - 4);

  g.setColor(UIUtil.getPanelBackground());

  g.fillRect(x,  y, width, 3 + (SystemInfo.isMacOSLion ? 1 : 0));
  g.fillRect(x, _y, 3, height);
  g.fillRect(x, _y + height - 3, width, 3);
}
项目:intellij-ce-playground    文件:JBDefaultTreeCellRenderer.java   
public JBDefaultTreeCellRenderer(@NotNull final JTree tree) {
  MacUIUtil.doNotFillBackground(tree, this);
  myMacTreeUI = tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection();
}
项目:intellij-ce-playground    文件:TabAction.java   
private static void insertTabAtCaret(Editor editor, @NotNull Caret caret, @Nullable Project project) {
  MacUIUtil.hideCursor();
  int columnNumber;
  if (caret.hasSelection()) {
    columnNumber = editor.visualToLogicalPosition(caret.getSelectionStartPosition()).column;
  }
  else {
    columnNumber = editor.getCaretModel().getLogicalPosition().column;
  }

  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);

  final Document doc = editor.getDocument();
  CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptionsByDocument(project, doc);

  int tabSize = indentOptions.INDENT_SIZE;
  int spacesToAddCount = tabSize - columnNumber % Math.max(1,tabSize);

  boolean useTab = editor.getSettings().isUseTabCharacter(project);

  CharSequence chars = doc.getCharsSequence();
  if (useTab && indentOptions.SMART_TABS) {
    int offset = editor.getCaretModel().getOffset();
    while (offset > 0) {
      offset--;
      if (chars.charAt(offset) == '\t') continue;
      if (chars.charAt(offset) == '\n') break;
      useTab = false;
      break;
    }
  }

  doc.startGuardedBlockChecking();
  try {
    if(useTab) {
      EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, "\t", false);
    }
    else {
      EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, StringUtil.repeatSymbol(' ', spacesToAddCount), false);
    }
  }
  catch (ReadOnlyFragmentModificationException e) {
    EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
  }
  finally {
    doc.stopGuardedBlockChecking();
  }
}
项目:intellij-ce-playground    文件:EnterAction.java   
public static void insertNewLineAtCaret(Editor editor) {
  MacUIUtil.hideCursor();
  Document document = editor.getDocument();
  int caretLine = editor.getCaretModel().getLogicalPosition().line;
  if(!editor.isInsertMode()) {
    int lineCount = document.getLineCount();
    if(caretLine < lineCount) {
      if (caretLine == lineCount - 1) {
        document.insertString(document.getTextLength(), "\n");
      }
      LogicalPosition pos = new LogicalPosition(caretLine + 1, 0);
      editor.getCaretModel().moveToLogicalPosition(pos);
      editor.getSelectionModel().removeSelection();
      EditorModificationUtil.scrollToCaret(editor);
    }
    return;
  }
  EditorModificationUtil.deleteSelectedText(editor);
  // Smart indenting here:
  CharSequence text = document.getCharsSequence();

  int indentLineNum = caretLine;
  int lineLength = 0;
  if (document.getLineCount() > 0) {
    for(;indentLineNum >= 0; indentLineNum--) {
      lineLength = document.getLineEndOffset(indentLineNum) - document.getLineStartOffset(indentLineNum);
      if(lineLength > 0)
        break;
    }
  } else {
    indentLineNum = -1;
  }

  int colNumber = editor.getCaretModel().getLogicalPosition().column;
  StringBuilder buf = new StringBuilder();
  if(indentLineNum >= 0) {
    int lineStartOffset = document.getLineStartOffset(indentLineNum);
    for(int i = 0; i < lineLength; i++) {
      char c = text.charAt(lineStartOffset + i);
      if(c != ' ' && c != '\t') {
        break;
      }
      if(i >= colNumber) {
        break;
      }
      buf.append(c);
    }
  }
  int caretOffset = editor.getCaretModel().getOffset();
  String s = "\n"+buf;
  document.insertString(caretOffset, s);
  editor.getCaretModel().moveToOffset(caretOffset + s.length());
  EditorModificationUtil.scrollToCaret(editor);
  editor.getSelectionModel().removeSelection();
}
项目:intellij-ce-playground    文件:EditorComboBox.java   
@Override
public void paint(Graphics g) {
  super.paint(g);

  MacUIUtil.drawComboboxFocusRing(this, g);
}
项目:intellij-ce-playground    文件:DarculaUIUtil.java   
public static void paintFocusRing(Graphics g, int x, int y, int width, int height) {
  MacUIUtil.paintFocusRing((Graphics2D)g, getGlow(), new Rectangle(x, y, width, height));
}
项目:intellij-ce-playground    文件:DarculaUIUtil.java   
public static void paintFocusOval(Graphics g, int x, int y, int width, int height) {
  MacUIUtil.paintFocusRing((Graphics2D)g, getGlow(), new Rectangle(x, y, width, height), true);
}
项目:intellij-ce-playground    文件:DarculaUIUtil.java   
public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds, int maxArcSize) {
  int correction = UIUtil.isUnderAquaLookAndFeel() ? 30 : UIUtil.isUnderDarcula() ? 50 : 0;
  final Color[] colors = new Color[]{
    ColorUtil.toAlpha(getGlow(), 180 - correction),
    ColorUtil.toAlpha(getGlow(), 120 - correction),
    ColorUtil.toAlpha(getGlow(), 70  - correction),
    ColorUtil.toAlpha(getGlow(), 100 - correction),
    ColorUtil.toAlpha(getGlow(), 50  - correction)
  };

  final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);


  final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);
  int arcSize = r.height - 1;
  if (maxArcSize>0) arcSize = Math.min(maxArcSize, arcSize);
  if (arcSize %2 == 1) arcSize--;


  g.setColor(colors[0]);
  g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize-4, arcSize-4);

  g.setColor(colors[1]);
  g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, arcSize-2, arcSize-2);

  g.setColor(colors[2]);
  g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, arcSize, arcSize);


  g.setColor(colors[3]);
  g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, arcSize-6, arcSize-6);

  g.setColor(colors[4]);
  g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, arcSize-8, arcSize-8);

  // restore rendering hints
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
}
项目:intellij-ce-playground    文件:GradleEditorComboBoxEditor.java   
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  Color topColor;
  Color secondTopColor;
  Color leftRightColor;
  Color bottomColor;

  if (myDisabled) {
    topColor = Gray._200;
    secondTopColor = Gray._250;
    leftRightColor = Gray._205;
    bottomColor = Gray._220;
  }
  else {
    topColor = Gray._150;
    secondTopColor = Gray._230;
    leftRightColor = Gray._175;
    bottomColor = Gray._200;
  }

  int _y = y + MacUIUtil.MAC_COMBO_BORDER_V_OFFSET;

  g.setColor(topColor);
  g.drawLine(x + 3, _y + 3, x + width - 1, _y + 3);

  g.setColor(secondTopColor);
  g.drawLine(x + 3, _y + 4, x + width - 1, _y + 4);

  g.setColor(leftRightColor);
  g.drawLine(x + 3, _y + 4, x + 3, _y + height - 4);
  g.drawLine(x + width - 1, _y + 4, x + width - 1, _y + height - 4);

  g.setColor(bottomColor);
  g.drawLine(x + 4, _y + height - 4, x + width - 2, _y + height - 4);

  g.setColor(GradleEditorUiConstants.BACKGROUND_COLOR);

  g.fillRect(x,  y, width, 3 + (SystemInfo.isMacOSLion ? 1 : 0));
  g.fillRect(x, _y, 3, height);
  g.fillRect(x, _y + height - 3, width, 3);
}
项目:tools-idea    文件:ComboBox.java   
@Override
public void paint(Graphics g) {
  super.paint(g);
  if (Boolean.TRUE != getClientProperty("JComboBox.isTableCellEditor")) MacUIUtil.drawComboboxFocusRing(this, g);
}
项目:tools-idea    文件:FixedComboBoxEditor.java   
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  Color topColor;
  Color secondTopColor;
  Color leftRightColor;
  Color bottomColor;

  if (myDisabled) {
    topColor = Gray._200;
    secondTopColor = Gray._250;
    leftRightColor = Gray._205;
    bottomColor = Gray._220;
  }
  else {
    topColor = Gray._150;
    secondTopColor = Gray._230;
    leftRightColor = Gray._175;
    bottomColor = Gray._200;
  }

  int _y = y + MacUIUtil.MAC_COMBO_BORDER_V_OFFSET;

  g.setColor(topColor);
  g.drawLine(x + 3, _y + 3, x + width - 1, _y + 3);

  g.setColor(secondTopColor);
  g.drawLine(x + 3, _y + 4, x + width - 1, _y + 4);

  g.setColor(leftRightColor);
  g.drawLine(x + 3, _y + 4, x + 3, _y + height - 4);
  g.drawLine(x + width - 1, _y + 4, x + width - 1, _y + height - 4);

  g.setColor(bottomColor);
  g.drawLine(x + 4, _y + height - 4, x + width - 2, _y + height - 4);

  g.setColor(UIUtil.getPanelBackground());

  g.fillRect(x,  y, width, 3 + (SystemInfo.isMacOSLion ? 1 : 0));
  g.fillRect(x, _y, 3, height);
  g.fillRect(x, _y + height - 3, width, 3);
}
项目:tools-idea    文件:JBDefaultTreeCellRenderer.java   
public JBDefaultTreeCellRenderer(@NotNull final JTree tree) {
  MacUIUtil.doNotFillBackground(tree, this);
  myMacTreeUI = tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection();
}
项目:tools-idea    文件:TabAction.java   
private static void insertTabAtCaret(Editor editor, Project project) {
  MacUIUtil.hideCursor();
  int columnNumber = editor.getCaretModel().getLogicalPosition().column;

  CodeStyleFacade settings = CodeStyleFacade.getInstance(project);

  final Document doc = editor.getDocument();
  VirtualFile vFile = FileDocumentManager.getInstance().getFile(doc);
  final FileType fileType = vFile == null ? null : vFile.getFileType();

  int tabSize = settings.getIndentSize(fileType);
  int spacesToAddCount = tabSize - columnNumber % Math.max(1,tabSize);

  boolean useTab = editor.getSettings().isUseTabCharacter(project);

  CharSequence chars = doc.getCharsSequence();
  if (useTab && settings.isSmartTabs(fileType)) {
    int offset = editor.getCaretModel().getOffset();
    while (offset > 0) {
      offset--;
      if (chars.charAt(offset) == '\t') continue;
      if (chars.charAt(offset) == '\n') break;
      useTab = false;
      break;
    }
  }

  doc.startGuardedBlockChecking();
  try {
    if(useTab) {
      EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, "\t", false);
    }
    else {
      EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, StringUtil.repeatSymbol(' ', spacesToAddCount), false);
    }
  }
  catch (ReadOnlyFragmentModificationException e) {
    EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
  }
  finally {
    doc.stopGuardedBlockChecking();
  }
}
项目:tools-idea    文件:EnterAction.java   
public static void insertNewLineAtCaret(Editor editor) {
  MacUIUtil.hideCursor();
  if(!editor.isInsertMode()) {
    if(editor.getCaretModel().getLogicalPosition().line < editor.getDocument().getLineCount()-1) {
      LogicalPosition pos = new LogicalPosition(editor.getCaretModel().getLogicalPosition().line+1, 0);
      editor.getCaretModel().moveToLogicalPosition(pos);
      editor.getSelectionModel().removeSelection();
      editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    }
    return;
  }
  EditorModificationUtil.deleteSelectedText(editor);
  // Smart indenting here:
  Document document = editor.getDocument();
  CharSequence text = document.getCharsSequence();

  int indentLineNum = editor.getCaretModel().getLogicalPosition().line;
  int lineLength = 0;
  if (document.getLineCount() > 0) {
    for(;indentLineNum >= 0; indentLineNum--) {
      lineLength = document.getLineEndOffset(indentLineNum) - document.getLineStartOffset(indentLineNum);
      if(lineLength > 0)
        break;
    }
  } else {
    indentLineNum = -1;
  }

  int colNumber = editor.getCaretModel().getLogicalPosition().column;
  StringBuilder buf = new StringBuilder();
  if(indentLineNum >= 0) {
    int lineStartOffset = document.getLineStartOffset(indentLineNum);
    for(int i = 0; i < lineLength; i++) {
      char c = text.charAt(lineStartOffset + i);
      if(c != ' ' && c != '\t') {
        break;
      }
      if(i >= colNumber) {
        break;
      }
      buf.append(c);
    }
  }
  int caretOffset = editor.getCaretModel().getOffset();
  String s = "\n"+buf;
  document.insertString(caretOffset, s);
  editor.getCaretModel().moveToOffset(caretOffset + s.length());
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  editor.getSelectionModel().removeSelection();
}
项目:tools-idea    文件:EditorComboBox.java   
@Override
public void paint(Graphics g) {
  super.paint(g);

  MacUIUtil.drawComboboxFocusRing(this, g);
}
项目:tools-idea    文件:DarculaUIUtil.java   
public static void paintFocusRing(Graphics g, int x, int y, int width, int height) {
  MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height));
}
项目:tools-idea    文件:DarculaUIUtil.java   
public static void paintFocusOval(Graphics g, int x, int y, int width, int height) {
  MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height), true);
}
项目:consulo    文件:FixedComboBoxEditor.java   
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  Color topColor;
  Color secondTopColor;
  Color leftRightColor;
  Color bottomColor;

  if (myDisabled) {
    topColor = Gray._200;
    secondTopColor = Gray._250;
    leftRightColor = Gray._205;
    bottomColor = Gray._220;
  }
  else {
    topColor = Gray._150;
    secondTopColor = Gray._230;
    leftRightColor = Gray._175;
    bottomColor = Gray._200;
  }

  int _y = y + MacUIUtil.MAC_COMBO_BORDER_V_OFFSET;

  g.setColor(topColor);
  g.drawLine(x + 3, _y + 3, x + width - 1, _y + 3);

  g.setColor(secondTopColor);
  g.drawLine(x + 3, _y + 4, x + width - 1, _y + 4);

  g.setColor(leftRightColor);
  g.drawLine(x + 3, _y + 4, x + 3, _y + height - 4);
  g.drawLine(x + width - 1, _y + 4, x + width - 1, _y + height - 4);

  g.setColor(bottomColor);
  g.drawLine(x + 4, _y + height - 4, x + width - 2, _y + height - 4);

  g.setColor(UIUtil.getPanelBackground());

  g.fillRect(x,  y, width, 3 + (SystemInfo.isMacOSLion ? 1 : 0));
  g.fillRect(x, _y, 3, height);
  g.fillRect(x, _y + height - 3, width, 3);
}
项目:consulo    文件:JBDefaultTreeCellRenderer.java   
public JBDefaultTreeCellRenderer(@Nonnull final JTree tree) {
  MacUIUtil.doNotFillBackground(tree, this);
  myMacTreeUI = tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection();
}
项目:consulo    文件:EditorComboBox.java   
@Override
public void paint(Graphics g) {
  super.paint(g);

  MacUIUtil.drawComboboxFocusRing(this, g);
}
项目:consulo    文件:MacIntelliJTextFieldUI.java   
protected void paintSearchField(Graphics2D g, JTextComponent c, Rectangle r) {
  Graphics2D g2 = (Graphics2D)g.create();
  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.translate(r.x, r.y);

    int arc = JBUI.scale(6);
    double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
    Shape outerShape = new RoundRectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
                                                   r.width - JBUI.scale(6),
                                                   r.height - JBUI.scale(6),
                                                   arc, arc);
    g2.setColor(c.getBackground());
    g2.fill(outerShape);

    Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
    path.append(outerShape, false);
    path.append(new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
                                            r.width - JBUI.scale(6) - lw*2,
                                            r.height - JBUI.scale(6) - lw*2,
                                            arc-lw, arc-lw), false);

    g2.setColor(Gray.xBC);
    g2.fill(path);

    if (c.hasFocus() && c.getClientProperty("JTextField.Search.noBorderRing") != Boolean.TRUE) {
      DarculaUIUtil.paintFocusBorder(g2, r.width, r.height, arc, true);
    }

    g2.translate(-r.x, -r.y);

    boolean withHistoryPopup = isSearchFieldWithHistoryPopup(c);
    Icon label = getSearchIcon(c);
    boolean isEmpty = !hasText();
    Point point = getSearchIconCoord();
    if (isEmpty && !c.hasFocus() && !withHistoryPopup) {
      label.paintIcon(c, g2, point.x, point.y);
    } else {
      Graphics ig = g2.create(0, 0, c.getWidth(), c.getHeight());

      Area area = new Area(new Rectangle2D.Double(point.x, point.y, isEmpty ? label.getIconWidth() : 16, label.getIconHeight()));
      area.intersect(new Area(ig.getClip()));
      ig.setClip(area);
      label.paintIcon(c, ig, point.x, point.y);
      ig.dispose();
    }

    if (!isEmpty) {
      Point ic = getClearIconCoord();
      IconCache.getIcon("searchFieldClear").paintIcon(c, g2, ic.x, ic.y);
    }

    AbstractAction newLineAction = getNewLineAction(c);
    if (newLineAction != null) {
      Icon newLineIcon = (Icon)newLineAction.getValue(Action.SMALL_ICON);
      if (newLineIcon != null) {
        newLineIcon.paintIcon(c, g2, getAddNewLineIconCoord().x, r.y);
      }
    }
  } finally {
    g2.dispose();
  }
}
项目:consulo    文件:DarculaUIUtil.java   
public static void paintFocusRing(Graphics g, Rectangle bounds) {
  MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, bounds);
}
项目:consulo    文件:DarculaUIUtil.java   
public static void paintFocusOval(Graphics g, int x, int y, int width, int height) {
  MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height), true);
}
项目:consulo    文件:DarculaUIUtil.java   
public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds, Component component, int maxArcSize) {
  int correction = UIUtil.isUnderAquaLookAndFeel() ? 30 : UIUtil.isUnderDarcula() ? 50 : 0;
  final Color[] colors = new Color[]{
          ColorUtil.toAlpha(GLOW_COLOR, 180 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 120 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 70  - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 100 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 50  - correction)
  };

  final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);


  final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);
  int arcSize = r.height - 1;
  if (maxArcSize>0) arcSize = Math.min(maxArcSize, arcSize);
  if (arcSize %2 == 1) arcSize--;


  g.setColor(component.getBackground());
  g.fillRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize - 4, arcSize - 4);

  g.setColor(colors[0]);
  g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize-4, arcSize-4);

  g.setColor(colors[1]);
  g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, arcSize-2, arcSize-2);

  g.setColor(colors[2]);
  g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, arcSize, arcSize);


  g.setColor(colors[3]);
  g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, arcSize-6, arcSize-6);

  g.setColor(colors[4]);
  g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, arcSize-8, arcSize-8);

  // restore rendering hints
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
}