home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / mac / vnc-mac.hqx / binary / Server / VNCServer.rsrc / JAVA_132_optionsFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-01-25  |  3.4 KB  |  151 lines

  1. import java.awt.Button;
  2. import java.awt.Choice;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Frame;
  7. import java.awt.GridBagConstraints;
  8. import java.awt.GridBagLayout;
  9. import java.awt.Label;
  10. import java.awt.Window;
  11.  
  12. class optionsFrame extends Frame {
  13.    static String[] names = new String[]{"Encoding", "Use CopyRect", "Mouse buttons 2 and 3", "Raw pixel drawing", "CopyRect", "Share desktop"};
  14.    static String[][] values = new String[][]{{"Raw", "RRE", "CoRRE", "Hextile"}, {"Yes", "No"}, {"Normal", "Reversed"}, {"Fast", "Reliable"}, {"Fast", "Reliable"}, {"Yes", "No"}};
  15.    final int encodingIndex;
  16.    final int useCopyRectIndex = 1;
  17.    final int mouseButtonIndex = 2;
  18.    final int rawPixelDrawingIndex = 3;
  19.    final int copyRectFastIndex = 4;
  20.    final int shareDesktopIndex = 5;
  21.    Label[] labels;
  22.    Choice[] choices;
  23.    Button dismiss;
  24.    // $FF: renamed from: v vncviewer
  25.    vncviewer field_0;
  26.    int[] encodings;
  27.    int nEncodings;
  28.    boolean reverseMouseButtons2And3;
  29.    boolean drawEachPixelForRawRects;
  30.    boolean copyRectFast;
  31.    boolean shareDesktop;
  32.  
  33.    optionsFrame(vncviewer var1) {
  34.       super("VNC Options");
  35.       this.labels = new Label[names.length];
  36.       this.choices = new Choice[names.length];
  37.       this.encodings = new int[10];
  38.       this.field_0 = var1;
  39.       GridBagLayout var2 = new GridBagLayout();
  40.       ((Container)this).setLayout(var2);
  41.       GridBagConstraints var3 = new GridBagConstraints();
  42.       var3.fill = 1;
  43.  
  44.       for(int var4 = 0; var4 < names.length; ++var4) {
  45.          this.labels[var4] = new Label(names[var4]);
  46.          var3.gridwidth = 1;
  47.          var2.setConstraints(this.labels[var4], var3);
  48.          ((Container)this).add(this.labels[var4]);
  49.          this.choices[var4] = new Choice();
  50.          var3.gridwidth = 0;
  51.          var2.setConstraints(this.choices[var4], var3);
  52.          ((Container)this).add(this.choices[var4]);
  53.  
  54.          for(int var5 = 0; var5 < values[var4].length; ++var5) {
  55.             this.choices[var4].addItem(values[var4][var5]);
  56.          }
  57.       }
  58.  
  59.       this.dismiss = new Button("Dismiss");
  60.       var3.gridwidth = 0;
  61.       var2.setConstraints(this.dismiss, var3);
  62.       ((Container)this).add(this.dismiss);
  63.       ((Window)this).pack();
  64.       this.choices[0].select("Hextile");
  65.       this.choices[1].select("Yes");
  66.       this.choices[2].select("Normal");
  67.       this.choices[3].select("Reliable");
  68.       this.choices[4].select("Fast");
  69.       this.choices[5].select("No");
  70.  
  71.       for(int var8 = 0; var8 < names.length; ++var8) {
  72.          String var6 = this.field_0.readParameter(names[var8], false);
  73.          if (var6 != null) {
  74.             for(int var7 = 0; var7 < values[var8].length; ++var7) {
  75.                if (var6.equalsIgnoreCase(values[var8][var7])) {
  76.                   this.choices[var8].select(var7);
  77.                }
  78.             }
  79.          }
  80.       }
  81.  
  82.       this.setEncodings();
  83.       this.setOtherOptions();
  84.    }
  85.  
  86.    void disableShareDesktop() {
  87.       this.labels[5].disable();
  88.       this.choices[5].disable();
  89.    }
  90.  
  91.    void setEncodings() {
  92.       this.nEncodings = 0;
  93.       if (this.choices[1].getSelectedItem().equals("Yes")) {
  94.          this.encodings[this.nEncodings++] = 1;
  95.       }
  96.  
  97.       byte var1 = 0;
  98.       if (this.choices[0].getSelectedItem().equals("RRE")) {
  99.          var1 = 2;
  100.       } else if (this.choices[0].getSelectedItem().equals("CoRRE")) {
  101.          var1 = 4;
  102.       } else if (this.choices[0].getSelectedItem().equals("Hextile")) {
  103.          var1 = 5;
  104.       }
  105.  
  106.       if (var1 == 0) {
  107.          this.choices[3].select("Fast");
  108.          this.drawEachPixelForRawRects = false;
  109.       }
  110.  
  111.       this.encodings[this.nEncodings++] = var1;
  112.       if (var1 != 2) {
  113.          this.encodings[this.nEncodings++] = 2;
  114.       }
  115.  
  116.       if (var1 != 4) {
  117.          this.encodings[this.nEncodings++] = 4;
  118.       }
  119.  
  120.       if (var1 != 5) {
  121.          this.encodings[this.nEncodings++] = 5;
  122.       }
  123.  
  124.       this.field_0.setEncodings();
  125.    }
  126.  
  127.    void setOtherOptions() {
  128.       this.reverseMouseButtons2And3 = this.choices[2].getSelectedItem().equals("Reversed");
  129.       this.drawEachPixelForRawRects = this.choices[3].getSelectedItem().equals("Reliable");
  130.       this.copyRectFast = this.choices[4].getSelectedItem().equals("Fast");
  131.       this.shareDesktop = this.choices[5].getSelectedItem().equals("Yes");
  132.    }
  133.  
  134.    public boolean action(Event var1, Object var2) {
  135.       if (var1.target == this.dismiss) {
  136.          ((Component)this).hide();
  137.          return true;
  138.       } else if (var1.target != this.choices[0] && var1.target != this.choices[1]) {
  139.          if (var1.target != this.choices[2] && var1.target != this.choices[3] && var1.target != this.choices[4] && var1.target != this.choices[5]) {
  140.             return false;
  141.          } else {
  142.             this.setOtherOptions();
  143.             return true;
  144.          }
  145.       } else {
  146.          this.setEncodings();
  147.          return true;
  148.       }
  149.    }
  150. }
  151.