home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc102 / Buttons / Src / SDKCtrlPnl.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  18.9 KB  |  679 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import java.awt.Insets;
  6. import java.awt.Image;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import com.ms.ui.*;
  10. import com.ms.fx.*;
  11. import com.ms.util.*;
  12.  
  13. public class SDKCtrlPnl extends UIPanel implements SDKConsts, SDKCallbacks
  14. {
  15.     private UIPanel panel;
  16.     private UIGroup main, stsgrp, btntst;
  17.     private BtnPanel btns;
  18.     private BtnTstPanel btntstpnl;
  19.     private SDKInsetPanelBL ipanel;
  20.     private UIText btntype, btnstyle, btnstate;
  21.  
  22.     public SDKCtrlPnl(UIApplet applet, UIFrame frame)
  23.     {
  24.         SDKImages.init(applet, frame);
  25.  
  26.         setLayout(new UIBorderLayout(0,0));
  27.  
  28.         // Create button UIPanel
  29.         btns = new BtnPanel(this);
  30.  
  31.         // Create Button Test Panel
  32.         btntst = new UIGroup("Button Test Area");
  33.         btntst.setLayout(new UIBorderLayout(0,0));
  34.         btntstpnl = new BtnTstPanel(this);
  35.         btntst.add(btntstpnl, "Center");
  36.  
  37.         // Create UIPanel for btns and btntst
  38.         panel = new UIPanel();
  39.         panel.setLayout(new UISplitLayout(0, 135));
  40.         panel.add(btns,"nw"); panel.add(btntst,"se");
  41.  
  42.         // Create UIGroup for displaying button status information
  43.         stsgrp = new UIGroup("Button Status");
  44.         stsgrp.setLayout(new UISplitLayout(0, 90));
  45.  
  46.         SDKInsetPanelGL ipnlgl;
  47.         ipnlgl = new SDKInsetPanelGL(0,0,0,0);
  48.         ipnlgl.add(new UIText( "Button TYPE:", UIStatic.RIGHT));
  49.         ipnlgl.add(new UIText("Button STYLE:", UIStatic.RIGHT));
  50.         ipnlgl.add(new UIText("Button STATE:", UIStatic.RIGHT));
  51.         stsgrp.add(ipnlgl, "nw");
  52.  
  53.         ipnlgl = new SDKInsetPanelGL(0,5,0,0);
  54.         btntype = new UIText("", UIStatic.LEFT);
  55.         btnstyle = new UIText("", UIStatic.LEFT);
  56.         btnstate = new UIText("", UIStatic.LEFT);
  57.         btnstate.setFont(new FxFont("Dialog", FxFont.BOLD, 12));
  58.         ipnlgl.add(btntype); ipnlgl.add(btnstyle); ipnlgl.add(btnstate);
  59.         stsgrp.add(ipnlgl, "se");
  60.  
  61.         // Initialize Status panel w/ UIPushButton status (one button at a time
  62.         //  is enabled, we start w/ UIPushButton
  63.         displayTestBtn(B_PUSH); setStatusPush();
  64.  
  65.         // Create main UIGroup, add to this UIPanel
  66.         main = new UIGroup("You don't wear these BUTTONS on your lapel");
  67.         add(main, "Center");
  68.         main.setLayout(new UISplitLayout(UISplitLayout.HORIZONTAL, 264));
  69.         // Add button and button test panels on top and status panel on bottom.
  70.         main.add(panel, "nw"); 
  71.         ipanel = new SDKInsetPanelBL(3,0,0,0); ipanel.add(stsgrp, "Center");
  72.         main.add(ipanel, "se");
  73.     }
  74.  
  75.     public void setStatusPush()
  76.     {
  77.         int style = 0;
  78.         String str = new String("");
  79.  
  80.         btntype.setName("UIPushButton");
  81.         if ( btns.raised.isChecked() ) {
  82.             str += "UIPushButton.RAISED";
  83.             style |= UIPushButton.RAISED;
  84.         }
  85.  
  86.         if ( btns.thick.isChecked() ) {
  87.             if ( str.length() != 0 ) str += " | ";
  88.             str += "UIPushButton.THICK";
  89.             style |= UIPushButton.THICK;
  90.         }
  91.         if ( btns.ptgl.isChecked() ) {
  92.             if ( str.length() != 0 ) str += " | ";
  93.             str += "UIButton.TOGGLE";
  94.             style |= UIButton.TOGGLE;
  95.         }
  96.         else { // If TOGGLE is turned off PushButton can't be checked
  97.             if ( btntstpnl.pbtn.isChecked() )
  98.                 btntstpnl.pbtn.setChecked(false);
  99.         }
  100.         btntstpnl.pbtn.setStyle(style);
  101.         btnstyle.setName(str);
  102.         if ( btntstpnl.pbtn.isChecked() ) {
  103.             btnstate.setName("Checked");
  104.             btnstate.setForeground(BaseColor.getColor(new FxColor(255,0,0)));
  105.         }
  106.         else {
  107.             btnstate.setName("UNChecked");
  108.             btnstate.setForeground(BaseColor.getColor(new FxColor(0,191,0)));
  109.         }
  110.         // This will ensure pbtn repaints properly
  111.         btntstpnl.pbtn.setVisible(false);
  112.         btntstpnl.pbtn.setVisible(true);
  113.         btnstate.setValid(true);
  114.     }
  115.  
  116.     public void setStatusCheck()
  117.     {
  118.         int style = 0;
  119.         String str = new String("");
  120.  
  121.         btntype.setName("UICheckButton");
  122.  
  123.         if ( btns.ctgl.isChecked() ) {
  124.             str += "UIButton.TRITOGGLE";
  125.             style = UIButton.TRITOGGLE;
  126.         }
  127.         else {
  128.             str += "UIButton.TOGGLE";
  129.             // if not TRITOGGLE can't be indeterminate
  130.             if ( btntstpnl.cbtn.isIndeterminate() )
  131.                 btntstpnl.cbtn.setIndeterminate(false);
  132.             style = UIButton.TOGGLE;
  133.         }
  134.  
  135.         btntstpnl.cbtn.setStyle(style);
  136.         btnstyle.setName(str);
  137.  
  138.         if ( btntstpnl.cbtn.isChecked() ) {
  139.             btnstate.setName("Checked");
  140.             btnstate.setForeground(BaseColor.getColor(new FxColor(255,0,0)));
  141.         }
  142.         else {
  143.             if ( btntstpnl.cbtn.isIndeterminate() ) {
  144.                 btnstate.setName("Indeterminate");
  145.                 btnstate.setForeground(BaseColor.getColor(new FxColor(255,255,0)));
  146.             }
  147.             else {
  148.                 btnstate.setName("UNChecked");
  149.                 btnstate.setForeground(BaseColor.getColor(new FxColor(0,191,0)));
  150.             }
  151.         }
  152.         btnstate.setValid(true);
  153.     }
  154.  
  155.     private void repaintAll(IUIComponent comp)
  156.     {
  157.         FxGraphics g = comp.getGraphics();
  158.         if (g != null)
  159.         {
  160.             comp.paintAll(g);
  161.             g.dispose();
  162.         }
  163.     }
  164.  
  165.     public void repaintCheck() { repaintAll(btntstpnl.cbtn); }
  166.  
  167.     public void setStatusRadio()
  168.     {
  169.         btntype.setName("UIRadioButton");
  170.         btnstyle.setName("UIButton.TOGGLE");
  171.         if ( btntstpnl.rbtn.isChecked() ) {
  172.             btnstate.setName("Checked");
  173.             btnstate.setForeground(BaseColor.getColor(new FxColor(255,0,0)));
  174.         }
  175.         else {
  176.             btnstate.setName("UNChecked");
  177.             btnstate.setForeground(BaseColor.getColor(new FxColor(0,191,0)));
  178.         }
  179.         btnstate.setValid(true);
  180.     }
  181.  
  182.     public void setEnabledRadio() { btntstpnl.rbtn.setEnabled(!btns.rdis.isChecked()); }
  183.  
  184.     public void repaintRadio()
  185.     { 
  186.         btntstpnl.rbtn.setValid(true);
  187.         repaintAll(btntstpnl.rbtn);
  188.     }
  189.  
  190.     public void setStatusRepeat()
  191.     {
  192.         btntype.setName("UIRepeatButton");
  193.         btnstyle.setName("");
  194.         btnstate.setName("UNChecked");
  195.         btnstate.setForeground(BaseColor.getColor(new FxColor(0,191,0)));
  196.         btnstate.setValid(true);
  197.     }
  198.  
  199.     public void setEnabledRepeat()
  200.     {
  201.         boolean enabled = !btns.rptdis.isChecked();
  202.         btntstpnl.rptitem.setImage(enabled ? SDKImages.get(HOLDME) : 
  203.                                              SDKImages.get(HOLDME_DIS));
  204.         btntstpnl.rptitem.setValid(true);
  205.         btntstpnl.rptbtn.setEnabled(enabled);
  206.     }
  207.  
  208.     public void displayTestBtn(int btn)
  209.     {
  210.         btntstpnl.removeAll();
  211.  
  212.         switch ( btn ) {
  213.         case B_PUSH: btntstpnl.add(btntstpnl.ppanel,"nw"); break;
  214.         case B_CHECK: btntstpnl.add(btntstpnl.cpanel,"nw"); break;
  215.         case B_RADIO: btntstpnl.add(btntstpnl.rpanel,"nw"); break;
  216.         case B_REPEAT: btntstpnl.add(btntstpnl.rptpnl,"nw"); break;
  217.         }
  218.         btntstpnl.add(btntstpnl.display, "se");
  219.     }
  220.  
  221.     public boolean isCustomCheck() { return btns.ccstm.isChecked(); }
  222.  
  223.     public boolean isCustomRadio() { return btns.rcstm.isChecked(); }
  224.  
  225.     public Insets getInsets() { return new Insets(0,5,5,5); }
  226. }
  227.  
  228. class BtnPanel extends UIPanel implements SDKConsts
  229. {
  230.     public UIRadioButton push, rpt, chk, rad;
  231.     public UICheckButton raised, thick, ptgl, rcstm, ccstm, ctgl, bgnd;
  232.     public UICheckButton rdis, rptdis;
  233.  
  234.     private SDKCallbacks ctrl;
  235.     private UIGroup types; //, contnt;
  236.     private SDKInsetPanelVFL ipnl1, ipnl2;
  237.  
  238.     public BtnPanel(SDKCallbacks ctrl)
  239.     {
  240.         this.ctrl = ctrl;
  241.  
  242.         setLayout(new UIBorderLayout(0,0));
  243.         types = new UIGroup("Button Types");
  244.         types.setLayout(new UIVerticalFlowLayout(UIVerticalFlowLayout.FILL, 0));
  245.  
  246.         add(types, "Center");
  247.  
  248.         push = new UIRadioButton("UIPushButton"); push.setChecked(true);
  249.         raised = new UICheckButton("RAISED"); raised.setChecked(true);
  250.         thick = new UICheckButton("THICK"); thick.setChecked(true);
  251.         ptgl = new UICheckButton("TOGGLE"); ptgl.setChecked(true);
  252.         
  253.         chk = new UIRadioButton("UICheckButton"); 
  254.         ctgl = new UICheckButton("TRITOGGLE"); ctgl.setChecked(true); ctgl.setEnabled(false);
  255.         ccstm = new UICheckButton("Custom"); ccstm.setChecked(true); ccstm.setEnabled(false);
  256.  
  257.         rad = new UIRadioButton("UIRadioButton"); 
  258.         rcstm = new UICheckButton("Custom"); rcstm.setChecked(true); rcstm.setEnabled(false);
  259.         rdis = new UICheckButton("Disabled"); rdis.setEnabled(false);
  260.  
  261.         rpt = new UIRadioButton("UIRepeatButton"); 
  262.         rptdis = new UICheckButton("Disabled");
  263.  
  264.         // Add UIPushButton option and sub-options
  265.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0); ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  266.         ipnl1.add(push);
  267.         ipnl2.add(raised); ipnl2.add(thick); ipnl2.add(ptgl);
  268.         ipnl1.add(ipnl2); types.add(ipnl1);
  269.  
  270.         // Add UICheckButton option and sub-options
  271.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0);
  272.         ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  273.         ipnl1.add(chk);
  274.         ipnl2.add(ctgl); ipnl2.add(ccstm);
  275.         ipnl1.add(ipnl2); types.add(ipnl1);
  276.  
  277.         // Add UIRadioButton option and sub-options
  278.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0); ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  279.         ipnl1.add(rad);
  280.         ipnl2.add(rcstm); ipnl2.add(rdis);
  281.         ipnl1.add(ipnl2); types.add(ipnl1);
  282.  
  283.         // Add UIRepeatButton option
  284.         ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  285.         ipnl2.add(rptdis);
  286.         types.add(rpt); types.add(ipnl2);
  287.     }
  288.  
  289.     public boolean action(Event e, Object arg)
  290.     {
  291.         if ( arg instanceof UIButton ) {
  292.             if ( arg == push ) {
  293.                 push.setChecked(true); rpt.setChecked(false);
  294.                 chk.setChecked(false); rad.setChecked(false);
  295.                 raised.setEnabled(true); thick.setEnabled(true);
  296.                 ptgl.setEnabled(true);
  297.                 ctgl.setEnabled(false); ccstm.setEnabled(false);
  298.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  299.                 rptdis.setEnabled(false);
  300.                 ctrl.displayTestBtn(B_PUSH); ctrl.setStatusPush();
  301.             }
  302.             else if ( (arg == raised) || (arg == thick) || (arg == ptgl) )
  303.                 ctrl.setStatusPush();
  304.             else if ( arg == chk ) {
  305.                 push.setChecked(false); rpt.setChecked(false);
  306.                 chk.setChecked(true); rad.setChecked(false);
  307.                 raised.setEnabled(false); thick.setEnabled(false);
  308.                 ptgl.setEnabled(false);
  309.                 ctgl.setEnabled(true); ccstm.setEnabled(true);
  310.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  311.                 rptdis.setEnabled(false);
  312.                 ctrl.displayTestBtn(B_CHECK); ctrl.setStatusCheck();
  313.             }
  314.             else if ( arg == ctgl )
  315.                 ctrl.setStatusCheck();
  316.             else if ( arg == ccstm )
  317.                 ctrl.repaintCheck();
  318.             else if ( arg == rad ) {
  319.                 push.setChecked(false); rpt.setChecked(false);
  320.                 chk.setChecked(false); rad.setChecked(true);
  321.                 raised.setEnabled(false); thick.setEnabled(false);
  322.                 ptgl.setEnabled(false);
  323.                 ctgl.setEnabled(false);    ccstm.setEnabled(false);
  324.                 if ( !rdis.isChecked() )
  325.                     rcstm.setEnabled(true); 
  326.                 if ( !rcstm.isChecked() )
  327.                     rdis.setEnabled(true);
  328.                 rptdis.setEnabled(false);
  329.                 ctrl.displayTestBtn(B_RADIO); ctrl.setStatusRadio();
  330.             }
  331.             else if ( arg == rcstm ) {
  332.                 ctrl.repaintRadio();
  333.                 if ( rcstm.isChecked() )
  334.                     rdis.setEnabled(false);
  335.                 else
  336.                     rdis.setEnabled(true);
  337.             }
  338.             else if ( arg == rdis ) {
  339.                 ctrl.setEnabledRadio();
  340.                 if ( rdis.isChecked() )
  341.                     rcstm.setEnabled(false);
  342.                 else
  343.                     rcstm.setEnabled(true);
  344.             }
  345.             else if ( arg == rpt ) {
  346.                 push.setChecked(false); rpt.setChecked(true);
  347.                 chk.setChecked(false); rad.setChecked(false);
  348.                 raised.setEnabled(false); thick.setEnabled(false);
  349.                 ptgl.setEnabled(false); 
  350.                 ctgl.setEnabled(false); ccstm.setEnabled(false);
  351.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  352.                 rptdis.setEnabled(true);
  353.                 ctrl.displayTestBtn(B_REPEAT); ctrl.setStatusRepeat();
  354.             }
  355.             else if ( arg == rptdis )
  356.                 ctrl.setEnabledRepeat();
  357.         }
  358.     return super.action(e, arg);
  359.     }    
  360. }
  361.  
  362. class BtnTstPanel extends UIPanel implements SDKConsts, TimerListener
  363. {
  364.     public UIPushButton pbtn;
  365.     public CustomCheckButton cbtn;
  366.     public CustomRadioButton rbtn;
  367.     public UIRepeatButton rptbtn;
  368.     public DisplayPanel display; 
  369.     public SDKInsetPanelBL ppanel, cpanel, rpanel, rptpnl;
  370.     public UIGraphic anigrfc;
  371.     public UIItem rptitem;
  372.  
  373.     private SDKCallbacks ctrl;
  374.     private int imgindex, times;
  375.         private Timer timer;
  376.         com.ms.util.TaskManager myTm = null ;
  377.  
  378.     public BtnTstPanel(SDKCallbacks ctrl)
  379.     {
  380.         super();
  381.         this.ctrl = ctrl;
  382.  
  383.         imgindex = 0;
  384.         timer = null;
  385.  
  386.         setLayout(new UISplitLayout(0, 135));
  387.  
  388.         // Make test UIPushButton
  389.         UIItem item = new UIItem(SDKImages.get(PUSHME), "Press Me!", UIStatic.LEFT);
  390.         item.setFont(new FxFont("Dialog", FxFont.PLAIN, 14));
  391.         pbtn = new TTUIPushButton(item, 
  392.                                 UIPushButton.TOGGLE | UIPushButton.RAISED | 
  393.                                 UIPushButton.THICK);
  394.         ppanel = new SDKInsetPanelBL(0,5,175,10); ppanel.add(pbtn, "Center");
  395.  
  396.         UIText text;
  397.  
  398.         // Make test UICheckButton
  399.         text = new UIText("Check Me!", UIStatic.LEFT);
  400.         cbtn = new CustomCheckButton(text, UIButton.TRITOGGLE, ctrl);
  401.         cpanel = new SDKInsetPanelBL(64,0,131,10); cpanel.add(cbtn, "Center");
  402.  
  403.         // Make test UIRadioButton
  404.         text = new UIText("Turn Me On!", UIStatic.LEFT);
  405.         rbtn = new CustomRadioButton(text, ctrl);
  406.         rpanel = new SDKInsetPanelBL(123,0,72,10); rpanel.add(rbtn, "Center");
  407.  
  408.         // Make test UIRepeatButton
  409.         rptitem = new UIItem(SDKImages.get(HOLDME), "Hold Me Down!", 0, UIItem.ABOVE);
  410.         rptbtn = new TTUIRepeatButton(rptitem, UIPushButton.RAISED);
  411.         rptpnl = new SDKInsetPanelBL(167,5,0,10); rptpnl.add(rptbtn, "Center");
  412.  
  413.         // Create Animation panel
  414.         display = new DisplayPanel();
  415.         anigrfc = new UIGraphic(SDKImages.get(ANIMATION));
  416.         display.add(anigrfc, "Center");
  417.  
  418.         // Preload all of the animation image here.
  419.         for ( int i = 0 ; i < NUM_ANIMATE ; i++ )
  420.             Image img =    SDKImages.get( ANIMATION + i ) ;
  421.  
  422.     }
  423.  
  424.     
  425.     public boolean action (Event evt, Object arg)
  426.     {
  427.         if ( arg instanceof UIButton ) {
  428.             if ( arg == pbtn ) {
  429.                 animate();
  430.                 ctrl.setStatusPush(); 
  431.             }
  432.             else if ( arg == rptbtn ) {
  433.                 // Show next frame in animation
  434.                 imgindex = (imgindex + 1) % NUM_ANIMATE;
  435.                 anigrfc.setImage(SDKImages.get(ANIMATION+imgindex));
  436.                 anigrfc.setValid(true);
  437.                 ctrl.setStatusRepeat();
  438.             }
  439.             else if ( arg == cbtn ) {
  440.                 animate();
  441.                 ctrl.setStatusCheck();
  442.             }
  443.             else if ( arg == rbtn ) {
  444.                 animate();
  445.                 ctrl.setStatusRadio();
  446.             }
  447.         }
  448.         return super.action(evt, arg);
  449.     }
  450.  
  451.     private static AwtUIApplet findAwtUIAppletBelow(Component comp)
  452.     {
  453.         AwtUIApplet applet = null;
  454.  
  455.         if (comp instanceof AwtUIApplet)
  456.         {
  457.             applet = (AwtUIApplet)comp;
  458.         }
  459.         else if (comp instanceof Container)
  460.         {
  461.             Container cont = (Container)comp;
  462.             int count = cont.countComponents();
  463.             for (int i = 0; i < count; i++)
  464.             {
  465.                 comp = cont.getComponent(i);
  466.                 if (comp instanceof AwtUIApplet)
  467.                 {
  468.                     applet = (AwtUIApplet)comp;
  469.                     break;
  470.                 }
  471.             }
  472.         }
  473.  
  474.         return applet;
  475.     }
  476.  
  477.     private static AwtUIApplet findAwtUIApplet(Component comp)
  478.     {
  479.         AwtUIApplet applet = null;
  480.  
  481.         if (comp != null)
  482.         {
  483.             for (;;)
  484.             {
  485.                 if (comp instanceof AwtUIApplet)
  486.                 {
  487.                     applet = (AwtUIApplet)comp;
  488.                     break;
  489.                 }
  490.  
  491.                 Component parent = comp.getParent();
  492.                 if (parent == null)
  493.                 {
  494.                     applet = findAwtUIAppletBelow(comp);
  495.                     break;
  496.                 }
  497.  
  498.                 comp = parent;
  499.             }
  500.         }
  501.  
  502.         return applet;
  503.     }
  504.  
  505.     static TaskManager getTaskManager(Component comp)
  506.     {
  507.         AwtUIApplet found = findAwtUIAppletBelow(comp);
  508.  
  509.         if (found == null)
  510.             found = findAwtUIApplet(comp);
  511.  
  512.         return (found != null)? found.getTaskManager() : null;
  513.     }
  514.  
  515.     // This method is used to find what TaskManager should we use for the 
  516.     // specefied IUIComponent.
  517.     static TaskManager getTaskManager(IUIComponent uicomp)
  518.     {
  519.         TaskManager taskManager = null;
  520.  
  521.         if (uicomp != null)
  522.         {
  523.             IUIRootContainer root = uicomp.getRoot();
  524.             if (root != null)
  525.             {
  526.                 Component host = root.getHost();
  527.                 if (host != null)
  528.                     taskManager = getTaskManager(host);
  529.             }
  530.         }
  531.  
  532.         return taskManager;
  533.     }
  534.  
  535.     public void animate()
  536.     {                 
  537.         if ( timer != null )
  538.             timer.stop();
  539.  
  540.         // Try to find the TaskManager used in the AwtUIApplet. This TaskManager
  541.         // will be passed to the constructor of com.ms.util.Timer.
  542.         // This is used to get around the security exception when running as an applet 
  543.         // in Nav3.            
  544.         if ( myTm == null )
  545.            myTm = getTaskManager( this ) ;
  546.            
  547.  
  548.         times = 0;                
  549.         timer = new Timer( myTm, this, 65, true);
  550.  
  551.         timer.start();
  552.                 
  553.     }
  554.  
  555.         public void timeTriggered(TimerEvent te)
  556.     {
  557.         if ( te.getSource() == timer ) {
  558.             times++;
  559.             
  560.             imgindex++;            
  561.             if ( times == 4 )
  562.                 timer.stop();
  563.             anigrfc.setImage(SDKImages.get(ANIMATION + (imgindex % NUM_ANIMATE)));            
  564.             anigrfc.setValid(true);
  565.             
  566.         }
  567.     }
  568. }
  569.  
  570. class DisplayPanel extends UIPanel implements SDKConsts
  571. {
  572.     public DisplayPanel()
  573.     {
  574.         setLayout(new UIBorderLayout(0,0));
  575.         setBackground(BaseColor.getColor(new FxColor(0,0,0)));
  576.     }
  577.  
  578.     public Insets getInsets() { return new Insets(82,71,95,71); }
  579. }
  580.  
  581. class TTUIPushButton extends UIPushButton
  582. {
  583.     public TTUIPushButton(IUIComponent comp, int style) { super(comp, style); }
  584.  
  585.     // This will implement ToolTips
  586.     public String getHelp() {
  587.         return "Pressing button will\nmake globe rotate\none quarter revolution.";
  588.     }
  589. }
  590.  
  591. class TTUIRepeatButton extends UIRepeatButton
  592. {
  593.     public TTUIRepeatButton(IUIComponent comp, int style) { super(comp, style); }
  594.  
  595.     // This will implement ToolTips
  596.     public String getHelp() {
  597.         return "Holding down button\nwill cause globe to\nrotate continuously.";
  598.     }
  599. }
  600.  
  601. class CustomCheckButton extends UICheckButton implements SDKConsts
  602. {
  603.     private SDKCallbacks ctrl;
  604.     private Image on, off, ind;
  605.  
  606.     public CustomCheckButton(IUIComponent comp, int style, SDKCallbacks ctrl)
  607.     {
  608.         super(comp, style);
  609.         this.ctrl = ctrl;
  610.         on = SDKImages.get(CHECKBTN_ON); 
  611.         off = SDKImages.get(CHECKBTN); 
  612.         ind = SDKImages.get(CHECKBTN_IND);
  613.     }
  614.  
  615.     public void paintCheck(FxGraphics g)
  616.     {
  617.         if ( ctrl.isCustomCheck() ) {
  618.             if (g != null) {
  619.                 Image image;
  620.                 if ( isChecked() )
  621.                     image = on;
  622.                 else if ( isIndeterminate() )
  623.                     image = ind;
  624.                 else 
  625.                     image = off;
  626.                 g.drawImage(image, 0, (getSize().height - 32) / 2, this);
  627.             }            
  628.         }
  629.         else
  630.             super.paintCheck(g);
  631.     }
  632.  
  633.     public Insets getInsets()
  634.     {
  635.         Insets insets = super.getInsets();
  636.         if ( ctrl.isCustomCheck() )
  637.             insets.left += 14;
  638.         return(insets);
  639.     }
  640. }
  641.  
  642. class CustomRadioButton extends UIRadioButton implements SDKConsts
  643. {
  644.     private SDKCallbacks ctrl;
  645.     private Image off, on;
  646.  
  647.     public CustomRadioButton(IUIComponent comp, SDKCallbacks ctrl)
  648.     {
  649.         super(comp);
  650.         this.ctrl = ctrl;
  651.         off = SDKImages.get(RADIOBTN); on = SDKImages.get(RADIOBTN_ON);
  652.     }
  653.  
  654.     public void paintCheck(FxGraphics g)
  655.     {
  656.         if ( ctrl.isCustomRadio() ) {
  657.             if (g != null) {
  658.                 Image image;
  659.                 if ( isChecked() )
  660.                     image = on;
  661.                 else 
  662.                     image = off;
  663.                 g.clearRect(0,0, 30,40);
  664.                 g.drawImage(image, 0, (getSize().height - 32) / 2, this);
  665.             }            
  666.         }
  667.         else
  668.             super.paintCheck(g);
  669.     }
  670.  
  671.     public Insets getInsets()
  672.     {
  673.         Insets insets = super.getInsets();
  674.         if ( ctrl.isCustomRadio() )
  675.             insets.left += 16;
  676.         return(insets);
  677.     }
  678. }
  679.