49
49
public class GtkMenuItemPeer extends GtkMenuComponentPeer
50
50
implements MenuItemPeer
52
native void create (String label);
53
native void connectSignals ();
54
native void gtkWidgetModifyFont (String name, int style, int size);
53
* Creates the associated gtk+ widget and stores it in the nsa table
54
* for this peer. Called by the create() method with the label name
55
* of the associated MenuItem. Needs to be overridden my subclasses
56
* that want to create a different gtk+ widget.
58
protected native void create (String label);
61
* Called from constructor to enable signals from an item. If a
62
* subclass needs different (or no) signals connected this method
63
* should be overridden.
65
protected native void connectSignals ();
68
* Overridden to set font on menu item label.
70
protected native void gtkWidgetModifyFont(String name, int style, int size);
73
* Creates the associated gtk+ widget and stores it in the nsa table
74
* for this peer. Called by the (super class) constructor.
75
* Overridden to get the label if the assiociated MenuItem and to
76
* call create(String).
78
protected void create()
58
80
create (((MenuItem) awtWidget).getLabel());
61
public GtkMenuItemPeer (MenuItem item)
64
setEnabled (item.isEnabled ());
67
if (item.getParent() instanceof Menu && ! (item instanceof Menu))
73
MenuComponent mc = ((MenuComponent) awtWidget);
74
Font f = mc.getFont ();
78
MenuComponent parent = (MenuComponent) mc.getParent ();
79
Font pf = parent.getFont ();
80
gtkWidgetModifyFont (pf.getName (), pf.getStyle (), pf.getSize ());
83
gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize());
86
void setParent (MenuItem item)
88
// add ourself differently, based on what type of parent we have
89
// yes, the typecasting here is nasty.
90
Object parent = item.getParent ();
91
if (parent instanceof MenuBar)
93
((GtkMenuBarPeer)((MenuBar)parent).getPeer ()).addMenu ((MenuPeer) this);
95
else // parent instanceof Menu
97
((GtkMenuPeer)((Menu)parent).getPeer ()).addItem (this,
102
public void disable ()
107
public void enable ()
84
* Creates a new GtkMenuItemPeer associated with the given MenuItem.
85
* It will call create(), setFont(), setEnabled() and
86
* connectSignals() in that order.
88
public GtkMenuItemPeer(MenuItem item)
91
setEnabled (item.isEnabled());
96
* Calls setEnabled(false).
104
* Calls setEnabled(true).
112
111
public native void setEnabled(boolean b);
114
112
public native void setLabel(String label);
115
* Callback setup through connectSignals().
116
117
protected void postMenuActionEvent ()
118
119
postActionEvent (((MenuItem)awtWidget).getActionCommand (), 0);