home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.motif;
-
- import java.awt.Choice;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.event.ItemEvent;
- import java.awt.peer.ChoicePeer;
-
- class MChoicePeer extends MComponentPeer implements ChoicePeer {
- native void create(MComponentPeer var1);
-
- native void pReshape(int var1, int var2, int var3, int var4);
-
- public native void select(int var1);
-
- void initialize() {
- Choice var1 = (Choice)super.target;
- int var2 = var1.countItems();
-
- for(int var3 = 0; var3 < var2; ++var3) {
- this.add(var1.getItem(var3), var3);
- }
-
- if (var2 > 0) {
- this.select(var1.getSelectedIndex());
- }
-
- super.initialize();
- }
-
- public MChoicePeer(Choice var1) {
- super(var1);
- }
-
- public boolean isFocusTraversable() {
- return true;
- }
-
- public Dimension getMinimumSize() {
- FontMetrics var1 = ((MComponentPeer)this).getFontMetrics(super.target.getFont());
- Choice var2 = (Choice)super.target;
- int var3 = 0;
-
- for(int var4 = var2.countItems(); var4-- > 0; var3 = Math.max(var1.stringWidth(var2.getItem(var4)), var3)) {
- }
-
- return new Dimension(32 + var3, Math.max(var1.getHeight() + 8, 15) + 5);
- }
-
- public native void setFont(Font var1);
-
- public void add(String var1, int var2) {
- this.addItem(var1, var2);
- }
-
- public native void remove(int var1);
-
- public void removeAll() {
- }
-
- public native void addItem(String var1, int var2);
-
- public native void setBackground(Color var1);
-
- public native void setForeground(Color var1);
-
- void action(int var1) {
- Choice var2 = (Choice)super.target;
- var2.select(var1);
- ((MComponentPeer)this).postEvent(new ItemEvent(var2, 701, var2.getItem(var1), 1));
- }
-
- public void print(Graphics var1) {
- Choice var2 = (Choice)super.target;
- Dimension var3 = ((Component)var2).size();
- Color var4 = ((Component)var2).getBackground();
- Color var5 = ((Component)var2).getForeground();
- var1.setColor(var4);
- var1.fillRect(2, 2, var3.width - 1, var3.height - 1);
- ((MComponentPeer)this).draw3DRect(var1, var4, 1, 1, var3.width - 2, var3.height - 2, true);
- ((MComponentPeer)this).draw3DRect(var1, var4, var3.width - 18, var3.height / 2 - 3, 10, 6, true);
- var1.setColor(var5);
- var1.setFont(((Component)var2).getFont());
- FontMetrics var6 = var1.getFontMetrics();
- String var7 = var2.getSelectedItem();
- var1.drawString(var7, 5, (var3.height + var6.getMaxAscent() - var6.getMaxDescent()) / 2);
- super.target.print(var1);
- }
-
- public Dimension minimumSize() {
- return this.getMinimumSize();
- }
- }
-