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

« back to all changes in this revision

Viewing changes to gnu/java/awt/peer/gtk/GtkFramePeer.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
/* GtkFramePeer.java -- Implements FramePeer with GTK
2
 
   Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
 
2
   Copyright (C) 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Classpath.
5
5
 
43
43
import java.awt.Image;
44
44
import java.awt.MenuBar;
45
45
import java.awt.Rectangle;
46
 
import java.awt.Window;
47
 
import java.awt.event.ComponentEvent;
48
46
import java.awt.event.PaintEvent;
49
 
import java.awt.image.ColorModel;
50
47
import java.awt.peer.FramePeer;
51
48
import java.awt.peer.MenuBarPeer;
52
49
 
77
74
        removeMenuBarPeer ();
78
75
        insets.top -= menuBarHeight;
79
76
        menuBarHeight = 0;
80
 
        awtComponent.validate ();
 
77
        // if component has already been validated, we need to revalidate.
 
78
        // otherwise, it will be validated when it is shown.
 
79
        if (awtComponent.isValid())
 
80
          awtComponent.validate ();
81
81
        gtkFixedSetVisible (true);
82
82
      }
83
83
    else if (bar != null && menuBar == null)
92
92
          setMenuBarWidth (menuBar, menuBarWidth);
93
93
        menuBarHeight = getMenuBarHeight ();
94
94
        insets.top += menuBarHeight;
95
 
        awtComponent.validate ();
 
95
        // if component has already been validated, we need to revalidate.
 
96
        // otherwise, it will be validated when it is shown.
 
97
        if (awtComponent.isValid())
 
98
          awtComponent.validate ();
96
99
        gtkFixedSetVisible (true);
97
100
      }
98
101
    else if (bar != null && menuBar != null)
119
122
 
120
123
  public void setBounds (int x, int y, int width, int height)
121
124
  {
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
125
    int menuBarWidth = width - insets.left - insets.right;
134
126
    if (menuBar != null && menuBarWidth > 0)
135
127
      setMenuBarWidth (menuBar, menuBarWidth);
136
128
 
137
 
    nativeSetBounds (x, y,
138
 
                     width - insets.left - insets.right,
139
 
                     height - insets.top - insets.bottom
140
 
                     + menuBarHeight);
 
129
    super.setBounds(x, y, width, height + menuBarHeight);
141
130
  }  
142
131
  
143
132
  public void setResizable (boolean resizable)
193
182
        }
194
183
  }
195
184
 
196
 
  public Graphics getGraphics ()
197
 
  {
198
 
    Graphics g;
199
 
    if (GtkToolkit.useGraphics2D ())
200
 
      g = new GdkGraphics2D (this);
201
 
    else
202
 
      g = new GdkGraphics (this);
203
 
    g.translate (-insets.left, -insets.top);
204
 
    return g;
205
 
  }
206
 
  
207
185
  protected void postConfigureEvent (int x, int y, int width, int height)
208
186
  {
209
 
    int frame_width = width + insets.left + insets.right;
 
187
    if (menuBar != null && width > 0)
 
188
      setMenuBarWidthUnlocked (menuBar, width);
 
189
 
210
190
    // Since insets.top already includes the MenuBar's height, we need
211
191
    // to subtract the MenuBar's height from the top inset.
212
 
    int frame_height = height + insets.top + insets.bottom - menuBarHeight;
213
 
 
214
 
    if (frame_width != awtComponent.getWidth()
215
 
        || frame_height != awtComponent.getHeight())
216
 
      awtComponent.setSize(frame_width, frame_height);
217
 
 
218
 
    int frame_x = x - insets.left;
 
192
    int frame_height = height - menuBarHeight;
 
193
 
219
194
    // Likewise, since insets.top includes the MenuBar height, we need
220
195
    // to add back the MenuBar height to the frame's y position.  If
221
196
    // no MenuBar exists in this frame, the MenuBar height will be 0.
222
 
    int frame_y = y - insets.top + menuBarHeight;
223
 
 
224
 
    if (frame_x != awtComponent.getX()
225
 
        || frame_y != awtComponent.getY())
226
 
      {
227
 
        // awtComponent.setLocation(frame_x, frame_y);
228
 
      }
229
 
  }
230
 
 
231
 
  protected void postMouseEvent(int id, long when, int mods, int x, int y, 
232
 
                                int clickCount, boolean popupTrigger)
233
 
  {
234
 
    super.postMouseEvent (id, when, mods, 
235
 
                          x + insets.left, y + insets.top, 
236
 
                          clickCount, popupTrigger);
237
 
  }
238
 
 
239
 
  protected void postExposeEvent (int x, int y, int width, int height)
240
 
  {
241
 
    if (!isInRepaint)
242
 
      q().postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
243
 
                                   new Rectangle (x + insets.left, 
244
 
                                                  y + insets.top, 
245
 
                                                  width, height)));
 
197
    int frame_y = y + menuBarHeight;
 
198
 
 
199
    super.postConfigureEvent(x, frame_y, width, frame_height);
246
200
  }
247
201
 
248
202
  public int getState ()