77 |
|
|
78 |
Insets insets; |
Insets insets; |
79 |
|
|
80 |
|
boolean isInRepaint; |
81 |
|
|
82 |
/* this isEnabled differs from Component.isEnabled, in that it |
/* this isEnabled differs from Component.isEnabled, in that it |
83 |
knows if a parent is disabled. In that case Component.isEnabled |
knows if a parent is disabled. In that case Component.isEnabled |
84 |
may return true, but our isEnabled will always return false */ |
may return true, but our isEnabled will always return false */ |
99 |
native void gtkWidgetRequestFocus (); |
native void gtkWidgetRequestFocus (); |
100 |
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods, |
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods, |
101 |
int keyCode, int keyLocation); |
int keyCode, int keyLocation); |
102 |
native void gtkSetFont (String name, int style, int size); |
native void gtkWidgetRepaintArea(int x, int y, int width, int height); |
|
native void gtkWidgetQueueDrawArea(int x, int y, int width, int height); |
|
|
native void addExposeFilter(); |
|
|
native void removeExposeFilter(); |
|
103 |
|
|
104 |
void create () |
void create () |
105 |
{ |
{ |
133 |
|
|
134 |
setComponentBounds (); |
setComponentBounds (); |
135 |
|
|
|
Rectangle bounds = awtComponent.getBounds (); |
|
|
setBounds (bounds.x, bounds.y, bounds.width, bounds.height); |
|
136 |
setVisibleAndEnabled (); |
setVisibleAndEnabled (); |
137 |
} |
} |
138 |
|
|
151 |
gtkWidgetSetParent (p); |
gtkWidgetSetParent (p); |
152 |
} |
} |
153 |
|
|
154 |
|
void beginNativeRepaint () |
155 |
|
{ |
156 |
|
isInRepaint = true; |
157 |
|
} |
158 |
|
|
159 |
|
void endNativeRepaint () |
160 |
|
{ |
161 |
|
isInRepaint = false; |
162 |
|
} |
163 |
|
|
164 |
/* |
/* |
165 |
* Set the bounds of this peer's AWT Component based on dimensions |
* Set the bounds of this peer's AWT Component based on dimensions |
166 |
* returned by the native windowing system. Most Components impose |
* returned by the native windowing system. Most Components impose |
167 |
* their dimensions on the peers so the default implementation does |
* their dimensions on the peers which is what the default |
168 |
* nothing. However some peers, like GtkFileDialogPeer, need to |
* implementation does. However some peers, like GtkFileDialogPeer, |
169 |
* pass their size back to the AWT Component. |
* need to pass their size back to the AWT Component. |
170 |
*/ |
*/ |
171 |
void setComponentBounds () |
void setComponentBounds () |
172 |
{ |
{ |
173 |
|
Rectangle bounds = awtComponent.getBounds (); |
174 |
|
setBounds (bounds.x, bounds.y, bounds.width, bounds.height); |
175 |
} |
} |
176 |
|
|
177 |
void setVisibleAndEnabled () |
void setVisibleAndEnabled () |
274 |
// Some peers like GtkFileDialogPeer are repainted by Gtk itself |
// Some peers like GtkFileDialogPeer are repainted by Gtk itself |
275 |
if (g == null) |
if (g == null) |
276 |
break; |
break; |
277 |
|
|
278 |
g.setClip (((PaintEvent)event).getUpdateRect()); |
g.setClip (((PaintEvent) event).getUpdateRect()); |
279 |
|
|
280 |
if (id == PaintEvent.PAINT) |
if (id == PaintEvent.PAINT) |
281 |
awtComponent.paint (g); |
awtComponent.paint (g); |
319 |
|
|
320 |
public void paint (Graphics g) |
public void paint (Graphics g) |
321 |
{ |
{ |
|
Component parent = awtComponent.getParent(); |
|
|
GtkComponentPeer parentPeer = null; |
|
|
if ((parent instanceof Container) && !parent.isLightweight()) |
|
|
parentPeer = (GtkComponentPeer) parent.getPeer(); |
|
|
|
|
|
addExposeFilter(); |
|
|
if (parentPeer != null) |
|
|
parentPeer.addExposeFilter(); |
|
|
|
|
|
Rectangle clip = g.getClipBounds(); |
|
|
gtkWidgetQueueDrawArea(clip.x, clip.y, clip.width, clip.height); |
|
|
|
|
|
removeExposeFilter(); |
|
|
if (parentPeer != null) |
|
|
parentPeer.removeExposeFilter(); |
|
322 |
} |
} |
323 |
|
|
324 |
public Dimension preferredSize () |
public Dimension preferredSize () |
365 |
|
|
366 |
public void repaint (long tm, int x, int y, int width, int height) |
public void repaint (long tm, int x, int y, int width, int height) |
367 |
{ |
{ |
368 |
|
beginNativeRepaint (); |
369 |
|
gtkWidgetRepaintArea (x, y, width, height); |
370 |
|
endNativeRepaint (); |
371 |
q.postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE, |
q.postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE, |
372 |
new Rectangle (x, y, width, height))); |
new Rectangle (x, y, width, height))); |
373 |
} |
} |
374 |
|
|
375 |
public void requestFocus () |
public void requestFocus () |
423 |
if (parent instanceof Window && !lightweightChild) |
if (parent instanceof Window && !lightweightChild) |
424 |
{ |
{ |
425 |
Insets insets = ((Window) parent).getInsets (); |
Insets insets = ((Window) parent).getInsets (); |
426 |
// Convert from Java coordinates to GTK coordinates. |
GtkWindowPeer peer = (GtkWindowPeer) parent.getPeer (); |
427 |
setNativeBounds (x - insets.left, y - insets.top, width, height); |
int menuBarHeight = 0; |
428 |
|
if (peer instanceof GtkFramePeer) |
429 |
|
menuBarHeight = ((GtkFramePeer) peer).getMenuBarHeight (); |
430 |
|
|
431 |
|
// Convert from Java coordinates to GTK coordinates. |
432 |
|
setNativeBounds (x - insets.left, y - insets.top + menuBarHeight, |
433 |
|
width, height); |
434 |
} |
} |
435 |
else |
else |
436 |
setNativeBounds (x, y, width, height); |
setNativeBounds (x, y, width, height); |
451 |
// FIXME: This should really affect the widget tree below me. |
// FIXME: This should really affect the widget tree below me. |
452 |
// Currently this is only handled if the call is made directly on |
// Currently this is only handled if the call is made directly on |
453 |
// a text widget, which implements setFont() itself. |
// a text widget, which implements setFont() itself. |
454 |
gtkSetFont(f.getName(), f.getStyle(), f.getSize()); |
gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize()); |
455 |
} |
} |
456 |
|
|
457 |
public void setForeground (Color c) |
public void setForeground (Color c) |
491 |
|
|
492 |
protected void postExposeEvent (int x, int y, int width, int height) |
protected void postExposeEvent (int x, int y, int width, int height) |
493 |
{ |
{ |
494 |
q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT, |
if (!isInRepaint) |
495 |
new Rectangle (x, y, width, height))); |
q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT, |
496 |
|
new Rectangle (x, y, width, height))); |
497 |
} |
} |
498 |
|
|
499 |
protected void postKeyEvent (int id, long when, int mods, |
protected void postKeyEvent (int id, long when, int mods, |