Package quicktime.app.view

Source Code of quicktime.app.view.QTJavaCocoaCanvas

/*     */ package quicktime.app.view;
/*     */
/*     */ import com.apple.eawt.CocoaComponent;
/*     */ import java.applet.Applet;
/*     */ import java.awt.Component;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Frame;
/*     */ import java.awt.Point;
/*     */ import java.awt.Window;
/*     */ import java.awt.event.KeyEvent;
/*     */ import java.awt.event.KeyListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseListener;
/*     */ import java.awt.event.WindowAdapter;
/*     */ import java.awt.event.WindowEvent;
/*     */ import java.io.PrintStream;
/*     */ import quicktime.QTException;
/*     */ import quicktime.QTObject;
/*     */ import quicktime.QTRuntimeException;
/*     */ import quicktime.QTSession;
/*     */ import quicktime.jdirect.QTNative;
/*     */ import quicktime.qd.QDGraphics;
/*     */ import quicktime.qd.QDPoint;
/*     */ import quicktime.qd.QDRect;
/*     */ import quicktime.qd.Region;
/*     */ import quicktime.std.StdQTException;
/*     */ import quicktime.std.image.GraphicsImporter;
/*     */ import quicktime.std.movies.Movie;
/*     */ import quicktime.std.movies.MovieController;
/*     */ import quicktime.std.sg.SGVideoChannel;
/*     */
/*     */ class QTJavaCocoaCanvas extends CocoaComponent
/*     */   implements QTComponent, KeyListener, MouseListener
/*     */ {
/*     */   private static final int kSetMovie = 0;
/*     */   private static final int kSetImage = 1;
/*     */   private static final int kSetMovieController = 2;
/*     */   private static final int kSetSeqGrabber = 3;
/*  56 */   private static boolean debug = false;
/*     */
/*  74 */   private int qtjavaView = 0;
/*  75 */   private boolean addDone = false;
/*  76 */   private boolean viewShown = false;
/*     */   private Movie movie;
/*     */   private MovieController controller;
/*     */   private GraphicsImporter image;
/*     */   private SGVideoChannel sgChannel;
/*     */   private int currentX;
/*     */   private int currentY;
/*     */   private int currentWidth;
/*     */   private int currentHeight;
/*     */   private int minWidth;
/*     */   private int minHeight;
/*     */   private int maxWidth;
/*     */   private int maxHeight;
/*  89 */   private QDRect oldbounds = null;
/*     */   transient int initialWidth;
/*     */   transient int initialHeight;
/*     */   private transient int prefWidth;
/*     */   private transient int prefHeight;
/*  94 */   private boolean performanceResize = false;
/*  95 */   private boolean QTMOVIEVIEW = false;
/*     */   private WindowAdapter wa;
/*     */   private Window parentWindow;
/*     */
/*     */   private static native void initGlobalLock(Object paramObject);
/*     */
/*     */   private static native void initGlobalOffScreen(Object paramObject);
/*     */
/*     */   private native void setFullScreen(byte paramByte);
/*     */
/*     */   private native void setMovie(int paramInt, Object paramObject);
/*     */
/*     */   private native void setMovieController(int paramInt, Object paramObject);
/*     */
/*     */   private native int createNSViewNative(float paramFloat1, float paramFloat2, Object paramObject1, Object paramObject2);
/*     */
/*     */   private native int createImageNSViewNative(int paramInt1, int paramInt2, Object paramObject);
/*     */
/*     */   private native int createSequenceGrabberNSView(int paramInt1, int paramInt2, Object paramObject);
/*     */
/*     */   private native Object getMovieController(int paramInt);
/*     */
/*     */   private native void removeMovie(int paramInt);
/*     */
/*     */   public int createNSView()
/*     */   {
/* 128 */     QDRect localQDRect = new QDRect(0, 0, 1, 1);
/* 129 */     Object localObject = null;
/* 130 */     if (this.movie != null) {
/*     */       try {
/* 132 */         if (this.controller != null)
/*     */           try {
/* 134 */             localQDRect = this.controller.getBounds();
/* 135 */             if (debug) System.err.println("createNSView controller " + this.controller + "bounds " + localQDRect);
/*     */           }
/*     */           catch (QTException localQTException) {  }
/*     */
/* 138 */         else localQDRect = this.movie.getBounds();
/*     */
/* 140 */         setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize()); } catch (StdQTException localStdQTException1) {
/*     */       }
/* 142 */       return this.qtjavaView = createNSViewNative(localQDRect.getWidthF(), localQDRect.getHeightF(), new Integer(QTObject.ID(this.movie)), this.controller != null ? new Integer(QTObject.ID(this.controller)) : null);
/*     */     }
/*     */
/* 145 */     if (this.image != null) {
/*     */       try {
/* 147 */         localQDRect = this.image.getBoundsRect();
/* 148 */         setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize()); } catch (StdQTException localStdQTException2) {
/*     */       }
/* 150 */       return this.qtjavaView = createImageNSViewNative(localQDRect.getWidth(), localQDRect.getHeight(), new Integer(QTObject.ID(this.image)));
/*     */     }
/* 152 */     if (this.sgChannel != null) {
/*     */       try {
/* 154 */         if ((this.sgChannel instanceof SGVideoChannel))
/* 155 */           localQDRect = this.sgChannel.getBounds();
/* 156 */         setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize());
/* 157 */         if (debug) System.err.println("***createNSView sgChannel " + this.sgChannel + ", " + localQDRect);
/*     */       } catch (StdQTException localStdQTException3) {  }
/*     */
/* 159 */       return this.qtjavaView = createSequenceGrabberNSView(localQDRect.getWidth(), localQDRect.getHeight(), new Integer(QTObject.ID(this.sgChannel.getSequenceGrabber())));
/*     */     }
/* 161 */     return 0;
/*     */   }
/*     */
/*     */   QTJavaCocoaCanvas(MovieController paramMovieController)
/*     */     throws QTException
/*     */   {
/* 170 */     this();
/* 171 */     this.movie = paramMovieController.getMovie();
/* 172 */     this.controller = paramMovieController;
/* 173 */     if (debug) System.err.println("QTJavaCocoaCanvas " + this.movie + ", " + this.controller);
/*     */   }
/*     */
/*     */   QTJavaCocoaCanvas(Movie paramMovie)
/*     */   {
/* 182 */     this();
/* 183 */     this.movie = paramMovie;
/* 184 */     this.controller = null;
/* 185 */     this.performanceResize = false;
/* 186 */     if (debug) System.err.println("QTJavaCocoaCanvas " + this.movie);
/*     */   }
/*     */
/*     */   QTJavaCocoaCanvas(GraphicsImporter paramGraphicsImporter)
/*     */   {
/* 195 */     this();
/* 196 */     this.image = paramGraphicsImporter;
/* 197 */     if (debug) System.err.println("QTJavaCocoaCanvas " + paramGraphicsImporter);
/*     */   }
/*     */
/*     */   QTJavaCocoaCanvas(SGVideoChannel paramSGVideoChannel)
/*     */   {
/* 202 */     this();
/* 203 */     this.sgChannel = paramSGVideoChannel;
/* 204 */     if (debug) System.err.println("QTJavaCocoaCanvas " + this.sgChannel);
/*     */   }
/*     */
/*     */   private QTJavaCocoaCanvas()
/*     */   {
/* 208 */     this.initialWidth = 1;
/* 209 */     this.initialHeight = 1;
/* 210 */     this.minWidth = 1;
/* 211 */     this.minHeight = 1;
/* 212 */     this.maxWidth = 2147483647;
/* 213 */     this.maxHeight = 2147483647;
/*     */   }
/*     */
/*     */   public void addNotify()
/*     */   {
/* 221 */     super.addNotify();
/* 222 */     if (!this.addDone) {
/* 223 */       if (debug) System.err.println("addNotify qtjavaView " + this.qtjavaView);
/* 224 */       addedTo();
/* 225 */       QTSession.addActiveCanvas(this);
/* 226 */       this.addDone = true;
/*     */     }
/* 228 */     if (isVisible())
/* 229 */       repaint();
/*     */   }
/*     */
/*     */   public synchronized void removeNotify()
/*     */   {
/* 237 */     if (debug) System.err.println("removeNotify:");
/* 238 */     if ((this.addDone) && (QTSession.isInitialized()))
/*     */       try {
/* 240 */         if (this.movie != null)
/* 241 */           doRemoveDrawable();
/* 242 */         QTSession.removeActiveCanvas(this);
/* 243 */         if (debug) System.err.println("removeNotify:");
/* 244 */         this.addDone = false;
/*     */       } finally {
/* 246 */         super.removeNotify();
/*     */       }
/*     */     else
/* 249 */       super.removeNotify();
/*     */   }
/*     */
/*     */   private final void doParentLayout() {
/* 253 */     if (debug) System.err.println("doParentLayout:" + getParent());
/* 254 */     Container localContainer = getParent();
/* 255 */     if (localContainer != null) {
/* 256 */       invalidate();
/* 257 */       localContainer.validate();
/*     */     }
/*     */
/* 260 */     super.setBounds(this.currentX, this.currentY, this.currentWidth, this.currentHeight);
/*     */   }
/*     */
/*     */   public void setBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/*     */   {
/* 265 */     if (debug) System.err.println("setBounds: " + paramInt3 + "," + paramInt4);
/* 266 */     super.setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
/*     */   }
/*     */
/*     */   private final void setCurrentXY(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/*     */   {
/* 271 */     int i = paramInt3 - this.currentWidth;
/* 272 */     if (i < 0) i = 0;
/*     */
/* 275 */     int j = paramInt4 - this.currentHeight;
/* 276 */     if (j < 0) j = 0;
/*     */
/* 278 */     if (this.performanceResize) {
/* 279 */       this.currentX = (paramInt1 + (int)(0.5F * i));
/* 280 */       this.currentY = (paramInt2 + (int)(0.5F * j));
/*     */     } else {
/* 282 */       this.currentX = paramInt1;
/* 283 */       this.currentY = paramInt2;
/*     */     }
/* 285 */     if (debug) System.err.println("setCurrentXY " + this.currentX + " " + this.currentY);
/*     */   }
/*     */
/*     */   public float getAlignmentX()
/*     */   {
/* 292 */     return this.performanceResize ? 0.5F : 0.0F;
/*     */   }
/*     */
/*     */   public float getAlignmentY()
/*     */   {
/* 298 */     return this.performanceResize ? 0.5F : 0.0F;
/*     */   }
/*     */
/*     */   private void setCurrentWidthHeight(int paramInt1, int paramInt2) {
/* 302 */     if (paramInt1 < this.minWidth) paramInt1 = this.minWidth;
/* 303 */     else if (paramInt1 > this.maxWidth) paramInt1 = this.maxWidth;
/* 304 */     if (paramInt2 < this.minHeight) paramInt2 = this.minHeight;
/* 305 */     else if (paramInt2 > this.maxHeight) paramInt2 = this.maxHeight;
/*     */
/* 307 */     if (this.performanceResize) {
/* 308 */       setPerformanceResize(paramInt1, paramInt2);
/*     */     } else {
/* 310 */       this.currentWidth = paramInt1;
/* 311 */       this.currentHeight = paramInt2;
/*     */     }
/*     */
/* 314 */     if (debug) System.out.println("setCurrentWidthHeight( " + this.currentWidth + ", " + this.currentHeight + ", " + this.minWidth + ", " + this.minHeight);
/*     */   }
/*     */
/*     */   private void setInitialWidthAndHeight(QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2)
/*     */   {
/* 318 */     this.initialWidth = paramQDRect.getWidth();
/* 319 */     this.initialHeight = paramQDRect.getHeight();
/*     */
/* 322 */     if (paramDimension1.width < 0) this.minWidth = 0; else {
/* 323 */       this.minWidth = paramDimension1.width;
/*     */     }
/* 325 */     if (paramDimension1.height < 0) this.minHeight = 0; else {
/* 326 */       this.minHeight = paramDimension1.height;
/*     */     }
/* 328 */     if (paramDimension2.width < this.minWidth) this.maxWidth = this.minWidth; else {
/* 329 */       this.maxWidth = paramDimension2.width;
/*     */     }
/* 331 */     if (paramDimension2.height < this.minHeight) this.maxHeight = this.minHeight; else {
/* 332 */       this.maxHeight = paramDimension2.height;
/*     */     }
/* 334 */     if (this.initialWidth < this.minWidth) this.initialWidth = this.minWidth;
/* 335 */     else if (this.initialWidth > this.maxWidth) this.initialWidth = this.maxWidth;
/*     */
/* 337 */     if (this.initialHeight < this.minHeight) this.initialHeight = this.minHeight;
/* 338 */     else if (this.initialHeight > this.maxHeight) this.initialHeight = this.maxHeight;
/*     */
/* 340 */     this.prefWidth = this.initialWidth;
/* 341 */     this.prefHeight = this.initialHeight;
/* 342 */     if (debug) System.err.println("setInitialWidthAndHeight " + this.initialWidth + " " + this.initialHeight + " " + this.prefWidth + " " + this.prefHeight);
/*     */   }
/*     */
/*     */   private void setPerformanceResize(int paramInt1, int paramInt2)
/*     */   {
/* 346 */     int i = 0;
/*     */
/* 350 */     for (int m = 2; i == 0; m *= 2)
/*     */     {
/*     */       int j;
/*     */       int k;
/*     */       int n;
/* 351 */       if ((paramInt1 < this.initialWidth) || (paramInt2 < this.initialHeight)) {
/* 352 */         j = this.initialWidth / m;
/* 353 */         k = this.initialHeight / m;
/* 354 */         if ((j <= paramInt1) && (k <= paramInt2)) {
/* 355 */           i = 1;
/*     */
/* 357 */           n = 0;
/* 358 */           this.currentWidth = j; for (this.currentHeight = k;
/* 359 */             n != 0;
/* 360 */             this.currentHeight *= 2) {
/* 361 */             if ((this.currentWidth >= this.minWidth) && (this.currentHeight >= this.minHeight))
/* 362 */               n = 1;
/* 360 */             this.currentWidth *= 2;
/*     */           }
/*     */
/*     */         }
/*     */
/*     */       }
/*     */       else
/*     */       {
/* 368 */         j = this.initialWidth * m;
/* 369 */         k = this.initialHeight * m;
/* 370 */         if ((j >= paramInt1) || (k >= paramInt2)) {
/* 371 */           i = 1;
/*     */
/* 373 */           if ((j > paramInt1) || (k > paramInt2)) {
/* 374 */             j /= 2;
/* 375 */             k /= 2;
/*     */           }
/*     */
/* 378 */           n = 0;
/* 379 */           this.currentWidth = j; for (this.currentHeight = k;
/* 380 */             n != 0;
/* 381 */             this.currentHeight /= 2) {
/* 382 */             if ((this.currentWidth <= this.maxWidth) && (this.currentHeight <= this.maxHeight))
/* 383 */               n = 1;
/* 381 */             this.currentWidth /= 2;
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */
/*     */   public Dimension getPreferredSize()
/*     */   {
/* 392 */     Dimension localDimension = null;
/* 393 */     localDimension = new Dimension(this.prefWidth, this.prefHeight);
/* 394 */     if (debug) System.err.println("getPreferredSize " + localDimension);
/* 395 */     return localDimension;
/*     */   }
/*     */
/*     */   public Dimension getBestSize() {
/* 399 */     Dimension localDimension = null;
/* 400 */     localDimension = new Dimension(this.initialWidth, this.initialHeight);
/* 401 */     if (debug) System.err.println("getBestSize " + localDimension);
/* 402 */     return localDimension;
/*     */   }
/*     */
/*     */   public Dimension getMinimumSize() {
/* 406 */     Dimension localDimension = null;
/* 407 */     localDimension = new Dimension(this.minWidth, this.minHeight);
/* 408 */     if (debug) System.err.println("getMinimumSize " + localDimension);
/* 409 */     return localDimension;
/*     */   }
/*     */
/*     */   public Dimension getMaximumSize() {
/* 413 */     Dimension localDimension = null;
/* 414 */     localDimension = new Dimension(32767, 32767);
/* 415 */     if (debug) System.err.println("getMaximumSize " + localDimension);
/* 416 */     return localDimension;
/*     */   }
/*     */
/*     */   private void setFullScreen()
/*     */   {
/* 421 */     setFullScreen((byte)1);
/*     */   }
/*     */
/*     */   public void removeMovie()
/*     */     throws QTException
/*     */   {
/* 428 */     if (this.movie != null) {
/* 429 */       this.movie.setRate(0.0F);
/* 430 */       this.movie.stop();
/*     */     }
/*     */   }
/*     */
/*     */   public Movie getMovie()
/*     */   {
/* 439 */     return this.movie;
/*     */   }
/*     */
/*     */   public MovieController getMovieController()
/*     */   {
/* 447 */     return this.controller;
/*     */   }
/*     */
/*     */   public void setMovieController(MovieController paramMovieController)
/*     */     throws QTException
/*     */   {
/* 456 */     QDRect localQDRect = null;
/* 457 */     if (paramMovieController == this.controller) return;
/*     */
/* 459 */     doRemoveDrawable();
/*     */
/* 461 */     this.controller = paramMovieController;
/*     */
/* 463 */     if (paramMovieController != null) {
/* 464 */       this.movie = paramMovieController.getMovie();
/*     */       try {
/* 466 */         localQDRect = paramMovieController.getBounds();
/* 467 */         if ((this.qtjavaView != 0) && (isValid()))
/*     */         {
/* 469 */           sendMessage(2, new Integer(QTObject.ID(paramMovieController)));
/* 470 */           setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize());
/*     */         }
/*     */       } catch (QTException localQTException) {
/*     */       }
/* 474 */       if ((this.qtjavaView != 0) && (isValid()))
/* 475 */         addedTo();
/*     */     } else {
/* 477 */       this.movie = null;
/*     */     }
/*     */   }
/*     */
/*     */   public void setMovie(Movie paramMovie)
/*     */     throws QTException
/*     */   {
/* 487 */     QDRect localQDRect = null;
/* 488 */     if (paramMovie == this.movie) return;
/*     */
/* 490 */     if (debug) System.err.println("setMovie " + paramMovie);
/* 491 */     doRemoveDrawable();
/*     */
/* 493 */     this.movie = paramMovie;
/* 494 */     if (paramMovie != null) {
/* 495 */       localQDRect = this.movie.getBounds();
/* 496 */       if ((this.qtjavaView != 0) && (isValid()))
/* 497 */         sendMessage(0, new Integer(QTObject.ID(this.movie)));
/* 498 */       setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize());
/*     */     }
/*     */   }
/*     */
/*     */   public void setSGChannel(SGVideoChannel paramSGVideoChannel) throws QTException
/*     */   {
/* 504 */     QDRect localQDRect = new QDRect(0, 0, 1, 1);
/* 505 */     if (paramSGVideoChannel == this.sgChannel) return;
/*     */
/* 507 */     if (debug) System.err.println("setSGChannel " + this.sgChannel);
/* 508 */     if (this.sgChannel != null) {
/* 509 */       doRemoveDrawable();
/*     */     }
/* 511 */     if (paramSGVideoChannel != null) {
/* 512 */       this.sgChannel = paramSGVideoChannel;
/* 513 */       if ((this.sgChannel instanceof SGVideoChannel))
/* 514 */         localQDRect = this.sgChannel.getBounds();
/* 515 */       if ((this.qtjavaView != 0) && (isValid()))
/* 516 */         sendMessage(3, new Integer(QTObject.ID(this.sgChannel.getSequenceGrabber())));
/* 517 */       setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize());
/*     */     }
/*     */   }
/*     */
/*     */   public Component asComponent() {
/* 522 */     return this;
/*     */   }
/*     */
/*     */   void doRemoveDrawable() {
/* 526 */     QDGraphics localQDGraphics = null;
/* 527 */     if (debug) System.out.println("doRemoveDrawable:"); try
/*     */     {
/* 529 */       localQDGraphics = QDGraphics.scratch;
/* 530 */       if ((this.movie != null) &&
/* 531 */         (QTSession.isInitialized()) &&
/* 532 */         (this.movie != null)) {
/* 533 */         this.movie.setRate(0.0F);
/* 534 */         this.movie.stop();
/*     */       }
/*     */
/* 538 */       if ((this.qtjavaView != 0) && (isValid()))
/*     */       {
/* 540 */         if (this.movie != null)
/*     */         {
/* 542 */           if (this.controller != null)
/* 543 */             sendMessage(2, null);
/* 544 */           if (this.movie != null)
/* 545 */             sendMessage(0, null);
/*     */         }
/* 547 */         if (this.image != null)
/* 548 */           sendMessage(1, null);
/*     */       }
/*     */     }
/*     */     catch (QTException localQTException) {
/* 552 */       if (debug) localQTException.printStackTrace();
/*     */     }
/* 554 */     finally { if (this.controller != null)
/* 555 */         removedFrom();
/* 556 */       if (debug) System.out.println("finally:");
/* 557 */       this.movie = null;
/* 558 */       this.controller = null;
/* 559 */       this.image = null;
/*     */     }
/*     */   }
/*     */
/*     */   public GraphicsImporter getImage()
/*     */   {
/* 569 */     return this.image;
/*     */   }
/*     */
/*     */   public void setImage(GraphicsImporter paramGraphicsImporter)
/*     */   {
/* 577 */     QDRect localQDRect = null;
/* 578 */     if (this.image == paramGraphicsImporter) {
/* 579 */       return;
/*     */     }
/* 581 */     doRemoveDrawable();
/*     */
/* 583 */     this.image = paramGraphicsImporter;
/* 584 */     if (paramGraphicsImporter != null) {
/*     */       try {
/* 586 */         localQDRect = this.image.getBoundsRect();
/* 587 */         setInitialWidthAndHeight(localQDRect, getMinimumSize(), getMaximumSize()); } catch (StdQTException localStdQTException) {
/*     */       }
/* 589 */       if ((this.qtjavaView != 0) && (isValid()))
/* 590 */         sendMessage(1, new Integer(QTObject.ID(this.image)));
/* 591 */       doParentLayout();
/*     */     }
/* 593 */     repaint();
/*     */   }
/*     */
/*     */   protected void addedTo()
/*     */   {
/* 600 */     if (debug)
/*     */       try
/*     */       {
/* 603 */         if (debug) System.err.println("addedTo " + this.controller.getPort());
/*     */       }
/*     */       catch (StdQTException localStdQTException1)
/*     */       {
/*     */       }
/* 607 */     if (this.controller != null) {
/* 608 */       addKeyListener(this);
/*     */     }
/* 610 */     Object localObject1 = getParent();
/* 611 */     Object localObject2 = localObject1;
/* 612 */     while (localObject2 != null) {
/* 613 */       localObject1 = localObject2;
/* 614 */       if ((localObject1 instanceof Window))
/*     */         break;
/* 616 */       localObject2 = ((Container)localObject1).getParent();
/*     */     }
/* 618 */     if (localObject1 != null)
/* 619 */       ((Container)localObject1).addKeyListener(this);
/*     */     try {
/* 621 */       if (this.controller != null)
/* 622 */         this.controller.setKeysEnabled(true);
/*     */     } catch (StdQTException localStdQTException2) {
/*     */     }
/* 625 */     if ((localObject1 instanceof Window)) {
/* 626 */       this.parentWindow = ((Window)localObject1);
/* 627 */       this.wa = new WindowAdapter() {
/*     */         public void windowActivated(WindowEvent paramAnonymousWindowEvent) {
/*     */           try {
/* 630 */             if (QTJavaCocoaCanvas.this.controller != null)
/*     */             {
/* 632 */               QTJavaCocoaCanvas.this.controller.activate(QTJavaCocoaCanvas.this.controller.getPort(), true);
/* 633 */               QTJavaCocoaCanvas.this.controller.activate();
/*     */             }
/* 635 */             QTJavaCocoaCanvas.this.redraw(null); } catch (QTException localQTException) {
/*     */           }
/*     */         }
/*     */
/* 639 */         public void windowDeactivated(WindowEvent paramAnonymousWindowEvent) { synchronized (QTSession.terminationLock()) {
/* 640 */             if (QTSession.isInitialized())
/*     */               try {
/* 642 */                 if (QTJavaCocoaCanvas.this.controller != null)
/*     */                 {
/* 644 */                   QTJavaCocoaCanvas.this.controller.deactivate();
/* 645 */                   QTJavaCocoaCanvas.this.controller.activate(QTJavaCocoaCanvas.this.controller.getPort(), false);
/*     */                 }
/* 647 */                 QTJavaCocoaCanvas.this.redraw(null);
/*     */               } catch (QTException localQTException) {
/*     */               }
/* 650 */             else QTJavaCocoaCanvas.this.removedFrom();
/*     */           }
/*     */         }
/*     */       };
/* 655 */       this.parentWindow.addWindowListener(this.wa);
/*     */     }
/*     */   }
/*     */
/*     */   protected void removedFrom()
/*     */   {
/* 664 */     removeKeyListener(this);
/* 665 */     if (getParent() != null)
/* 666 */       getParent().removeKeyListener(this);
/* 667 */     if (this.parentWindow != null) {
/* 668 */       this.parentWindow.removeWindowListener(this.wa);
/* 669 */       this.parentWindow = null;
/* 670 */       this.wa = null;
/*     */     }
/*     */   }
/*     */
/*     */   public void keyPressed(KeyEvent paramKeyEvent)
/*     */   {
/*     */     try
/*     */     {
/* 679 */       if (debug) System.err.println("Key pressed " + paramKeyEvent);
/* 680 */       if (this.controller != null)
/*     */       {
/* 682 */         boolean bool = this.controller.key(paramKeyEvent.getKeyCode(), paramKeyEvent.getModifiers());
/*     */       }
/*     */     }
/*     */     catch (QTException localQTException) {
/* 686 */       QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this, "keyPressed");
/*     */     }
/*     */   }
/*     */
/*     */   public void keyReleased(KeyEvent paramKeyEvent) {
/*     */   }
/*     */
/*     */   public void keyTyped(KeyEvent paramKeyEvent) {
/*     */   }
/*     */
/* 696 */   public void mousePressed(MouseEvent paramMouseEvent) { if (debug) System.err.println("mousePressed " + paramMouseEvent); try
/*     */     {
/* 698 */       Object localObject1 = getParent();
/* 699 */       Object localObject2 = localObject1;
/* 700 */       while (localObject2 != null) {
/* 701 */         if (debug) System.err.println(localObject2 + " getLocation " + ((Container)localObject2).getLocation() + " getBounds " + ((Container)localObject2).getBounds());
/* 702 */         if (((localObject2 instanceof Window)) || ((localObject2 instanceof Frame)) || ((localObject2 instanceof Applet)))
/*     */           break;
/* 704 */         localObject1 = localObject2;
/* 705 */         localObject2 = ((Container)localObject1).getParent();
/*     */       }
/* 707 */       if (debug) System.err.println(localObject1 + " getLocation " + ((Container)localObject1).getLocation() + " getBounds " + ((Container)localObject1).getBounds());
/* 708 */       if ((localObject1 instanceof Applet))
/*     */       {
/* 710 */         if (this.controller != null)
/* 711 */           this.controller.click(new QDPoint(paramMouseEvent.getX(), paramMouseEvent.getY() + (((Container)localObject1).getLocation().y - 22) + getLocation().y), paramMouseEvent.getModifiers());
/*     */       }
/*     */       else
/*     */       {
/* 715 */         if (debug)
/*     */         {
/* 717 */           System.err.println(paramMouseEvent.getX() + ((Container)localObject1).getLocation().x + getLocation().x + ", " + (paramMouseEvent.getY() + (((Container)localObject1).getLocation().y == 22 ? ((Container)localObject1).getLocation().y : ((Container)localObject1).getLocation().y - 22) + getLocation().y));
/*     */         }
/*     */
/* 720 */         if (this.controller != null)
/* 721 */           this.controller.click(new QDPoint(paramMouseEvent.getX() + ((Container)localObject1).getLocation().x + getLocation().x, ((Container)localObject1).getLocation().y != 22 ? paramMouseEvent.getY() + (((Container)localObject1).getLocation().y - 22) + getLocation().y : paramMouseEvent.getY()), paramMouseEvent.getModifiers());
/*     */       }
/*     */     } catch (QTException localQTException) {
/* 724 */       QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this, "mousePressed");
/*     */     } }
/*     */
/*     */   public void mouseClicked(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */
/*     */   public void mouseEntered(MouseEvent paramMouseEvent) {
/*     */   }
/*     */
/*     */   public void mouseExited(MouseEvent paramMouseEvent) {
/*     */   }
/*     */
/*     */   public void mouseReleased(MouseEvent paramMouseEvent) {
/*     */   }
/*     */
/*     */   private final void redraw(Region paramRegion) throws QTException {
/* 741 */     if (debug) System.out.println("RD:");
/* 742 */     if (paramRegion != null) {
/*     */       try {
/* 744 */         if (this.controller != null)
/*     */         {
/* 746 */           this.controller.invalidate(this.controller.getPort(), paramRegion);
/* 747 */           this.controller.idle();
/*     */         }
/*     */       } catch (StdQTException localStdQTException) {
/* 750 */         if (this.controller != null)
/* 751 */           this.controller.draw();
/*     */       }
/*     */     }
/* 754 */     else if (this.controller != null)
/* 755 */       this.controller.draw();
/*     */   }
/*     */
/*     */   static
/*     */   {
/*  61 */     if (!QTSession.isCurrentOS(4))
/*  62 */       throw new QTRuntimeException("OS not supported");
/*  63 */     if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() < 65540)) {
/*  64 */       throw new QTRuntimeException("Java version not supported");
/*     */     }
/*     */
/*  67 */     String str = "/System/Library/QuickTimeJava/QuickTimeJava.bundle/Contents/Resources/libCocoaInterface.jnilib";
/*  68 */     System.load(str);
/*     */
/*  70 */     initGlobalLock(QTNative.globalsLock);
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name:     quicktime.app.view.QTJavaCocoaCanvas
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of quicktime.app.view.QTJavaCocoaCanvas

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.