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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [gnu/] [java/] [awt/] [peer/] [gtk/] [GtkWindowPeer.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* GtkWindowPeer.java -- Implements WindowPeer with GTK
2
   Copyright (C) 1998, 1999, 2002, 2005  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package gnu.java.awt.peer.gtk;
40
 
41
import java.awt.Component;
42
import java.awt.Frame;
43
import java.awt.Window;
44
import java.awt.event.WindowEvent;
45
import java.awt.peer.WindowPeer;
46
 
47
public class GtkWindowPeer extends GtkContainerPeer
48
  implements WindowPeer
49
{
50
  protected static final int GDK_WINDOW_TYPE_HINT_NORMAL = 0;
51
  protected static final int GDK_WINDOW_TYPE_HINT_DIALOG = 1;
52
  protected static final int GDK_WINDOW_TYPE_HINT_MENU = 2;
53
  protected static final int GDK_WINDOW_TYPE_HINT_TOOLBAR = 3;
54
  protected static final int GDK_WINDOW_TYPE_HINT_SPLASHSCREEN = 4;
55
  protected static final int GDK_WINDOW_TYPE_HINT_UTILITY = 5;
56
  protected static final int GDK_WINDOW_TYPE_HINT_DOCK = 6;
57
  protected static final int GDK_WINDOW_TYPE_HINT_DESKTOP = 7;
58
 
59
  private boolean hasBeenShown = false;
60
  private int oldState = Frame.NORMAL;
61
 
62
  native void gtkWindowSetTitle (String title);
63
  native void gtkWindowSetResizable (boolean resizable);
64
  native void gtkWindowSetModal (boolean modal);
65
 
66
  native void realize ();
67
 
68
  int getWidth ()
69
  {
70
    return awtComponent.getWidth();
71
  }
72
 
73
  int getHeight ()
74
  {
75
    return awtComponent.getHeight();
76
  }
77
 
78
  native void create (int type, boolean decorated, GtkWindowPeer parent);
79
 
80
  void create (int type, boolean decorated)
81
  {
82
    Window window = (Window) awtComponent;
83
    GtkWindowPeer parent_peer = null;
84
    Component parent = awtComponent.getParent();
85
 
86
    if (!window.isFocusableWindow())
87
      type = GDK_WINDOW_TYPE_HINT_MENU;
88
 
89
    if (parent != null)
90
      parent_peer = (GtkWindowPeer) awtComponent.getParent().getPeer();
91
 
92
    create (type, decorated, parent_peer);
93
  }
94
 
95
  void create ()
96
  {
97
    // Create a normal undecorated window.
98
    create (GDK_WINDOW_TYPE_HINT_NORMAL, false);
99
  }
100
 
101
  void setParent ()
102
  {
103
    setVisible (awtComponent.isVisible ());
104
    setEnabled (awtComponent.isEnabled ());
105
  }
106
 
107
  void setVisibleAndEnabled ()
108
  {
109
  }
110
 
111
  public native void setVisibleNative (boolean b);
112
  public native void setVisibleNativeUnlocked (boolean b);
113
 
114
  native void connectSignals ();
115
 
116
  public GtkWindowPeer (Window window)
117
  {
118
    super (window);
119
  }
120
 
121
  public native void toBack();
122
  public native void toFront();
123
 
124
  native void nativeSetBounds (int x, int y, int width, int height);
125
  native void nativeSetBoundsUnlocked (int x, int y, int width, int height);
126
 
127
  public void setBounds (int x, int y, int width, int height)
128
  {
129
    // prevent window_configure_cb -> awtComponent.setSize ->
130
    // peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
131
    if (Thread.currentThread() == GtkToolkit.mainThread)
132
      return;
133
 
134
    nativeSetBounds (x, y,
135
                     width - insets.left - insets.right,
136
                     height - insets.top - insets.bottom);
137
  }
138
 
139
  public void setBoundsUnlocked (int x, int y, int width, int height)
140
  {
141
    nativeSetBoundsUnlocked (x, y,
142
                             width - insets.left - insets.right,
143
                             height - insets.top - insets.bottom);
144
  }
145
 
146
  public void setTitle (String title)
147
  {
148
    gtkWindowSetTitle (title);
149
  }
150
 
151
  native void setSize (int width, int height);
152
 
153
  public void setResizable (boolean resizable)
154
  {
155
    // Call setSize; otherwise when resizable is changed from true to
156
    // false the window will shrink to the dimensions it had before it
157
    // was resizable.
158
    setSize (awtComponent.getWidth() - insets.left - insets.right,
159
             awtComponent.getHeight() - insets.top - insets.bottom);
160
    gtkWindowSetResizable (resizable);
161
  }
162
 
163
  protected void postInsetsChangedEvent (int top, int left,
164
                                         int bottom, int right)
165
  {
166
    insets.top = top;
167
    insets.left = left;
168
    insets.bottom = bottom;
169
    insets.right = right;
170
  }
171
 
172
  // called back by native side: window_configure_cb
173
  // only called from GTK thread
174
  protected void postConfigureEvent (int x, int y, int width, int height)
175
  {
176
    int frame_width = width + insets.left + insets.right;
177
    int frame_height = height + insets.top + insets.bottom;
178
 
179
    if (frame_width != awtComponent.getWidth()
180
        || frame_height != awtComponent.getHeight())
181
      awtComponent.setSize(frame_width, frame_height);
182
 
183
    int frame_x = x - insets.left;
184
    int frame_y = y - insets.top;
185
 
186
    if (frame_x != awtComponent.getX()
187
        || frame_y != awtComponent.getY())
188
      {
189
        // awtComponent.setLocation(frame_x, frame_y);
190
      }
191
  }
192
 
193
  public void show ()
194
  {
195
    // Prevent the window manager from automatically placing this
196
    // window when it is shown.
197
    setBounds (awtComponent.getX(),
198
               awtComponent.getY(),
199
               awtComponent.getWidth(),
200
               awtComponent.getHeight());
201
    setVisible (true);
202
  }
203
 
204
  void postWindowEvent (int id, Window opposite, int newState)
205
  {
206
    if (id == WindowEvent.WINDOW_OPENED)
207
      {
208
        // Post a WINDOW_OPENED event the first time this window is shown.
209
        if (!hasBeenShown)
210
          {
211
            q().postEvent (new WindowEvent ((Window) awtComponent, id,
212
                                          opposite));
213
            hasBeenShown = true;
214
          }
215
      }
216
    else if (id == WindowEvent.WINDOW_STATE_CHANGED)
217
      {
218
        if (oldState != newState)
219
          {
220
            q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite,
221
                                          oldState, newState));
222
            oldState = newState;
223
          }
224
      }
225
    else
226
      q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite));
227
  }
228
  public void updateAlwaysOnTop()
229
  {
230
    // TODO Auto-generated method stub
231
 
232
  }
233
  public boolean requestWindowFocus()
234
  {
235
    // TODO Auto-generated method stub
236
    return false;
237
  }
238
}

powered by: WebSVN 2.1.0

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