/[classpath]/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java
ViewVC logotype

Diff of /classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java

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

revision 1.26 by mark, Sun Aug 8 13:44:17 2004 UTC revision 1.27 by mkoch, Wed Sep 22 11:03:09 2004 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package gnu.java.awt.peer.gtk;  package gnu.java.awt.peer.gtk;
40    
41  import java.awt.Component;  import java.awt.Component;
42    import java.awt.Container;
43  import java.awt.Frame;  import java.awt.Frame;
44  import java.awt.Graphics;  import java.awt.Graphics;
45  import java.awt.Graphics2D;  import java.awt.Graphics2D;
# Line 58  public class GtkFramePeer extends GtkWin Line 59  public class GtkFramePeer extends GtkWin
59    private MenuBarPeer menuBar;    private MenuBarPeer menuBar;
60    native int getMenuBarHeight (MenuBarPeer bar);    native int getMenuBarHeight (MenuBarPeer bar);
61    
62      int getMenuBarHeight ()
63      {
64        return menuBar == null ? 0 : getMenuBarHeight (menuBar);
65      }
66    
67    native void setMenuBarPeer (MenuBarPeer bar);    native void setMenuBarPeer (MenuBarPeer bar);
68    native void removeMenuBarPeer ();    native void removeMenuBarPeer ();
69    native void moveLayout (int offset);    native void gtkFixedMove (int offset);
70    native void gtkLayoutSetVisible (boolean vis);    native void gtkFixedSetVisible (boolean visible);
71    
72    public void setMenuBar (MenuBar bar)    public void setMenuBar (MenuBar bar)
73    {    {
74      if (bar == null)      if (bar == null && menuBar != null)
     {      
       if (menuBar != null)  
75        {        {
76          gtkLayoutSetVisible(false);          // We're removing the menubar.
77          removeMenuBarPeer();          gtkFixedSetVisible (false);
78          menuBar = null;          menuBar = null;
79          moveLayout(menuBarHeight);          removeMenuBarPeer ();
80          insets.top -= menuBarHeight;          insets.top -= menuBarHeight;
81          menuBarHeight = 0;                menuBarHeight = 0;
82          awtComponent.doLayout();          awtComponent.validate ();
83          gtkLayoutSetVisible(true);          gtkFixedSetVisible (true);
84        }        }
85      }      else if (bar != null && menuBar == null)
     else  
     {  
       gtkLayoutSetVisible(false);  
       int oldHeight = 0;  
       if (menuBar != null)  
86        {        {
87            // We're adding a menubar where there was no menubar before.
88            gtkFixedSetVisible (false);
89            menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
90            setMenuBarPeer (menuBar);
91            menuBarHeight = getMenuBarHeight ();
92            insets.top += menuBarHeight;
93            awtComponent.validate ();
94            gtkFixedSetVisible (true);
95          }
96        else if (bar != null && menuBar != null)
97          {
98            // We're swapping the menubar.
99            gtkFixedSetVisible (false);
100          removeMenuBarPeer();          removeMenuBarPeer();
101          oldHeight = menuBarHeight;          int oldHeight = menuBarHeight;
102          insets.top -= menuBarHeight;          menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer ();
103            setMenuBarPeer (menuBar);
104            menuBarHeight = getMenuBarHeight ();
105            if (oldHeight != menuBarHeight)
106              {
107                insets.top += (menuBarHeight - oldHeight);
108                awtComponent.validate ();
109              }
110            gtkFixedSetVisible (true);
111        }        }
       menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();  
       setMenuBarPeer(menuBar);  
       menuBarHeight = getMenuBarHeight (menuBar);  
       if (oldHeight != menuBarHeight)  
         moveLayout(oldHeight - menuBarHeight);  
       insets.top += menuBarHeight;  
       awtComponent.doLayout();  
       gtkLayoutSetVisible(true);  
     }  
112    }    }
113    
114    public void setBounds (int x, int y, int width, int height)    public void setBounds (int x, int y, int width, int height)
# Line 225  public class GtkFramePeer extends GtkWin Line 236  public class GtkFramePeer extends GtkWin
236    
237    protected void postExposeEvent (int x, int y, int width, int height)    protected void postExposeEvent (int x, int y, int width, int height)
238    {    {
239      q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,      if (!isInRepaint)
240                                   new Rectangle (x + insets.left,        q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
241                                                  y + insets.top,                                     new Rectangle (x + insets.left,
242                                                  width, height)));                                                    y + insets.top,
243                                                      width, height)));
244    }    }
245    
246    public int getState ()    public int getState ()

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

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