OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [awt/] [xlib/] [XFramePeer.java] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2000, 2002, 2003  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
8
 
9
package gnu.awt.xlib;
10
 
11
import java.awt.*;
12
import java.awt.peer.*;
13
import java.awt.image.*;
14
import gnu.gcj.xlib.WMSizeHints;
15
import gnu.gcj.xlib.WindowAttributes;
16
import gnu.gcj.xlib.Display;
17
import gnu.gcj.xlib.Visual;
18
import gnu.gcj.xlib.Screen;
19
import gnu.gcj.xlib.XConfigureEvent;
20
 
21
/** FIXME: a lot of the code here should be moved down to XWindowPeer. */
22
 
23
public class XFramePeer extends XCanvasPeer implements FramePeer
24
{
25
  private boolean processingConfigureNotify = false;
26
 
27
  public XFramePeer(Frame frame)
28
  {
29
    super(frame);
30
 
31
    // Set some defaults for a toplevel component:
32
    if (frame.getFont() == null)
33
      frame.setFont(new Font("helvetica", Font.PLAIN, 12));
34
 
35
    if (frame.getBackground() == null)
36
      frame.setBackground(Color.lightGray);
37
 
38
    if (frame.getForeground() == null)
39
      frame.setForeground(Color.black);
40
  }
41
 
42
  /** Find parent window for toplevel window, ie. root window of
43
      selected screen. Bounds are not changed. */
44
  gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds)
45
  {
46
    Screen screen = config.getVisual().getScreen();
47
    return screen.getRootWindow();
48
  }
49
 
50
  void initWindowProperties()
51
  {
52
    Frame frame = (Frame) component;
53
    setResizable(frame.isResizable());
54
    String title = frame.getTitle();
55
    if (!title.equals("")) setTitle(title);
56
  }
57
 
58
  long getBasicEventMask()
59
  {
60
    return super.getBasicEventMask() |
61
      WindowAttributes.MASK_STRUCTURE_NOTIFY;
62
  }
63
 
64
  void configureNotify(XConfigureEvent configEvent)
65
  {
66
    processingConfigureNotify = true; // to avoid setBounds flood
67
    component.setBounds(configEvent.getBounds());
68
    processingConfigureNotify = false;
69
  }
70
 
71
  /* Overridden to ignore request to set bounds if the request occurs
72
     while processing an XConfigureNotify event, in which case the X
73
     window already has the desired bounds.
74
     That's what java.awt.Window.setBoundsCallback is for, but it's
75
     package-private, and using our own flag eliminates the need to
76
     circumvent java security.
77
  */
78
  public void setBounds(int x, int y, int width, int height)
79
  {
80
    if (!processingConfigureNotify)
81
      super.setBounds(x, y, width, height);
82
  }
83
 
84
  // Implementing ContainerPeer:
85
 
86
  static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0);
87
 
88
  public Insets getInsets()
89
  {
90
    return (Insets) INSETS_0_PROTOTYPE.clone();
91
  }
92
 
93
  public Insets insets ()
94
  {
95
    return getInsets ();
96
  }
97
 
98
  public void beginValidate()
99
  {
100
  }
101
 
102
  public void endValidate()
103
  {
104
    // reassert sizing hints
105
    Frame frame = (Frame) component;
106
    setResizable(frame.isResizable());
107
  }
108
 
109
 
110
  // Implementing WindowPeer:
111
 
112
  public void toBack()
113
  {
114
    window.toBack ();
115
  }
116
 
117
  public void toFront()
118
  {
119
    window.toFront ();
120
  }
121
 
122
 
123
  // Implementing FramePeer:
124
 
125
  public void setIconImage(Image image)
126
  {
127
    throw new UnsupportedOperationException("not implemented yet");
128
  }
129
 
130
  public void setMenuBar(MenuBar mb)
131
  {
132
    throw new UnsupportedOperationException("not implemented yet");
133
  }
134
 
135
 
136
  public void setTitle(String title)
137
  {
138
    synchronized (window.getDisplay())
139
      {
140
        // Oh, what a nice implementation :-)
141
        window.setProperty("WM_NAME", "STRING", title);
142
 
143
        ensureFlush();
144
      }
145
  }
146
 
147
  public void setResizable(boolean resizable)
148
  {
149
    Frame frame = (Frame) component;
150
 
151
    WMSizeHints sizeHints = new WMSizeHints();
152
    if (resizable)
153
      {
154
        Dimension minSize = frame.getMinimumSize();
155
        sizeHints.setMinSize(minSize.width, minSize.height);
156
 
157
        Dimension maxSize = frame.getMaximumSize();
158
 
159
        if ((maxSize.width < Short.MAX_VALUE) ||
160
            (maxSize.height < Short.MAX_VALUE))
161
          {
162
            maxSize.width  = Math.min(maxSize.width,  Short.MAX_VALUE);
163
            maxSize.height = Math.min(maxSize.height, Short.MAX_VALUE);
164
            sizeHints.setMaxSize(maxSize.width, maxSize.height);
165
          }
166
      }
167
    else
168
      {
169
        // lock resizing to current bounds
170
        Dimension size = frame.getSize();
171
        sizeHints.setMinSize(size.width, size.height);
172
        sizeHints.setMaxSize(size.width, size.height);
173
      }
174
    sizeHints.applyNormalHints(window);
175
  }
176
 
177
  public int getState ()
178
  {
179
    return 0;
180
  }
181
 
182
  public void setState (int state)
183
  {
184
  }
185
 
186
  public void setMaximizedBounds (Rectangle r)
187
  {
188
  }
189
 
190
  public void beginLayout () { }
191
  public void endLayout () { }
192
  public boolean isPaintPending () { return false; }
193
 
194
  /**
195
   * @since 1.5
196
   */
197
  public void setBoundsPrivate (int x, int y, int width, int height)
198
  {
199
    // TODO: Implement this.
200
    throw new UnsupportedOperationException("Not yet implemented.");
201
  }
202
 
203
  public Rectangle getBoundsPrivate()
204
  {
205
    // TODO: Implement this.
206
    throw new UnsupportedOperationException("Not yet implemented.");
207
  }
208
 
209
  /**
210
   * @since 1.5
211
   */
212
  public void updateAlwaysOnTop()
213
  {
214
  }
215
 
216
  /**
217
   * @since 1.5
218
   */
219
  public boolean requestWindowFocus ()
220
  {
221
    return false;
222
  }
223
 
224
  public void setAlwaysOnTop(boolean alwaysOnTop)
225
  {
226
    throw new UnsupportedOperationException("not implemented yet");
227
  }
228
 
229
  public void updateFocusableWindowState()
230
  {
231
    throw new UnsupportedOperationException("not implemented yet");
232
  }
233
 
234
  public void setModalBlocked(Dialog blocker, boolean blocked)
235
  {
236
    throw new UnsupportedOperationException("not implemented yet");
237
  }
238
 
239
  public void updateMinimumSize()
240
  {
241
    throw new UnsupportedOperationException("not implemented yet");
242
  }
243
 
244
  public void updateIconImages()
245
  {
246
    throw new UnsupportedOperationException("not implemented yet");
247
  }
248
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.