~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to gnu/java/awt/peer/gtk/GtkMenuItemPeer.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GtkMenuItemPeer.java -- Implements MenuItemPeer with GTK+
2
 
   Copyright (C) 1999, 2005  Free Software Foundation, Inc.
 
2
   Copyright (C) 1999, 2005, 2006  Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Classpath.
5
5
 
49
49
public class GtkMenuItemPeer extends GtkMenuComponentPeer
50
50
  implements MenuItemPeer
51
51
{
52
 
  native void create (String label);
53
 
  native void connectSignals ();
54
 
  native void gtkWidgetModifyFont (String name, int style, int size);
55
 
 
56
 
  void create ()
 
52
  /**
 
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.
 
57
   */
 
58
  protected native void create (String label);
 
59
 
 
60
  /**
 
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.
 
64
   */
 
65
  protected native void connectSignals ();
 
66
 
 
67
  /**
 
68
   * Overridden to set font on menu item label.
 
69
   */
 
70
  protected native void gtkWidgetModifyFont(String name, int style, int size);
 
71
 
 
72
  /**
 
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).
 
77
   */
 
78
  protected void create()
57
79
  {
58
80
    create (((MenuItem) awtWidget).getLabel());
59
81
  }
60
82
 
61
 
  public GtkMenuItemPeer (MenuItem item)
62
 
  {
63
 
    super (item);
64
 
    setEnabled (item.isEnabled ());
65
 
    setParent (item);
66
 
 
67
 
    if (item.getParent() instanceof Menu && ! (item instanceof Menu))
68
 
      connectSignals();
69
 
  }
70
 
 
71
 
  void setFont ()
72
 
  {
73
 
    MenuComponent mc = ((MenuComponent) awtWidget);
74
 
    Font f = mc.getFont ();
75
 
 
76
 
    if (f == null)
77
 
      {
78
 
        MenuComponent parent = (MenuComponent) mc.getParent ();
79
 
        Font pf = parent.getFont ();
80
 
        gtkWidgetModifyFont (pf.getName (), pf.getStyle (), pf.getSize ());
81
 
      }
82
 
    else
83
 
      gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize());
84
 
  }
85
 
 
86
 
  void setParent (MenuItem item)
87
 
  {
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)
92
 
      {
93
 
        ((GtkMenuBarPeer)((MenuBar)parent).getPeer ()).addMenu ((MenuPeer) this);
94
 
      }
95
 
    else // parent instanceof Menu
96
 
      {
97
 
        ((GtkMenuPeer)((Menu)parent).getPeer ()).addItem (this, 
98
 
                                                          item.getShortcut ());
99
 
      }
100
 
  }
101
 
 
102
 
  public void disable ()
103
 
  {
104
 
    setEnabled (false);
105
 
  }
106
 
 
107
 
  public void enable ()
108
 
  {
109
 
    setEnabled (true);
 
83
  /**
 
84
   * Creates a new GtkMenuItemPeer associated with the given MenuItem.
 
85
   * It will call create(), setFont(), setEnabled() and
 
86
   * connectSignals() in that order.
 
87
   */
 
88
  public GtkMenuItemPeer(MenuItem item)
 
89
  {
 
90
    super(item);
 
91
    setEnabled (item.isEnabled());
 
92
    connectSignals();
 
93
  }
 
94
 
 
95
  /**
 
96
   * Calls setEnabled(false).
 
97
   */
 
98
  public void disable()
 
99
  {
 
100
    setEnabled(false);
 
101
  }
 
102
 
 
103
  /**
 
104
   * Calls setEnabled(true).
 
105
   */
 
106
  public void enable()
 
107
  {
 
108
    setEnabled(true);
110
109
  }
111
110
 
112
111
  public native void setEnabled(boolean b);
113
 
 
114
112
  public native void setLabel(String label);
115
113
 
 
114
  /**
 
115
   * Callback setup through connectSignals().
 
116
   */
116
117
  protected void postMenuActionEvent ()
117
118
  {
118
119
    postActionEvent (((MenuItem)awtWidget).getActionCommand (), 0);