/[classpath]/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
ViewVC logotype

Diff of /classpath/gnu/java/awt/peer/qt/QtComponentPeer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by fitzsim, Fri Aug 19 01:29:26 2005 UTC revision 1.5 by smarothy, Sun Aug 21 00:19:49 2005 UTC
# Line 73  import java.awt.event.WindowEvent; // 2/ Line 73  import java.awt.event.WindowEvent; // 2/
73  import java.util.Timer;  import java.util.Timer;
74  import java.util.TimerTask;  import java.util.TimerTask;
75    
76    import javax.swing.DebugGraphics;
77    
78  public class QtComponentPeer extends NativeWrapper implements ComponentPeer  public class QtComponentPeer extends NativeWrapper implements ComponentPeer
79  {  {
80    
# Line 111  public class QtComponentPeer extends Nat Line 113  public class QtComponentPeer extends Nat
113     */     */
114    private QtImage backBuffer;    private QtImage backBuffer;
115    
   /**  
    * Stores if the backBuffer is dirty or not  
    */  
   private boolean dirtyBackBuffer;  
   
116    protected long qtApp;    protected long qtApp;
117    
118    private boolean settingUp;    private boolean settingUp;
119    
120      private boolean ignoreResize = false;
121    
122    QtComponentPeer( QtToolkit kit, Component owner )    QtComponentPeer( QtToolkit kit, Component owner )
123    {    {
124      this.owner = owner;      this.owner = owner;
# Line 166  public class QtComponentPeer extends Nat Line 165  public class QtComponentPeer extends Nat
165          setEnabled( owner.isEnabled() );          setEnabled( owner.isEnabled() );
166    
167          backBuffer = null;          backBuffer = null;
         dirtyBackBuffer = true;  
168          updateBounds();          updateBounds();
169    
170          setVisible( owner.isVisible() );          setVisible( owner.isVisible() );
171            QtToolkit.repaintThread.queueComponent(this);
172        }        }
173      settingUp = false;      settingUp = false;
174    }    }
# Line 352  public class QtComponentPeer extends Nat Line 351  public class QtComponentPeer extends Nat
351      toolkit.eventQueue.postEvent(e);      toolkit.eventQueue.postEvent(e);
352    }    }
353    
354    protected void moveEvent()    protected void moveEvent(int x, int y, int oldx, int oldy)
355    {    {
356      ComponentEvent e = new ComponentEvent(owner,      if( !ignoreResize )
357                                            ComponentEvent.COMPONENT_MOVED);        {
358      toolkit.eventQueue.postEvent(e);          // Since Component.setLocation calls back to setBounds,
359            // we need to ignore that.
360            ignoreResize = true;
361            owner.setLocation( x, y );
362            ignoreResize = false;
363          }
364    }    }
365    
366    protected void resizeEvent(int oldWidth, int oldHeight,    protected void resizeEvent(int oldWidth, int oldHeight,
367                               int width, int height)                               int width, int height)
368    {    {
369      dirtyBackBuffer = true;      if(!(owner instanceof Window))
370      if( drawableComponent() )        return;
371        {      ignoreResize = true;
         //      backBuffer.dispose();  
         backBuffer = new QtImage(width, height);  
       }  
372      owner.setSize(width, height);      owner.setSize(width, height);
373        ignoreResize = false;
374      ComponentEvent e = new ComponentEvent(owner,      ComponentEvent e = new ComponentEvent(owner,
375                                            ComponentEvent.COMPONENT_RESIZED);                                            ComponentEvent.COMPONENT_RESIZED);
376      toolkit.eventQueue.postEvent(e);      toolkit.eventQueue.postEvent(e);
377    }    }
378    
# Line 495  public class QtComponentPeer extends Nat Line 497  public class QtComponentPeer extends Nat
497    
498    public Graphics getGraphics()    public Graphics getGraphics()
499    {    {
500      if( backBuffer == null)      if( backBuffer == null )
501        {        {
502          Rectangle r = owner.getBounds();          Rectangle r = owner.getBounds();
503          backBuffer = new QtImage( r.width, r.height );          backBuffer = new QtImage( r.width, r.height );
# Line 512  public class QtComponentPeer extends Nat Line 514  public class QtComponentPeer extends Nat
514    
515    public native Point getLocationOnScreen();    public native Point getLocationOnScreen();
516    
517    public Dimension getMinimumSize()    public synchronized Dimension getMinimumSize()
518    {    {
519      Dimension d = getMinimumSizeNative();      Dimension d = getMinimumSizeNative();
520      if(d == null)      if(d == null)
# Line 520  public class QtComponentPeer extends Nat Line 522  public class QtComponentPeer extends Nat
522      return d;      return d;
523    }    }
524    
525    public Dimension getPreferredSize()    public synchronized Dimension getPreferredSize()
526    {    {
527      Dimension d = getPreferredSizeNative();      synchronized(toolkit)
528      if(d == null)        {
529        return owner.getSize();          Dimension d = getPreferredSizeNative();
530      return d;          if(d == null)
531              return owner.getSize();
532            return d;
533          }
534    }    }
535    
536    public Toolkit getToolkit()    public Toolkit getToolkit()
# Line 574  public class QtComponentPeer extends Nat Line 579  public class QtComponentPeer extends Nat
579                        int width,                        int width,
580                        int height)                        int height)
581    {    {
     dirtyBackBuffer = true;  
582      setBounds( x, y, width, height );      setBounds( x, y, width, height );
583    }    }
584    
# Line 587  public class QtComponentPeer extends Nat Line 591  public class QtComponentPeer extends Nat
591    
592    public void setBounds(int x, int y, int width, int height)    public void setBounds(int x, int y, int width, int height)
593    {    {
594        if( ignoreResize )
595          return;
596      if(width > 0 && height > 0 && (drawableComponent() || backBuffer != null))      if(width > 0 && height > 0 && (drawableComponent() || backBuffer != null))
597        backBuffer = new QtImage(width, height);          backBuffer = new QtImage(width, height);  
598      setBoundsNative(x, y, width, height);      setBoundsNative(x, y, width, height);
599        QtToolkit.repaintThread.queueComponent(this);
600    }    }
601    
602    public void setCursor(Cursor cursor)    public void setCursor(Cursor cursor)
# Line 629  public class QtComponentPeer extends Nat Line 636  public class QtComponentPeer extends Nat
636        case ComponentEvent.COMPONENT_SHOWN:        case ComponentEvent.COMPONENT_SHOWN:
637        case PaintEvent.PAINT:        case PaintEvent.PAINT:
638        case PaintEvent.UPDATE:          case PaintEvent.UPDATE:  
639          dirtyBackBuffer = true;          QtToolkit.repaintThread.queueComponent(this);
         QtUpdate();  
640          break;          break;
641        case KeyEvent.KEY_PRESSED:        case KeyEvent.KEY_PRESSED:
642          break;          break;
# Line 640  public class QtComponentPeer extends Nat Line 646  public class QtComponentPeer extends Nat
646    }    }
647    
648    /**    /**
649     * Paint() is called back from the native side in response to a native     * paint() is called back from the native side in response to a native
650     * repaint event.     * repaint event.
651     */       */  
652    public void paint(Graphics g)    public void paint(Graphics g)
653    {    {
654      if (backBuffer != null)      if (backBuffer != null)
655          backBuffer.drawPixels((QtGraphics)g, 0, 0, 0, 0, 0, false );
656      }
657    
658      public void paintBackBuffer()
659      {
660        if( backBuffer != null)
661        {        {
662          if (dirtyBackBuffer)          backBuffer.clear();
663            {          Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
664              backBuffer.clear();          owner.paint(bbg);
665              Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();          bbg.dispose();
             owner.paint(bbg);  
             bbg.dispose();  
             dirtyBackBuffer = false;  
           }  
         backBuffer.drawPixels((QtGraphics)g, 0, 0, 0, 0, 0, false );  
666        }        }
667    }    }
668    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26