44 |
import java.awt.MenuBar; |
import java.awt.MenuBar; |
45 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
46 |
import java.awt.Window; |
import java.awt.Window; |
47 |
|
import java.awt.event.ComponentEvent; |
48 |
import java.awt.event.PaintEvent; |
import java.awt.event.PaintEvent; |
49 |
import java.awt.image.ColorModel; |
import java.awt.image.ColorModel; |
50 |
import java.awt.peer.FramePeer; |
import java.awt.peer.FramePeer; |
56 |
private int menuBarHeight; |
private int menuBarHeight; |
57 |
private MenuBarPeer menuBar; |
private MenuBarPeer menuBar; |
58 |
native int getMenuBarHeight (MenuBarPeer bar); |
native int getMenuBarHeight (MenuBarPeer bar); |
59 |
|
native void setMenuBarWidthUnlocked (MenuBarPeer bar, int width); |
60 |
native void setMenuBarWidth (MenuBarPeer bar, int width); |
native void setMenuBarWidth (MenuBarPeer bar, int width); |
61 |
native void setMenuBarPeer (MenuBarPeer bar); |
native void setMenuBarPeer (MenuBarPeer bar); |
62 |
native void removeMenuBarPeer (); |
native void removeMenuBarPeer (); |
119 |
|
|
120 |
public void setBounds (int x, int y, int width, int height) |
public void setBounds (int x, int y, int width, int height) |
121 |
{ |
{ |
122 |
|
// prevent window_configure_cb -> awtComponent.setSize -> |
123 |
|
// peer.setBounds -> nativeSetBounds self-deadlock on GDK lock. |
124 |
|
if (Thread.currentThread() == GtkToolkit.mainThread) |
125 |
|
{ |
126 |
|
int menuBarWidth = width - insets.left - insets.right; |
127 |
|
if (menuBar != null && menuBarWidth > 0) |
128 |
|
setMenuBarWidthUnlocked (menuBar, menuBarWidth); |
129 |
|
|
130 |
|
return; |
131 |
|
} |
132 |
|
|
133 |
int menuBarWidth = width - insets.left - insets.right; |
int menuBarWidth = width - insets.left - insets.right; |
134 |
if (menuBar != null && menuBarWidth > 0) |
if (menuBar != null && menuBarWidth > 0) |
135 |
setMenuBarWidth (menuBar, menuBarWidth); |
setMenuBarWidth (menuBar, menuBarWidth); |
205 |
|
|
206 |
protected void postConfigureEvent (int x, int y, int width, int height) |
protected void postConfigureEvent (int x, int y, int width, int height) |
207 |
{ |
{ |
|
int frame_x = x - insets.left; |
|
|
// Since insets.top includes the MenuBar height, we need to add back |
|
|
// the MenuBar height to the frame's y position. |
|
|
// If no MenuBar exists in this frame, the MenuBar height will be 0. |
|
|
int frame_y = y - insets.top + menuBarHeight; |
|
208 |
int frame_width = width + insets.left + insets.right; |
int frame_width = width + insets.left + insets.right; |
209 |
// Ditto as above. Since insets.top already includes the MenuBar's height, |
// Since insets.top already includes the MenuBar's height, we need |
210 |
// we need to subtract the MenuBar's height from the top inset. |
// to subtract the MenuBar's height from the top inset. |
211 |
int frame_height = height + insets.top + insets.bottom - menuBarHeight; |
int frame_height = height + insets.top + insets.bottom - menuBarHeight; |
212 |
if (frame_x != awtComponent.getX() |
|
213 |
|| frame_y != awtComponent.getY() |
if (frame_width != awtComponent.getWidth() |
|
|| frame_width != awtComponent.getWidth() |
|
214 |
|| frame_height != awtComponent.getHeight()) |
|| frame_height != awtComponent.getHeight()) |
215 |
{ |
awtComponent.setSize(frame_width, frame_height); |
216 |
if (frame_width != awtComponent.getWidth() && menuBar != null |
|
217 |
&& width > 0) |
int frame_x = x - insets.left; |
218 |
setMenuBarWidth (menuBar, width); |
// Likewise, since insets.top includes the MenuBar height, we need |
219 |
|
// to add back the MenuBar height to the frame's y position. If |
220 |
setBoundsCallback ((Window) awtComponent, |
// no MenuBar exists in this frame, the MenuBar height will be 0. |
221 |
frame_x, |
int frame_y = y - insets.top + menuBarHeight; |
|
frame_y, |
|
|
frame_width, |
|
|
frame_height); |
|
222 |
|
|
223 |
awtComponent.validate(); |
if (frame_x != awtComponent.getX() |
224 |
|
|| frame_y != awtComponent.getY()) |
225 |
|
{ |
226 |
|
// awtComponent.setLocation(frame_x, frame_y); |
227 |
} |
} |
228 |
} |
} |
229 |
|
|
258 |
{ |
{ |
259 |
|
|
260 |
} |
} |
261 |
|
public void setBoundsPrivate(int x, int y, int width, int height) |
262 |
|
{ |
263 |
|
// TODO Auto-generated method stub |
264 |
|
|
265 |
|
} |
266 |
|
public void updateAlwaysOnTop() |
267 |
|
{ |
268 |
|
// TODO Auto-generated method stub |
269 |
|
|
270 |
|
} |
271 |
|
public boolean requestWindowFocus() |
272 |
|
{ |
273 |
|
// TODO Auto-generated method stub |
274 |
|
return false; |
275 |
|
} |
276 |
} |
} |
277 |
|
|
278 |
|
|