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/] [GtkListPeer.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* GtkListPeer.java -- Implements ListPeer with GTK
2
   Copyright (C) 1998, 1999 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.AWTEvent;
42
import java.awt.Dimension;
43
import java.awt.List;
44
import java.awt.event.KeyEvent;
45
import java.awt.event.MouseEvent;
46
import java.awt.peer.ListPeer;
47
 
48
public class GtkListPeer extends GtkComponentPeer
49
  implements ListPeer
50
{
51
  void create ()
52
  {
53
    List list = (List) awtComponent;
54
 
55
    create (list.getRows ());
56
 
57
    setMultipleMode (list.isMultipleMode ());
58
  }
59
 
60
  native void create (int rows);
61
  native void connectSignals ();
62
  native void gtkWidgetModifyFont (String name, int style, int size);
63
  native void gtkWidgetRequestFocus ();
64
 
65
  native void getSize (int rows, int visibleRows, int dims[]);
66
 
67
  public GtkListPeer (List list)
68
  {
69
    super (list);
70
 
71
    setMultipleMode (list.isMultipleMode ());
72
 
73
    if (list.getItemCount () > 0)
74
      append (list.getItems ());
75
  }
76
 
77
  native void append (String items[]);
78
 
79
  public native void add (String item, int index);
80
 
81
  public void addItem (String item, int index)
82
  {
83
    add (item, index);
84
  }
85
 
86
  public void clear ()
87
  {
88
    removeAll ();
89
  }
90
 
91
  public native void delItems (int start, int end);
92
  public native void deselect (int index);
93
 
94
  public Dimension getMinimumSize (int rows)
95
  {
96
    return minimumSize (rows);
97
  }
98
 
99
  public Dimension getPreferredSize (int rows)
100
  {
101
    return preferredSize (rows);
102
  }
103
 
104
  public native int[] getSelectedIndexes ();
105
  public native void makeVisible (int index);
106
 
107
  public Dimension minimumSize (int rows)
108
  {
109
    int dims[] = new int[2];
110
 
111
    int visibleRows = ((List) awtComponent).getRows();
112
    getSize (rows, visibleRows, dims);
113
    return new Dimension (dims[0], dims[1]);
114
  }
115
 
116
  public Dimension preferredSize (int rows)
117
  {
118
    int dims[] = new int[2];
119
 
120
    int visibleRows = ((List) awtComponent).getRows();
121
    getSize (rows, visibleRows, dims);
122
    return new Dimension (dims[0], dims[1]);
123
  }
124
 
125
  public void removeAll ()
126
  {
127
    delItems (0, -1);
128
  }
129
 
130
  public native void select (int index);
131
  public native void setMultipleMode (boolean b);
132
 
133
  public void setMultipleSelections (boolean b)
134
  {
135
    setMultipleMode (b);
136
  }
137
 
138
  public void handleEvent (AWTEvent e)
139
  {
140
    if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ())
141
      {
142
        // Only generate the ActionEvent on the second click of a
143
        // multiple click.
144
        MouseEvent me = (MouseEvent) e;
145
        if (!me.isConsumed ()
146
            && (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0
147
            && me.getClickCount() == 2)
148
          {
149
            String selectedItem = ((List) awtComponent).getSelectedItem ();
150
 
151
            // Double-click only generates an Action event if
152
            // something is selected.
153
            if (selectedItem != null)
154
              postActionEvent (((List) awtComponent).getSelectedItem (),
155
                               me.getModifiersEx ());
156
          }
157
      }
158
 
159
    if (e.getID () == KeyEvent.KEY_PRESSED)
160
      {
161
        KeyEvent ke = (KeyEvent) e;
162
        if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_ENTER)
163
          {
164
            String selectedItem = ((List) awtComponent).getSelectedItem ();
165
 
166
            // Enter only generates an Action event if something is
167
            // selected.
168
            if (selectedItem != null)
169
              postActionEvent (selectedItem, ke.getModifiersEx ());
170
          }
171
      }
172
 
173
    super.handleEvent (e);
174
  }
175
 
176
  protected void postItemEvent (int item, int stateChange)
177
  {
178
    postItemEvent (new Integer (item), stateChange);
179
  }
180
}

powered by: WebSVN 2.1.0

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