예제 #1
0
 // #{GxwCbkHost_
 public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) {
   boolean rv = true;
   int id = e.getID(), val = e.getKeyCode();
   boolean isAltF4 = false;
   if (e.isAltDown() && val == IptKey_.F4.Val()) {
     isAltF4 = true;
   }
   if (id == KeyEvent.KEY_TYPED) {
     IptEvtDataKeyHeld keyHeldData = IptEvtDataKeyHeld.char_(e.getKeyChar());
     rv = host.KeyHeldCbk(keyHeldData);
     if (keyHeldData.Handled()) rv = false;
   } else {
     if (e.isShiftDown()) val |= IptKey_.Shift.Val();
     if (e.isControlDown()) val |= IptKey_.Ctrl.Val();
     if (e.isAltDown()) val |= IptKey_.Alt.Val();
     IptEvtDataKey keyData = IptEvtDataKey.int_(val);
     //			Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id);
     if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData);
     else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData);
     if (keyData.Handled()) rv = false; // was false
   }
   if (isAltF4) {
     e.consume();
   }
   if (e.getKeyCode() == KeyEvent.VK_ALT)
     e.consume(); // force consume of alt-keys; occurs when alt-f4ing out of video app (though
   // not audio app)
   return rv;
 }
예제 #2
0
 public static final boolean ExecMouseEvent(GxwCbkHost host, MouseEvent e) {
   int button = e.getButton(), val = 0;
   if (button == MouseEvent.BUTTON1) val = IptMouseBtn_.Left.Val();
   if (button == MouseEvent.BUTTON2) val |= IptMouseBtn_.Middle.Val();
   if (button == MouseEvent.BUTTON3) val |= IptMouseBtn_.Right.Val();
   IptEvtDataMouse data =
       IptEvtDataMouse.new_(IptMouseBtn_.api_(val), IptMouseWheel_.None, e.getX(), e.getY());
   boolean rv = true;
   int id = e.getID();
   if (id == MouseEvent.MOUSE_PRESSED) rv = host.MouseDownCbk(data);
   else if (id == MouseEvent.MOUSE_RELEASED) rv = host.MouseUpCbk(data);
   return rv;
 }
예제 #3
0
 @Override
 public void paint(Graphics g) {
   if (host.PaintCbk(
       PaintArgs.new_(
           GfxAdpBase.new_((Graphics2D) g),
           RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
   super.paint(g);
 }
예제 #4
0
 @Override
 public void paint(Graphics g) {
   // always paint background color; must happen before any controlPaint; extract to separate
   // method if override needed
   Graphics2D g2 = (Graphics2D) g;
   g2.setBackground(this.getBackground());
   RectAdp clipRect = GxwCore_lang.XtoRectAdp(g2.getClipBounds());
   g2.clearRect(clipRect.X(), clipRect.Y(), clipRect.Width(), clipRect.Height());
   if (host.PaintCbk(
       PaintArgs.new_(
           GfxAdpBase.new_(g2),
           clipRect))) // ClipRect not used by any clients; implement when necessary
   super.paint(
         g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go
             // before PaintCbk (had issues with drawing text on images)
 }
예제 #5
0
 @Override
 public void processMouseMotionEvent(MouseEvent e) {
   if (host.MouseMoveCbk(
       IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY())))
     super.processMouseMotionEvent(e);
 }
예제 #6
0
 public void windowIconified(WindowEvent e) {
   host.SizeChangedCbk();
 }
예제 #7
0
 public void windowClosing(WindowEvent e) {
   host.DisposeCbk();
 }
예제 #8
0
 public static final boolean ExecMouseWheel(GxwCbkHost host, MouseWheelEvent e) {
   IptMouseWheel wheel = e.getWheelRotation() < 0 ? IptMouseWheel_.Up : IptMouseWheel_.Down;
   return host.MouseWheelCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, wheel, e.getX(), e.getY()));
 }