use of com.intellij.openapi.wm.ToolWindowAnchor in project intellij-community by JetBrains.
the class TestResultsPanel method splitVertically.
private boolean splitVertically() {
final String windowId = myProperties.getExecutor().getToolWindowId();
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProperties.getProject()).getToolWindow(windowId);
boolean splitVertically = false;
if (toolWindow != null) {
final ToolWindowAnchor anchor = toolWindow.getAnchor();
splitVertically = anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT;
}
return splitVertically;
}
use of com.intellij.openapi.wm.ToolWindowAnchor in project android by JetBrains.
the class FloatingToolWindow method createToolWindow.
private ToolWindowEx createToolWindow(@NotNull ToolWindowManager toolWindowManager, @NotNull ToolWindowDefinition<T> definition) {
String id = definition.getTitle();
ToolWindowEx window = (ToolWindowEx) toolWindowManager.getToolWindow(id);
if (window == null) {
ToolWindowAnchor anchor = definition.getSide().isLeft() ? ToolWindowAnchor.LEFT : ToolWindowAnchor.RIGHT;
window = (ToolWindowEx) toolWindowManager.registerToolWindow(id, false, anchor, this, true);
window.setIcon(definition.getIcon());
window.setType(ToolWindowType.FLOATING, null);
window.setAutoHide(false);
setToolWindowContent(window);
setAdditionalGearPopupActions(window);
setAdditionalActions(window);
}
return window;
}
use of com.intellij.openapi.wm.ToolWindowAnchor in project android by JetBrains.
the class FloatingToolWindow method updateState.
private void updateState(@NotNull AttachedToolWindow<T> correspondingWindow) {
myCorrespondingToolWindow = correspondingWindow;
ToolWindowAnchor anchor = correspondingWindow.isLeft() ? ToolWindowAnchor.LEFT : ToolWindowAnchor.RIGHT;
myToolWindow.setAnchor(anchor, null);
}
use of com.intellij.openapi.wm.ToolWindowAnchor in project intellij-community by JetBrains.
the class StripeButtonUI method paint.
public void paint(final Graphics g, final JComponent c) {
final AnchoredButton button = (AnchoredButton) c;
final String text = button.getText();
final Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
if ((icon == null) && (text == null)) {
return;
}
final FontMetrics fm = button.getFontMetrics(button.getFont());
ourViewInsets = c.getInsets(ourViewInsets);
ourViewRect.x = ourViewInsets.left;
ourViewRect.y = ourViewInsets.top;
final ToolWindowAnchor anchor = button.getAnchor();
// Use inverted height & width
if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) {
ourViewRect.height = c.getWidth() - (ourViewInsets.left + ourViewInsets.right);
ourViewRect.width = c.getHeight() - (ourViewInsets.top + ourViewInsets.bottom);
} else {
ourViewRect.height = c.getHeight() - (ourViewInsets.left + ourViewInsets.right);
ourViewRect.width = c.getWidth() - (ourViewInsets.top + ourViewInsets.bottom);
}
ourIconRect.x = ourIconRect.y = ourIconRect.width = ourIconRect.height = 0;
ourTextRect.x = ourTextRect.y = ourTextRect.width = ourTextRect.height = 0;
final String clippedText = SwingUtilities.layoutCompoundLabel(c, fm, text, icon, button.getVerticalAlignment(), button.getHorizontalAlignment(), button.getVerticalTextPosition(), button.getHorizontalTextPosition(), ourViewRect, ourIconRect, ourTextRect, button.getText() == null ? 0 : button.getIconTextGap());
// Paint button's background
final Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
final ButtonModel model = button.getModel();
final Color background = button.getBackground();
ourIconRect.x -= JBUI.scale(2);
ourTextRect.x -= JBUI.scale(2);
final int off = 1;
if (model.isArmed() && model.isPressed() || model.isSelected() || model.isRollover()) {
if (anchor == ToolWindowAnchor.LEFT)
g2.translate(-off, 0);
if (anchor.isHorizontal())
g2.translate(0, -off);
final boolean dark = UIUtil.isUnderDarcula();
g2.setColor(dark ? Gray._15.withAlpha(model.isSelected() ? 85 : 40) : Gray._85.withAlpha(model.isSelected() ? 85 : 40));
g2.fillRect(0, 0, button.getWidth(), button.getHeight());
if (anchor == ToolWindowAnchor.LEFT)
g2.translate(off, 0);
if (anchor.isHorizontal())
g2.translate(0, off);
}
AffineTransform tr = null;
if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) {
tr = g2.getTransform();
if (ToolWindowAnchor.RIGHT == anchor) {
if (icon != null) {
// do not rotate icon
//noinspection SuspiciousNameCombination
icon.paintIcon(c, g2, ourIconRect.y, ourIconRect.x);
}
g2.rotate(Math.PI / 2);
g2.translate(0, -c.getWidth());
} else {
if (icon != null) {
// do not rotate icon
//noinspection SuspiciousNameCombination
icon.paintIcon(c, g2, ourIconRect.y, c.getHeight() - ourIconRect.x - icon.getIconHeight());
}
g2.rotate(-Math.PI / 2);
g2.translate(-c.getHeight(), 0);
}
} else {
if (icon != null) {
icon.paintIcon(c, g2, ourIconRect.x, ourIconRect.y);
}
}
// paint text
UISettings.setupAntialiasing(g2);
if (text != null) {
if (model.isEnabled()) {
if (model.isArmed() && model.isPressed() || model.isSelected()) {
g2.setColor(background);
} else {
g2.setColor(button.getForeground());
}
} else {
g2.setColor(background.darker());
}
/* Draw the Text */
if (model.isEnabled()) {
/* paint the text normally */
g2.setColor(UIUtil.isUnderDarcula() && model.isSelected() ? button.getForeground().brighter() : button.getForeground());
BasicGraphicsUtils.drawString(g2, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent());
} else {
/* paint the text disabled ***/
if (model.isSelected()) {
g2.setColor(c.getBackground());
} else {
g2.setColor(getDisabledTextColor());
}
BasicGraphicsUtils.drawString(g2, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent());
}
}
if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) {
g2.setTransform(tr);
}
g2.dispose();
}
use of com.intellij.openapi.wm.ToolWindowAnchor in project intellij-community by JetBrains.
the class StripeButton method is.
private boolean is(boolean first) {
Container parent = getParent();
if (parent == null)
return false;
int max = first ? Integer.MAX_VALUE : 0;
ToolWindowAnchor anchor = getAnchor();
Component c = null;
int count = parent.getComponentCount();
for (int i = 0; i < count; i++) {
Component component = parent.getComponent(i);
if (!component.isVisible())
continue;
Rectangle r = component.getBounds();
if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
if (first && max > r.y || !first && max < r.y) {
max = r.y;
c = component;
}
} else {
if (first && max > r.x || !first && max < r.x) {
max = r.x;
c = component;
}
}
}
return c == this;
}
Aggregations