summaryrefslogtreecommitdiff
path: root/gnu/java/awt/peer/gtk/GtkFramePeer.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/java/awt/peer/gtk/GtkFramePeer.java')
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java92
1 files changed, 58 insertions, 34 deletions
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index e1a877eed..4916a7d0a 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -57,51 +58,69 @@ public class GtkFramePeer extends GtkWindowPeer
private int menuBarHeight;
private MenuBarPeer menuBar;
native int getMenuBarHeight (MenuBarPeer bar);
-
+ native void setMenuBarWidth (MenuBarPeer bar, int width);
native void setMenuBarPeer (MenuBarPeer bar);
native void removeMenuBarPeer ();
- native void moveLayout (int offset);
- native void gtkLayoutSetVisible (boolean vis);
+ native void gtkFixedSetVisible (boolean visible);
+
+ int getMenuBarHeight ()
+ {
+ return menuBar == null ? 0 : getMenuBarHeight (menuBar);
+ }
public void setMenuBar (MenuBar bar)
{
- if (bar == null)
- {
- if (menuBar != null)
+ if (bar == null && menuBar != null)
{
- gtkLayoutSetVisible(false);
- removeMenuBarPeer();
+ // We're removing the menubar.
+ gtkFixedSetVisible (false);
menuBar = null;
- moveLayout(menuBarHeight);
+ removeMenuBarPeer ();
insets.top -= menuBarHeight;
- menuBarHeight = 0;
- awtComponent.doLayout();
- gtkLayoutSetVisible(true);
+ menuBarHeight = 0;
+ awtComponent.validate ();
+ gtkFixedSetVisible (true);
}
- }
- else
- {
- gtkLayoutSetVisible(false);
- int oldHeight = 0;
- if (menuBar != null)
+ else if (bar != null && menuBar == null)
+ {
+ // We're adding a menubar where there was no menubar before.
+ gtkFixedSetVisible (false);
+ menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
+ setMenuBarPeer (menuBar);
+ int menuBarWidth =
+ awtComponent.getWidth () - insets.left - insets.right;
+ setMenuBarWidth (menuBar, menuBarWidth);
+ menuBarHeight = getMenuBarHeight ();
+ insets.top += menuBarHeight;
+ awtComponent.validate ();
+ gtkFixedSetVisible (true);
+ }
+ else if (bar != null && menuBar != null)
{
+ // We're swapping the menubar.
+ gtkFixedSetVisible (false);
removeMenuBarPeer();
- oldHeight = menuBarHeight;
- insets.top -= menuBarHeight;
+ int oldHeight = menuBarHeight;
+ int menuBarWidth =
+ awtComponent.getWidth () - insets.left - insets.right;
+ menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer ();
+ setMenuBarPeer (menuBar);
+ setMenuBarWidth (menuBar, menuBarWidth);
+ menuBarHeight = getMenuBarHeight ();
+ if (oldHeight != menuBarHeight)
+ {
+ insets.top += (menuBarHeight - oldHeight);
+ awtComponent.validate ();
+ }
+ gtkFixedSetVisible (true);
}
- menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
- setMenuBarPeer(menuBar);
- menuBarHeight = getMenuBarHeight (menuBar);
- if (oldHeight != menuBarHeight)
- moveLayout(oldHeight - menuBarHeight);
- insets.top += menuBarHeight;
- awtComponent.doLayout();
- gtkLayoutSetVisible(true);
- }
}
public void setBounds (int x, int y, int width, int height)
{
+ if (menuBar != null)
+ setMenuBarWidth (menuBar, width - insets.left - insets.right);
+
nativeSetBounds (x, y,
width - insets.left - insets.right,
height - insets.top - insets.bottom
@@ -206,15 +225,19 @@ public class GtkFramePeer extends GtkWindowPeer
|| frame_width != awtComponent.getWidth()
|| frame_height != awtComponent.getHeight())
{
+ if (frame_width != awtComponent.getWidth() && menuBar != null)
+ setMenuBarWidth (menuBar, width);
+
setBoundsCallback ((Window) awtComponent,
frame_x,
frame_y,
frame_width,
frame_height);
}
+
awtComponent.validate();
}
-
+
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
{
@@ -225,10 +248,11 @@ public class GtkFramePeer extends GtkWindowPeer
protected void postExposeEvent (int x, int y, int width, int height)
{
- q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
- new Rectangle (x + insets.left,
- y + insets.top,
- width, height)));
+ if (!isInRepaint)
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x + insets.left,
+ y + insets.top,
+ width, height)));
}
public int getState ()