Browse Source
Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x * commit '83d78aaa9136f8101c3cb92f268070e4e36197f9': REPORT-65989 frm报表块内10.0模板在11.0设计器打开后无法使用鼠标滚轮滑动feature/x
starryi
3 years ago
4 changed files with 156 additions and 36 deletions
@ -0,0 +1,79 @@ |
|||||||
|
package com.fr.design.mainframe.form; |
||||||
|
|
||||||
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
||||||
|
import com.fr.design.mainframe.DesignerScaleMouseWheelHandler; |
||||||
|
import com.fr.design.mainframe.DesignerTranslateMouseWheelHandler; |
||||||
|
import com.fr.design.mainframe.JFormSliderPane; |
||||||
|
import com.fr.design.mainframe.ReportComponentComposite; |
||||||
|
|
||||||
|
import javax.swing.JScrollBar; |
||||||
|
import javax.swing.JViewport; |
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
import java.awt.event.MouseWheelListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/9/24 |
||||||
|
*/ |
||||||
|
public class FormReportComponentCompositeMouseWheelHandler implements MouseWheelListener { |
||||||
|
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler; |
||||||
|
private final DesignerScaleMouseWheelHandler scaleMouseWheelHandler; |
||||||
|
|
||||||
|
public FormReportComponentCompositeMouseWheelHandler(FormReportComponentComposite componentComposite) { |
||||||
|
translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new ScrollPaneAdapter(componentComposite)); |
||||||
|
scaleMouseWheelHandler = new DesignerScaleMouseWheelHandler(new ScalePaneAdapter(componentComposite), ReportComponentComposite.DIR); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) { |
||||||
|
if (InputEventBaseOnOS.isControlDown(e)) { |
||||||
|
scaleMouseWheelHandler.mouseWheelMoved(e); |
||||||
|
} else { |
||||||
|
translateMouseWheelHandler.mouseWheelMoved(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class ScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane { |
||||||
|
private final FormReportComponentComposite componentComposite; |
||||||
|
private JViewport viewport; |
||||||
|
|
||||||
|
public ScrollPaneAdapter(FormReportComponentComposite componentComposite) { |
||||||
|
this.componentComposite = componentComposite; |
||||||
|
this.viewport = new JViewport(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isWheelScrollingEnabled() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getVerticalScrollBar() { |
||||||
|
return componentComposite.elementCaseDesigner.getVerticalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getHorizontalScrollBar() { |
||||||
|
return componentComposite.elementCaseDesigner.getHorizontalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JViewport getViewport() { |
||||||
|
return viewport; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class ScalePaneAdapter implements DesignerScaleMouseWheelHandler.ScalePane { |
||||||
|
private final FormReportComponentComposite componentComposite; |
||||||
|
|
||||||
|
public ScalePaneAdapter(FormReportComponentComposite componentComposite) { |
||||||
|
this.componentComposite = componentComposite; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JFormSliderPane getSlidePane() { |
||||||
|
return componentComposite.getSliderContainer(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
package com.fr.design.share.ui.effect; |
||||||
|
|
||||||
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
||||||
|
import com.fr.design.mainframe.DesignerTranslateMouseWheelHandler; |
||||||
|
|
||||||
|
import javax.swing.JScrollBar; |
||||||
|
import javax.swing.JViewport; |
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
import java.awt.event.MouseWheelListener; |
||||||
|
|
||||||
|
import static com.fr.design.share.ui.effect.PreviewPane.SCALE_CURSOR; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/9/24 |
||||||
|
*/ |
||||||
|
public class PreviewPaneMouseWheelHandler implements MouseWheelListener { |
||||||
|
private static final int DIR = 10; |
||||||
|
|
||||||
|
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler; |
||||||
|
private final PreviewPane previewPane; |
||||||
|
|
||||||
|
public PreviewPaneMouseWheelHandler(PreviewPane previewPane) { |
||||||
|
this.translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new PreviewPaneScrollPaneAdapter(previewPane)); |
||||||
|
this.previewPane = previewPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) { |
||||||
|
if (InputEventBaseOnOS.isControlDown(e)) { |
||||||
|
int dir = e.getWheelRotation(); |
||||||
|
previewPane.addScale( - dir * DIR); |
||||||
|
previewPane.getElementCasePane().getGrid().setCursor(SCALE_CURSOR); |
||||||
|
} else { |
||||||
|
translateMouseWheelHandler.mouseWheelMoved(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class PreviewPaneScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane { |
||||||
|
private final PreviewPane previewPane; |
||||||
|
private final JViewport viewport; |
||||||
|
|
||||||
|
public PreviewPaneScrollPaneAdapter(PreviewPane previewPane) { |
||||||
|
this.previewPane = previewPane; |
||||||
|
this.viewport = new JViewport(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isWheelScrollingEnabled() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getVerticalScrollBar() { |
||||||
|
return previewPane.getElementCasePane().getVerticalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getHorizontalScrollBar() { |
||||||
|
return previewPane.getElementCasePane().getHorizontalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JViewport getViewport() { |
||||||
|
return this.viewport; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue