home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / COMMON / TOOLS / VB / CABINETS / MSDAO350.CAB / icontrols / RichText / RichText.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-08  |  27.3 KB  |  1,393 lines

  1. package icontrols.RichText;
  2.  
  3. import com.ms.dll.DllLib;
  4. import com.ms.wd.app.Message;
  5. import com.ms.wd.core.Component;
  6. import com.ms.wd.core.Event;
  7. import com.ms.wd.core.EventHandler;
  8. import com.ms.wd.io.ByteStream;
  9. import com.ms.wd.io.File;
  10. import com.ms.wd.io.IDataStream;
  11. import com.ms.wd.ui.Color;
  12. import com.ms.wd.ui.Control;
  13. import com.ms.wd.ui.CreateParams;
  14. import com.ms.wd.util.Debug;
  15. import com.ms.wd.util.Root;
  16. import com.ms.wd.win32.DEVMODE;
  17. import com.ms.wd.win32.NMHDR;
  18. import com.ms.wd.win32.Util;
  19. import com.ms.wd.win32.Windows;
  20.  
  21. public class RichText extends Control {
  22.    public static final int SB_NONE = 0;
  23.    public static final int SB_ASNEEDED = 1;
  24.    public static final int SB_FORCED = 2;
  25.    public static final int ALIGN_MULTI = -1;
  26.    public static final int ALIGN_LEFT = 0;
  27.    public static final int ALIGN_RIGHT = 1;
  28.    public static final int ALIGN_CENTER = 2;
  29.    public static final int ATTRIBUTE_MIX = -1;
  30.    public static final int ATTRIBUTE_NONE = 0;
  31.    public static final int ATTRIBUTE_ALL = 1;
  32.    public static final int WHOLEWORD = 2;
  33.    public static final int MATCHCASE = 4;
  34.    public static final int NOHIGHLIGHT = 8;
  35.    public static final int RICHTEXT_FILE = 0;
  36.    public static final int PLAINTEXT_FILE = 1;
  37.    static final int INPUT = 0;
  38.    static final int OUTPUT = 1;
  39.    private static final Module mod = new Module();
  40.    private static final String NOT_SUPPORTED = "Not supported at Design time";
  41.    private static final String SZ_RTF_TAG = "{\\rtf";
  42.    private static final int CHAR_BUFFER_LEN = 512;
  43.    private static final Object EVENT_HSCROLL = new Object();
  44.    private static final Object EVENT_PROTECTED = new Object();
  45.    private static final Object EVENT_SELCHANGE = new Object();
  46.    private static final Object EVENT_VSCROLL = new Object();
  47.    private int bulletIndent = 0;
  48.    private String fileName = null;
  49.    private int hDC = 0;
  50.    private int maxLength = 0;
  51.    private int rightMargin = 0;
  52.    private int scrollBars = 1;
  53.    private int style = 32964;
  54.    private boolean wantTabs = true;
  55.    transient IDataStream bis = null;
  56.    transient IDataStream bos = null;
  57.    private transient int editStreamProcRoot = 0;
  58.    private transient boolean protectedError = false;
  59.    // $FF: synthetic field
  60.    private static Class class$com$ms$wd$win32$NMHDR;
  61.    // $FF: synthetic field
  62.    private static Class class$icontrols$RichText$ENDROPFILES;
  63.    // $FF: synthetic field
  64.    private static Class class$icontrols$RichText$ENPROTECTED;
  65.    // $FF: synthetic field
  66.    private static Class class$icontrols$RichText$CHARFORMAT;
  67.  
  68.    public int getSelBold() {
  69.       return this.getCharFormat(1, 1);
  70.    }
  71.  
  72.    public EventHandler getOnHScroll() {
  73.       return (EventHandler)((Component)this).getEventHandler(EVENT_HSCROLL);
  74.    }
  75.  
  76.    public EventHandler getOnVScroll() {
  77.       return (EventHandler)((Component)this).getEventHandler(EVENT_VSCROLL);
  78.    }
  79.  
  80.    protected void onHScroll(Event e) {
  81.       ((Component)this).fireEvent(EVENT_HSCROLL, e);
  82.    }
  83.  
  84.    protected void onVScroll(Event e) {
  85.       ((Component)this).fireEvent(EVENT_VSCROLL, e);
  86.    }
  87.  
  88.    public String getSelFontName() {
  89.       if (((Component)this).isDesignMode()) {
  90.          throw new RuntimeException("Not supported at Design time");
  91.       } else {
  92.          String selFontName = null;
  93.          if (((Control)this).isHandleCreated()) {
  94.             CHARFORMAT cf = new CHARFORMAT();
  95.             this.sendMessage(1082, true, cf);
  96.             if ((cf.dwMask & 536870912) != 0) {
  97.                selFontName = new String(cf.szFaceName);
  98.             }
  99.          }
  100.  
  101.          return selFontName;
  102.       }
  103.    }
  104.  
  105.    public void setSelBold(int selBold) {
  106.       this.setCharFormat(1, 1, selBold);
  107.    }
  108.  
  109.    public void setSelFontName(String selFontName) {
  110.       if (((Component)this).isDesignMode()) {
  111.          throw new RuntimeException("Not supported at Design time");
  112.       } else {
  113.          if (((Control)this).isHandleCreated()) {
  114.             CHARFORMAT cf = new CHARFORMAT();
  115.             cf.dwMask = 536870912;
  116.             int count = Math.min(selFontName.length(), 32);
  117.             selFontName.getChars(0, count - 1, cf.szFaceName, 0);
  118.             this.sendMessage(1092, 1, (CHARFORMAT)cf);
  119.          }
  120.  
  121.       }
  122.    }
  123.  
  124.    public void setSelStart(int selStart) {
  125.       if (((Component)this).isDesignMode()) {
  126.          throw new RuntimeException("Not supported at Design time");
  127.       } else {
  128.          if (((Control)this).isHandleCreated()) {
  129.             CHARRANGE range = new CHARRANGE();
  130.             range.cpMax = range.cpMin = selStart;
  131.             this.sendMessage(1079, 0, (CHARRANGE)range);
  132.             this.sendMessage(183);
  133.          }
  134.  
  135.       }
  136.    }
  137.  
  138.    public void setMultiLine(boolean multiLine) {
  139.       if (multiLine && (this.style & 4) == 0 || !multiLine && (this.style & 4) != 0) {
  140.          this.style = multiLine ? this.style | 4 : this.style & -5;
  141.          if (!((Component)this).isDesignMode() && ((Control)this).isHandleCreated()) {
  142.             ((Control)this).recreateHandle();
  143.          }
  144.       }
  145.  
  146.    }
  147.  
  148.    public void setText(String text) {
  149.       if (((Control)this).isHandleCreated()) {
  150.          this.streamIn(text, 1);
  151.       }
  152.  
  153.    }
  154.  
  155.    public void setWantTabs(boolean wantTabs) {
  156.       this.wantTabs = wantTabs;
  157.    }
  158.  
  159.    private boolean isCharInCharSet(char c, String charSet, boolean negate) {
  160.       boolean match = false;
  161.       int charSetLen = charSet.length();
  162.  
  163.       for(int i = 0; !match && i < charSetLen; ++i) {
  164.          match = c == charSet.charAt(i);
  165.       }
  166.  
  167.       if (negate) {
  168.          return !match;
  169.       } else {
  170.          return match;
  171.       }
  172.    }
  173.  
  174.    protected CreateParams getCreateParams() {
  175.       CreateParams cp = super.getCreateParams();
  176.       cp.className = "RICHEDIT";
  177.       cp.style &= -1;
  178.       cp.style |= this.style;
  179.       if (this.scrollBars == 1) {
  180.          cp.style |= 3145728;
  181.       } else if (this.scrollBars == 2) {
  182.          cp.style |= 3153920;
  183.       }
  184.  
  185.       cp.exStyle |= 512;
  186.       return cp;
  187.    }
  188.  
  189.    public void addOnSelChange(EventHandler value) {
  190.       ((Component)this).addEventHandler(EVENT_SELCHANGE, value);
  191.    }
  192.  
  193.    protected int sendMessage(int msg) {
  194.       return Windows.SendMessage(((Control)this).getHandle(), msg, 0, 0);
  195.    }
  196.  
  197.    protected int sendMessage(int msg, boolean wParam) {
  198.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, 0);
  199.    }
  200.  
  201.    protected int sendMessage(int msg, boolean wParam, boolean lParam) {
  202.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  203.    }
  204.  
  205.    protected int sendMessage(int msg, boolean wParam, CHARFORMAT lParam) {
  206.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  207.    }
  208.  
  209.    protected int sendMessage(int msg, boolean wParam, int lParam) {
  210.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  211.    }
  212.  
  213.    public int getSelAlignment() {
  214.       if (((Component)this).isDesignMode()) {
  215.          throw new RuntimeException("Not supported at Design time");
  216.       } else {
  217.          int selAlignment = 0;
  218.          if (((Control)this).isHandleCreated()) {
  219.             PARAFORMAT pf = new PARAFORMAT();
  220.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  221.             if ((8 & pf.dwMask) != 0) {
  222.                switch (pf.wAlignment) {
  223.                   case 1:
  224.                      selAlignment = 0;
  225.                      break;
  226.                   case 2:
  227.                      selAlignment = 1;
  228.                      break;
  229.                   case 3:
  230.                      selAlignment = 2;
  231.                      break;
  232.                   default:
  233.                      Debug.assert(false, "RichText - getSelAlignment: Unknown PFA alignment type");
  234.                }
  235.             }
  236.          }
  237.  
  238.          return selAlignment;
  239.       }
  240.    }
  241.  
  242.    public int getSelHangingIndent() {
  243.       if (((Component)this).isDesignMode()) {
  244.          throw new RuntimeException("Not supported at Design time");
  245.       } else {
  246.          int selHangingIndent = 0;
  247.          if (((Control)this).isHandleCreated()) {
  248.             PARAFORMAT pf = new PARAFORMAT();
  249.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  250.             if ((4 & pf.dwMask) != 0) {
  251.                selHangingIndent = pf.dxOffset;
  252.             }
  253.          }
  254.  
  255.          return selHangingIndent;
  256.       }
  257.    }
  258.  
  259.    public int getSelIndent() {
  260.       if (((Component)this).isDesignMode()) {
  261.          throw new RuntimeException("Not supported at Design time");
  262.       } else {
  263.          int selIndent = 0;
  264.          if (((Control)this).isHandleCreated()) {
  265.             PARAFORMAT pf = new PARAFORMAT();
  266.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  267.             if ((1 & pf.dwMask) != 0) {
  268.                selIndent = pf.dxStartIndent;
  269.             }
  270.          }
  271.  
  272.          return selIndent;
  273.       }
  274.    }
  275.  
  276.    public int getSelRightIndent() {
  277.       if (((Component)this).isDesignMode()) {
  278.          throw new RuntimeException("Not supported at Design time");
  279.       } else {
  280.          int selRightIndent = 0;
  281.          if (((Control)this).isHandleCreated()) {
  282.             PARAFORMAT pf = new PARAFORMAT();
  283.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  284.             if ((2 & pf.dwMask) != 0) {
  285.                selRightIndent = pf.dxRightIndent;
  286.             }
  287.          }
  288.  
  289.          return selRightIndent;
  290.       }
  291.    }
  292.  
  293.    protected int sendMessage(int msg, int wParam, CHARFORMAT lParam) {
  294.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  295.    }
  296.  
  297.    protected int sendMessage(int msg, int wParam, CHARRANGE lParam) {
  298.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  299.    }
  300.  
  301.    protected int sendMessage(int msg, int wParam, EDITSTREAM lParam) {
  302.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  303.    }
  304.  
  305.    protected int sendMessage(int msg, int wParam, FINDTEXT lParam) {
  306.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  307.    }
  308.  
  309.    protected int sendMessage(int msg, int wParam, PARAFORMAT lParam) {
  310.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  311.    }
  312.  
  313.    protected int sendMessage(int msg, int wParam, TEXTRANGE lParam) {
  314.       return RichEdit.SendMessage(((Control)this).getHandle(), msg, wParam, lParam);
  315.    }
  316.  
  317.    public void setSelAlignment(int selAlignment) {
  318.       if (((Component)this).isDesignMode()) {
  319.          throw new RuntimeException("Not supported at Design time");
  320.       } else {
  321.          if (((Control)this).isHandleCreated()) {
  322.             PARAFORMAT pf = new PARAFORMAT();
  323.             pf.dwMask = 8;
  324.             switch (selAlignment) {
  325.                case 0:
  326.                   pf.wAlignment = 1;
  327.                   break;
  328.                case 1:
  329.                   pf.wAlignment = 2;
  330.                   break;
  331.                case 2:
  332.                   pf.wAlignment = 3;
  333.                   break;
  334.                default:
  335.                   throw new IllegalArgumentException("setSelAlignment: Unknown selAlignment type");
  336.             }
  337.  
  338.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  339.          }
  340.  
  341.       }
  342.    }
  343.  
  344.    public void setSelHangingIndent(int selHangingIndent) {
  345.       if (((Component)this).isDesignMode()) {
  346.          throw new RuntimeException("Not supported at Design time");
  347.       } else {
  348.          if (((Control)this).isHandleCreated()) {
  349.             PARAFORMAT pf = new PARAFORMAT();
  350.             pf.dwMask = 4;
  351.             pf.dxOffset = selHangingIndent;
  352.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  353.          }
  354.  
  355.       }
  356.    }
  357.  
  358.    public void setSelIndent(int selIndent) {
  359.       if (((Component)this).isDesignMode()) {
  360.          throw new RuntimeException("Not supported at Design time");
  361.       } else {
  362.          if (((Control)this).isHandleCreated()) {
  363.             PARAFORMAT pf = new PARAFORMAT();
  364.             pf.dwMask = 1;
  365.             pf.dxStartIndent = selIndent;
  366.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  367.          }
  368.  
  369.       }
  370.    }
  371.  
  372.    public void setSelRightIndent(int selRightIndent) {
  373.       if (((Component)this).isDesignMode()) {
  374.          throw new RuntimeException("Not supported at Design time");
  375.       } else {
  376.          if (((Control)this).isHandleCreated()) {
  377.             PARAFORMAT pf = new PARAFORMAT();
  378.             pf.dwMask = 2;
  379.             pf.dxRightIndent = selRightIndent;
  380.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  381.          }
  382.  
  383.       }
  384.    }
  385.  
  386.    public int getLineFromChar(int charPos) {
  387.       return ((Control)this).sendMessage(1078, 0, charPos);
  388.    }
  389.  
  390.    public void upTo(String characterSet) {
  391.       this.spanUpTo(characterSet, true, false, false);
  392.    }
  393.  
  394.    public void upTo(String characterSet, boolean forward) {
  395.       this.spanUpTo(characterSet, forward, false, false);
  396.    }
  397.  
  398.    public void upTo(String characterSet, boolean forward, boolean negate) {
  399.       this.spanUpTo(characterSet, forward, negate, false);
  400.    }
  401.  
  402.    public void setReadOnly(boolean readOnly) {
  403.       this.style = readOnly ? this.style | 2048 : this.style & -2049;
  404.       if (!((Component)this).isDesignMode() && ((Control)this).isHandleCreated()) {
  405.          this.sendMessage(207, readOnly, 0);
  406.       }
  407.  
  408.    }
  409.  
  410.    public int getSelStrikeThru() {
  411.       return this.getCharFormat(8, 8);
  412.    }
  413.  
  414.    public void setSelStrikeThru(int selStrikeThru) {
  415.       this.setCharFormat(8, 8, selStrikeThru);
  416.    }
  417.  
  418.    public int getSelBullet() {
  419.       if (((Component)this).isDesignMode()) {
  420.          throw new RuntimeException("Not supported at Design time");
  421.       } else {
  422.          int selBullet = 0;
  423.          if (((Control)this).isHandleCreated()) {
  424.             PARAFORMAT pf = new PARAFORMAT();
  425.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  426.             if ((32 & pf.dwMask) != 0 && 1 == pf.wNumbering) {
  427.                selBullet = 1;
  428.             }
  429.          }
  430.  
  431.          return selBullet;
  432.       }
  433.    }
  434.  
  435.    public void setSelBullet(int selBullet) {
  436.       if (((Component)this).isDesignMode()) {
  437.          throw new RuntimeException("Not supported at Design time");
  438.       } else {
  439.          if (((Control)this).isHandleCreated()) {
  440.             PARAFORMAT pf = new PARAFORMAT();
  441.             pf.dwMask = 36;
  442.             switch (selBullet) {
  443.                case 0:
  444.                   pf.wNumbering = 0;
  445.                   pf.dxOffset = 0;
  446.                   break;
  447.                case 1:
  448.                   pf.wNumbering = 1;
  449.                   pf.dxOffset = this.bulletIndent;
  450.                   break;
  451.                default:
  452.                   throw new IllegalArgumentException("setSelBullet: Unknown selBullet type");
  453.             }
  454.  
  455.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  456.          }
  457.  
  458.       }
  459.    }
  460.  
  461.    public int getSelUnderline() {
  462.       return this.getCharFormat(4, 4);
  463.    }
  464.  
  465.    public boolean isMultiLine() {
  466.       return (this.style & 4) != 0;
  467.    }
  468.  
  469.    public void setSelUnderline(int selUnderline) {
  470.       this.setCharFormat(4, 4, selUnderline);
  471.    }
  472.  
  473.    void wmReflectNotify(Message m) {
  474.       if (m.hWnd == ((Control)this).getHandle()) {
  475.          NMHDR nmhdr = (NMHDR)DllLib.ptrToStruct(class$com$ms$wd$win32$NMHDR != null ? class$com$ms$wd$win32$NMHDR : (class$com$ms$wd$win32$NMHDR = class$("com.ms.wd.win32.NMHDR")), m.lParam);
  476.          switch (nmhdr.code) {
  477.             case 1794:
  478.                this.onSelChange(Event.EMPTY);
  479.                break;
  480.             case 1795:
  481.                ENDROPFILES endropfiles = (ENDROPFILES)DllLib.ptrToStruct(class$icontrols$RichText$ENDROPFILES != null ? class$icontrols$RichText$ENDROPFILES : (class$icontrols$RichText$ENDROPFILES = class$("icontrols.RichText.ENDROPFILES")), m.lParam);
  482.                StringBuffer path = new StringBuffer(260);
  483.                DragQueryFile(endropfiles.hDrop, 0, path, 260);
  484.  
  485.                try {
  486.                   this.loadFile(path.toString(), 0);
  487.                } catch (Exception var8) {
  488.                   try {
  489.                      this.loadFile(path.toString(), 1);
  490.                   } catch (Exception var7) {
  491.                   }
  492.                }
  493.  
  494.                m.result = 1;
  495.                break;
  496.             case 1796:
  497.                ENPROTECTED enprotected = (ENPROTECTED)DllLib.ptrToStruct(class$icontrols$RichText$ENPROTECTED != null ? class$icontrols$RichText$ENPROTECTED : (class$icontrols$RichText$ENPROTECTED = class$("icontrols.RichText.ENPROTECTED")), m.lParam);
  498.                switch (enprotected.msg) {
  499.                   case 12:
  500.                   case 1077:
  501.                      m.result = 0;
  502.                      return;
  503.                   case 194:
  504.                   case 1095:
  505.                      break;
  506.                   case 770:
  507.                      m.result = 1;
  508.                      return;
  509.                   case 1092:
  510.                      CHARFORMAT charFormat = (CHARFORMAT)DllLib.ptrToStruct(class$icontrols$RichText$CHARFORMAT != null ? class$icontrols$RichText$CHARFORMAT : (class$icontrols$RichText$CHARFORMAT = class$("icontrols.RichText.CHARFORMAT")), m.lParam);
  511.                      if ((charFormat.dwMask & 16) != 0) {
  512.                         m.result = 0;
  513.                         return;
  514.                      }
  515.                      break;
  516.                   case 1097:
  517.                      if ((enprotected.wParam & 'ΦÇÇ') == 0) {
  518.                         m.result = 0;
  519.                         return;
  520.                      }
  521.                      break;
  522.                   default:
  523.                      Windows.MessageBeep(0);
  524.                      m.result = 1;
  525.                      return;
  526.                }
  527.  
  528.                this.onProtected(Event.EMPTY);
  529.                m.result = 1;
  530.                break;
  531.             default:
  532.                super.wndProc(m);
  533.          }
  534.       } else {
  535.          super.wndProc(m);
  536.       }
  537.  
  538.    }
  539.  
  540.    public int getSelCharOffset() {
  541.       if (((Component)this).isDesignMode()) {
  542.          throw new RuntimeException("Not supported at Design time");
  543.       } else {
  544.          int selCharOffset = 0;
  545.          if (((Control)this).isHandleCreated()) {
  546.             CHARFORMAT cf = new CHARFORMAT();
  547.             this.sendMessage(1082, true, cf);
  548.             if ((cf.dwMask & 268435456) != 0) {
  549.                selCharOffset = cf.yOffset;
  550.             }
  551.          }
  552.  
  553.          return selCharOffset;
  554.       }
  555.    }
  556.  
  557.    public void setSelCharOffset(int selCharOffset) {
  558.       if (((Component)this).isDesignMode()) {
  559.          throw new RuntimeException("Not supported at Design time");
  560.       } else {
  561.          if (((Control)this).isHandleCreated()) {
  562.             CHARFORMAT cf = new CHARFORMAT();
  563.             cf.dwMask = 268435456;
  564.             cf.yOffset = selCharOffset;
  565.             this.sendMessage(1092, 1, (CHARFORMAT)cf);
  566.          }
  567.  
  568.       }
  569.    }
  570.  
  571.    public int[] getSelTabs() {
  572.       if (((Component)this).isDesignMode()) {
  573.          throw new RuntimeException("Not supported at Design time");
  574.       } else {
  575.          int[] selTabs = null;
  576.          if (((Control)this).isHandleCreated()) {
  577.             PARAFORMAT pf = new PARAFORMAT();
  578.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  579.             if ((16 & pf.dwMask) != 0) {
  580.                selTabs = new int[pf.cTabCount];
  581.  
  582.                for(int x = 0; x < pf.cTabCount; ++x) {
  583.                   selTabs[x] = pf.rgxTabs[x];
  584.                }
  585.             }
  586.          }
  587.  
  588.          return selTabs;
  589.       }
  590.    }
  591.  
  592.    public boolean isWantTabs() {
  593.       return this.wantTabs;
  594.    }
  595.  
  596.    public void setSelTabs(int[] selTabs) {
  597.       if (((Component)this).isDesignMode()) {
  598.          throw new RuntimeException("Not supported at Design time");
  599.       } else {
  600.          if (((Control)this).isHandleCreated()) {
  601.             PARAFORMAT pf = new PARAFORMAT();
  602.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  603.             pf.dwMask = 16;
  604.  
  605.             for(int x = 0; x < pf.cTabCount; ++x) {
  606.                pf.rgxTabs[x] = selTabs[x];
  607.             }
  608.  
  609.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  610.          }
  611.  
  612.       }
  613.    }
  614.  
  615.    // $FF: synthetic method
  616.    private static Class class$(String s) {
  617.       try {
  618.          return Class.forName(s);
  619.       } catch (ClassNotFoundException e) {
  620.          throw new NoClassDefFoundError(((Throwable)e).getMessage());
  621.       }
  622.    }
  623.  
  624.    public void setHideSelection(boolean hideSelection) {
  625.       this.style = hideSelection ? this.style | 256 : this.style & -257;
  626.       if (!((Component)this).isDesignMode() && ((Control)this).isHandleCreated()) {
  627.          this.sendMessage(1087, hideSelection, true);
  628.       }
  629.  
  630.    }
  631.  
  632.    public void dispose() {
  633.       if (this.hDC != 0) {
  634.          Windows.DeleteDC(this.hDC);
  635.       }
  636.  
  637.       super.dispose();
  638.    }
  639.  
  640.    public void selPrint() {
  641.       throw new RuntimeException("selPrint: Not Implemented.");
  642.    }
  643.  
  644.    public void addOnProtected(EventHandler value) {
  645.       ((Component)this).addEventHandler(EVENT_PROTECTED, value);
  646.    }
  647.  
  648.    public int find(String string) {
  649.       return this.find(string, 0, -1, 0);
  650.    }
  651.  
  652.    public int find(String string, int options) {
  653.       return this.find(string, 0, -1, options);
  654.    }
  655.  
  656.    public int find(String string, int start, int options) {
  657.       return this.find(string, start, -1, options);
  658.    }
  659.  
  660.    public int find(String string, int start, int end, int options) {
  661.       boolean selectWord = true;
  662.       FINDTEXT ft = new FINDTEXT();
  663.       int findOptions = 0;
  664.       ft.lpstrText = string;
  665.       if (start < 0) {
  666.          this.sendMessage(1076, 0, (CHARRANGE)ft.chrg);
  667.       } else {
  668.          if (start > 0) {
  669.             ft.chrg.cpMin = start;
  670.          } else {
  671.             ft.chrg.cpMin = 0;
  672.          }
  673.  
  674.          if (end >= 0) {
  675.             ft.chrg.cpMax = end;
  676.          } else {
  677.             ft.chrg.cpMax = -1;
  678.          }
  679.       }
  680.  
  681.       if (ft.chrg.cpMin == ft.chrg.cpMax) {
  682.          ft.chrg.cpMin = 0;
  683.          ft.chrg.cpMax = -1;
  684.       }
  685.  
  686.       if ((options & 2) != 0) {
  687.          findOptions |= 2;
  688.       }
  689.  
  690.       if ((options & 4) != 0) {
  691.          findOptions |= 4;
  692.       }
  693.  
  694.       if ((options & 8) != 0) {
  695.          selectWord = false;
  696.       }
  697.  
  698.       int position = this.sendMessage(1080, findOptions, (FINDTEXT)ft);
  699.       if (position != -1 || !selectWord) {
  700.          CHARRANGE chrg = new CHARRANGE();
  701.          chrg.cpMin = position;
  702.          chrg.cpMax = position + string.length();
  703.          this.sendMessage(1079, 0, (CHARRANGE)chrg);
  704.          this.sendMessage(183);
  705.       }
  706.  
  707.       return position;
  708.    }
  709.  
  710.    public Color getSelColor() {
  711.       if (((Component)this).isDesignMode()) {
  712.          throw new RuntimeException("Not supported at Design time");
  713.       } else {
  714.          Color selColor = new Color(Windows.GetSysColor(8));
  715.          if (((Control)this).isHandleCreated()) {
  716.             CHARFORMAT cf = new CHARFORMAT();
  717.             this.sendMessage(1082, true, cf);
  718.             if ((cf.dwMask & 1073741824) != 0) {
  719.                selColor = new Color(cf.crTextColor);
  720.             }
  721.          }
  722.  
  723.          return selColor;
  724.       }
  725.    }
  726.  
  727.    private boolean isProtectedError() {
  728.       if (this.protectedError) {
  729.          this.protectedError = false;
  730.          return true;
  731.       } else {
  732.          return false;
  733.       }
  734.    }
  735.  
  736.    public void setSelColor(Color selColor) {
  737.       if (((Component)this).isDesignMode()) {
  738.          throw new RuntimeException("Not supported at Design time");
  739.       } else {
  740.          if (((Control)this).isHandleCreated()) {
  741.             CHARFORMAT cf = new CHARFORMAT();
  742.             cf.dwMask = 1073741824;
  743.             cf.crTextColor = selColor.getRGB();
  744.             this.sendMessage(1092, 1, (CHARFORMAT)cf);
  745.          }
  746.  
  747.       }
  748.    }
  749.  
  750.    public boolean isHideSelection() {
  751.       return (this.style & 256) == 0;
  752.    }
  753.  
  754.    public void setWantReturns(boolean wantReturns) {
  755.       this.style = wantReturns ? this.style | 4096 : this.style & -4097;
  756.       if (!((Component)this).isDesignMode() && ((Control)this).isHandleCreated()) {
  757.          ((Control)this).sendMessage(1101, 2, 4096);
  758.       }
  759.  
  760.    }
  761.  
  762.    public int getSelFontSize() {
  763.       if (((Component)this).isDesignMode()) {
  764.          throw new RuntimeException("Not supported at Design time");
  765.       } else {
  766.          int selFontSize = 0;
  767.          if (((Control)this).isHandleCreated()) {
  768.             CHARFORMAT cf = new CHARFORMAT();
  769.             this.sendMessage(1082, true, cf);
  770.             if ((cf.dwMask & Integer.MIN_VALUE) != 0) {
  771.                selFontSize = cf.yHeight;
  772.             }
  773.          }
  774.  
  775.          return selFontSize;
  776.       }
  777.    }
  778.  
  779.    public void setSelFontSize(int selFontSize) {
  780.       if (((Component)this).isDesignMode()) {
  781.          throw new RuntimeException("Not supported at Design time");
  782.       } else {
  783.          if (((Control)this).isHandleCreated()) {
  784.             CHARFORMAT cf = new CHARFORMAT();
  785.             cf.dwMask = Integer.MIN_VALUE;
  786.             cf.yHeight = selFontSize;
  787.             this.sendMessage(1092, 1, (CHARFORMAT)cf);
  788.          }
  789.  
  790.       }
  791.    }
  792.  
  793.    private void spanUpTo(String characterSet, boolean forward, boolean negate, boolean span) {
  794.       if (characterSet.length() != 0) {
  795.          CHARRANGE chrg = new CHARRANGE();
  796.          this.sendMessage(1076, 0, (CHARRANGE)chrg);
  797.          CHARRANGE chrgSave = new CHARRANGE();
  798.          chrgSave.cpMin = chrg.cpMin;
  799.          chrgSave.cpMax = chrg.cpMax;
  800.          chrg.cpMax = chrg.cpMin;
  801.          TEXTRANGE txrg = new TEXTRANGE();
  802.          txrg.chrg.cpMin = chrg.cpMin;
  803.          txrg.chrg.cpMax = chrg.cpMax;
  804.          CharBuffer charBuffer = CharBuffer.createBuffer(513);
  805.          txrg.lpstrText = charBuffer.allocCoTaskMem();
  806.          if (txrg.lpstrText == 0) {
  807.             throw new RuntimeException("spanUpTo: Unable to get memory.");
  808.          } else {
  809.             boolean done = false;
  810.  
  811.             while(!done) {
  812.                if (forward) {
  813.                   txrg.chrg.cpMin = chrg.cpMax;
  814.                   CHARRANGE var10000 = txrg.chrg;
  815.                   var10000.cpMax += 512;
  816.                } else {
  817.                   txrg.chrg.cpMax = chrg.cpMin;
  818.                   CHARRANGE var16 = txrg.chrg;
  819.                   var16.cpMin -= 512;
  820.                   if (txrg.chrg.cpMin < 0) {
  821.                      txrg.chrg.cpMin = 0;
  822.                   }
  823.                }
  824.  
  825.                int len = this.sendMessage(1099, 0, (TEXTRANGE)txrg);
  826.                if (len == 0) {
  827.                   break;
  828.                }
  829.  
  830.                charBuffer.putCoTaskMem(txrg.lpstrText);
  831.                String str = charBuffer.getString();
  832.                if (forward) {
  833.                   for(int x = 0; x < len; ++x) {
  834.                      boolean found = this.isCharInCharSet(str.charAt(x), characterSet, negate);
  835.                      if (span ? !found : found) {
  836.                         done = true;
  837.                         break;
  838.                      }
  839.  
  840.                      ++chrg.cpMax;
  841.                   }
  842.                } else {
  843.                   for(int x = len; x-- != 0; chrg.cpMin += -1) {
  844.                      boolean found = this.isCharInCharSet(str.charAt(x), characterSet, negate);
  845.                      if (span ? !found : found) {
  846.                         done = true;
  847.                         break;
  848.                      }
  849.                   }
  850.                }
  851.             }
  852.  
  853.             if (txrg.lpstrText != 0) {
  854.                DllLib.freeCoTaskMem(txrg.lpstrText);
  855.             }
  856.  
  857.             if (chrg.cpMin == chrg.cpMax) {
  858.                chrg.cpMin = chrgSave.cpMin;
  859.                chrg.cpMax = chrgSave.cpMax;
  860.             } else if (!span) {
  861.                if (forward) {
  862.                   chrg.cpMin = chrg.cpMax;
  863.                } else {
  864.                   chrg.cpMax = chrg.cpMin;
  865.                }
  866.             }
  867.  
  868.             this.sendMessage(1079, 0, (CHARRANGE)chrg);
  869.             this.sendMessage(183);
  870.          }
  871.       }
  872.    }
  873.  
  874.    public int getBulletIndent() {
  875.       return this.bulletIndent;
  876.    }
  877.  
  878.    public void setBulletIndent(int bulletIndent) {
  879.       this.bulletIndent = bulletIndent;
  880.    }
  881.  
  882.    private void wmReflectCommand(Message m) {
  883.       if (m.lParam == ((Control)this).getHandle()) {
  884.          switch (Util.HIWORD(m.wParam)) {
  885.             case 768:
  886.                ((Control)this).onChange(Event.EMPTY);
  887.                break;
  888.             case 1537:
  889.                this.onHScroll(Event.EMPTY);
  890.                break;
  891.             case 1538:
  892.                this.onVScroll(Event.EMPTY);
  893.                break;
  894.             default:
  895.                super.wndProc(m);
  896.          }
  897.       } else {
  898.          super.wndProc(m);
  899.       }
  900.  
  901.    }
  902.  
  903.    public int getMaxLength() {
  904.       return this.maxLength;
  905.    }
  906.  
  907.    private int getCharFormat(int mask, int effect) {
  908.       if (((Component)this).isDesignMode()) {
  909.          throw new RuntimeException("Not supported at Design time");
  910.       } else {
  911.          int charFormat = 0;
  912.          if (((Control)this).isHandleCreated()) {
  913.             CHARFORMAT cf = new CHARFORMAT();
  914.             this.sendMessage(1082, true, cf);
  915.             if ((cf.dwMask & mask) != 0 && (cf.dwEffects & effect) != 0) {
  916.                charFormat = 1;
  917.             }
  918.          }
  919.  
  920.          return charFormat;
  921.       }
  922.    }
  923.  
  924.    public boolean isReadOnly() {
  925.       return (this.style & 2048) != 0;
  926.    }
  927.  
  928.    public void setCharFormat(int mask, int effect, int charFormat) {
  929.       if (((Component)this).isDesignMode()) {
  930.          throw new RuntimeException("Not supported at Design time");
  931.       } else {
  932.          if (((Control)this).isHandleCreated()) {
  933.             CHARFORMAT cf = new CHARFORMAT();
  934.             cf.dwMask = mask;
  935.             switch (charFormat) {
  936.                case 0:
  937.                   cf.dwEffects = 0;
  938.                   break;
  939.                case 1:
  940.                   cf.dwEffects = effect;
  941.                   break;
  942.                default:
  943.                   throw new IllegalArgumentException("Unknown ATTRIBUTE type");
  944.             }
  945.  
  946.             this.sendMessage(1092, 1, (CHARFORMAT)cf);
  947.          }
  948.  
  949.       }
  950.    }
  951.  
  952.    public void setMaxLength(int maxLength) {
  953.       this.maxLength = maxLength;
  954.       if (!((Component)this).isDesignMode() && ((Control)this).isHandleCreated()) {
  955.          ((Control)this).sendMessage(1077, 0, maxLength == 0 ? 268435455 : maxLength);
  956.       }
  957.  
  958.    }
  959.  
  960.    public String getSelRichText() {
  961.       if (((Component)this).isDesignMode()) {
  962.          throw new RuntimeException("Not supported at Design time");
  963.       } else {
  964.          return ((Control)this).isHandleCreated() ? this.streamOut(32770) : "";
  965.       }
  966.    }
  967.  
  968.    public void setSelRichText(String selRichText) {
  969.       if (((Component)this).isDesignMode()) {
  970.          throw new RuntimeException("Not supported at Design time");
  971.       } else {
  972.          if (((Control)this).isHandleCreated()) {
  973.             this.streamIn(selRichText, 32770);
  974.          }
  975.  
  976.       }
  977.    }
  978.  
  979.    public void loadFile(String path) {
  980.       this.loadFile(path, 0);
  981.    }
  982.  
  983.    public synchronized void loadFile(String path, int fileType) {
  984.       boolean fileLoaded = false;
  985.       int type;
  986.       switch (fileType) {
  987.          case 0:
  988.             type = 2;
  989.             break;
  990.          case 1:
  991.             type = 1;
  992.             break;
  993.          default:
  994.             throw new IllegalArgumentException("loadFile: invalid fileType");
  995.       }
  996.  
  997.       try {
  998.          this.bis = File.open(path);
  999.          if (!this.bis.canSeek()) {
  1000.             throw new IllegalArgumentException("loadFile: path not a file");
  1001.          }
  1002.  
  1003.          if (type == 2) {
  1004.             String str = this.bis.getDataReader().readStringCharsAnsi("{\\rtf".length());
  1005.             if (!"{\\rtf".equals(str)) {
  1006.                throw new RuntimeException("loadFile: Invalid file format");
  1007.             }
  1008.  
  1009.             this.bis.setPosition(0L);
  1010.          }
  1011.  
  1012.          EDITSTREAM es = new EDITSTREAM();
  1013.          es.dwCookie = 0;
  1014.          es.pfnCallback = DllLib.addrOf(this.editStreamProcRoot);
  1015.          this.sendMessage(1097, type, (EDITSTREAM)es);
  1016.          ((File)this.bis).close();
  1017.          if (es.dwError != 0) {
  1018.             throw new RuntimeException("loadFile: Unable to load file");
  1019.          }
  1020.  
  1021.          this.sendMessage(185);
  1022.          fileLoaded = true;
  1023.       } finally {
  1024.          this.bis = null;
  1025.          if (fileLoaded) {
  1026.             this.fileName = path;
  1027.             if (!((Component)this).isDesignMode()) {
  1028.                this.sendMessage(186);
  1029.             }
  1030.          }
  1031.  
  1032.       }
  1033.  
  1034.    }
  1035.  
  1036.    public void addOnHScroll(EventHandler value) {
  1037.       ((Component)this).addEventHandler(EVENT_HSCROLL, value);
  1038.    }
  1039.  
  1040.    public void addOnVScroll(EventHandler value) {
  1041.       ((Component)this).addEventHandler(EVENT_VSCROLL, value);
  1042.    }
  1043.  
  1044.    public EventHandler getOnSelChange() {
  1045.       return (EventHandler)((Component)this).getEventHandler(EVENT_SELCHANGE);
  1046.    }
  1047.  
  1048.    protected void onSelChange(Event e) {
  1049.       ((Component)this).fireEvent(EVENT_SELCHANGE, e);
  1050.    }
  1051.  
  1052.    public int getRightMargin() {
  1053.       return this.rightMargin;
  1054.    }
  1055.  
  1056.    public void setRightMargin(int rightMargin) {
  1057.       if (this.rightMargin != rightMargin) {
  1058.          this.rightMargin = rightMargin;
  1059.          if (!((Component)this).isDesignMode()) {
  1060.             if (this.hDC != 0) {
  1061.                Windows.DeleteDC(this.hDC);
  1062.             }
  1063.  
  1064.             this.hDC = Windows.CreateIC("DISPLAY", (String)null, (String)null, (DEVMODE)null);
  1065.             if (((Control)this).isHandleCreated()) {
  1066.                ((Control)this).sendMessage(1096, this.hDC, rightMargin);
  1067.             }
  1068.          }
  1069.       }
  1070.  
  1071.    }
  1072.  
  1073.    public static native int DragQueryFile(int var0, int var1, StringBuffer var2, int var3);
  1074.  
  1075.    public void saveFile(String path) {
  1076.       this.saveFile(path, 0);
  1077.    }
  1078.  
  1079.    public synchronized void saveFile(String path, int fileType) {
  1080.       int type;
  1081.       switch (fileType) {
  1082.          case 0:
  1083.             type = 2;
  1084.             break;
  1085.          case 1:
  1086.             type = 1;
  1087.             break;
  1088.          default:
  1089.             throw new IllegalArgumentException("loadFile: invalid fileType");
  1090.       }
  1091.  
  1092.       try {
  1093.          this.bos = File.create(path);
  1094.          EDITSTREAM es = new EDITSTREAM();
  1095.          es.dwCookie = 1;
  1096.          es.pfnCallback = DllLib.addrOf(this.editStreamProcRoot);
  1097.          this.sendMessage(1098, type, (EDITSTREAM)es);
  1098.          ((File)this.bos).close();
  1099.          if (es.dwError != 0) {
  1100.             throw new RuntimeException("saveFile: Unable to save file.");
  1101.          }
  1102.       } finally {
  1103.          this.bos = null;
  1104.       }
  1105.  
  1106.    }
  1107.  
  1108.    public RichText() {
  1109.       synchronized(mod){}
  1110.  
  1111.       try {
  1112.          if (mod.handle == 0) {
  1113.             mod.handle = Windows.LoadLibrary("RichEd32.DLL");
  1114.          }
  1115.       } catch (Throwable var4) {
  1116.          throw var4;
  1117.       }
  1118.  
  1119.       this.editStreamProcRoot = Root.alloc(new EditStreamProc(this));
  1120.       ((Control)this).setStyle(2, false);
  1121.       ((Control)this).setTabStop(true);
  1122.    }
  1123.  
  1124.    public EventHandler getOnProtected() {
  1125.       return (EventHandler)((Component)this).getEventHandler(EVENT_PROTECTED);
  1126.    }
  1127.  
  1128.    public int getSelTabCount() {
  1129.       if (((Component)this).isDesignMode()) {
  1130.          throw new RuntimeException("Not supported at Design time");
  1131.       } else {
  1132.          int selTabCount = 0;
  1133.          if (((Control)this).isHandleCreated()) {
  1134.             PARAFORMAT pf = new PARAFORMAT();
  1135.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  1136.             if ((16 & pf.dwMask) != 0) {
  1137.                selTabCount = pf.cTabCount;
  1138.             }
  1139.          }
  1140.  
  1141.          return selTabCount;
  1142.       }
  1143.    }
  1144.  
  1145.    protected void onProtected(Event e) {
  1146.       this.protectedError = true;
  1147.       ((Component)this).fireEvent(EVENT_PROTECTED, e);
  1148.    }
  1149.  
  1150.    public void setSelTabCount(int selTabCount) {
  1151.       if (((Component)this).isDesignMode()) {
  1152.          throw new RuntimeException("Not supported at Design time");
  1153.       } else {
  1154.          if (((Control)this).isHandleCreated()) {
  1155.             if (selTabCount < 0 || selTabCount > 32) {
  1156.                throw new IllegalArgumentException("SelTabCount out of range");
  1157.             }
  1158.  
  1159.             PARAFORMAT pf = new PARAFORMAT();
  1160.             this.sendMessage(1085, 0, (PARAFORMAT)pf);
  1161.             pf.dwMask = 16;
  1162.             pf.cTabCount = (short)selTabCount;
  1163.             this.sendMessage(1095, 0, (PARAFORMAT)pf);
  1164.          }
  1165.  
  1166.       }
  1167.    }
  1168.  
  1169.    protected void wndProc(Message m) {
  1170.       switch (m.msg) {
  1171.          case 135:
  1172.             super.wndProc(m);
  1173.             m.result = this.wantTabs ? m.result | 2 : m.result & -3;
  1174.             break;
  1175.          case 48206:
  1176.             this.wmReflectNotify(m);
  1177.             break;
  1178.          case 48401:
  1179.             this.wmReflectCommand(m);
  1180.             break;
  1181.          default:
  1182.             super.wndProc(m);
  1183.       }
  1184.  
  1185.    }
  1186.  
  1187.    public static native void DragAcceptFiles(int var0, boolean var1);
  1188.  
  1189.    public boolean isWantReturns() {
  1190.       return (this.style & 4096) == 0;
  1191.    }
  1192.  
  1193.    public void createControl() {
  1194.       super.createControl();
  1195.       if (((Control)this).isHandleCreated()) {
  1196.          this.setMaxLength(this.maxLength);
  1197.          ((Control)this).sendMessage(1093, 0, 3801095);
  1198.          int rm = this.rightMargin;
  1199.          this.rightMargin = 0;
  1200.          this.setRightMargin(rm);
  1201.          if (!((Component)this).isDesignMode()) {
  1202.             DragAcceptFiles(((Control)this).getHandle(), true);
  1203.          }
  1204.       }
  1205.  
  1206.    }
  1207.  
  1208.    public int getSelItalic() {
  1209.       return this.getCharFormat(2, 2);
  1210.    }
  1211.  
  1212.    public void setSelItalic(int selItalic) {
  1213.       this.setCharFormat(2, 2, selItalic);
  1214.    }
  1215.  
  1216.    public void span(String characterSet) {
  1217.       this.spanUpTo(characterSet, true, false, true);
  1218.    }
  1219.  
  1220.    public void span(String characterSet, boolean forward) {
  1221.       this.spanUpTo(characterSet, forward, false, true);
  1222.    }
  1223.  
  1224.    public void span(String characterSet, boolean forward, boolean negate) {
  1225.       this.spanUpTo(characterSet, forward, negate, true);
  1226.    }
  1227.  
  1228.    public int getScrollBars() {
  1229.       return this.scrollBars;
  1230.    }
  1231.  
  1232.    public void setScrollBars(int scrollBars) {
  1233.       if (scrollBars != 0 && scrollBars != 1 && scrollBars != 2) {
  1234.          throw new IllegalArgumentException("setScrollBars: Unknown scrollBars type");
  1235.       } else {
  1236.          if (this.scrollBars != scrollBars) {
  1237.             this.scrollBars = scrollBars;
  1238.             if (((Control)this).isHandleCreated()) {
  1239.                ((Control)this).recreateHandle();
  1240.             }
  1241.          }
  1242.  
  1243.       }
  1244.    }
  1245.  
  1246.    private synchronized String streamOut(int flags) {
  1247.       this.bos = new ByteStream();
  1248.  
  1249.       String var4;
  1250.       try {
  1251.          EDITSTREAM es = new EDITSTREAM();
  1252.          es.dwCookie = 1;
  1253.          es.pfnCallback = DllLib.addrOf(this.editStreamProcRoot);
  1254.          this.sendMessage(1098, flags, (EDITSTREAM)es);
  1255.          if (es.dwError != 0) {
  1256.             throw new RuntimeException("streamOut: Unable to get text.");
  1257.          }
  1258.  
  1259.          this.bos.setPosition(0L);
  1260.          var4 = this.bos.getDataReader().readStringCharsAnsi((int)this.bos.getLength());
  1261.       } finally {
  1262.          this.bos = null;
  1263.       }
  1264.  
  1265.       return var4;
  1266.    }
  1267.  
  1268.    public int getSelLength() {
  1269.       if (((Component)this).isDesignMode()) {
  1270.          throw new RuntimeException("Not supported at Design time");
  1271.       } else {
  1272.          int selLength = 0;
  1273.          if (((Control)this).isHandleCreated()) {
  1274.             CHARRANGE range = new CHARRANGE();
  1275.             this.sendMessage(1076, 0, (CHARRANGE)range);
  1276.             selLength = range.cpMax - range.cpMin;
  1277.          }
  1278.  
  1279.          return selLength;
  1280.       }
  1281.    }
  1282.  
  1283.    public void setSelLength(int selLength) {
  1284.       if (((Component)this).isDesignMode()) {
  1285.          throw new RuntimeException("Not supported at Design time");
  1286.       } else {
  1287.          if (((Control)this).isHandleCreated()) {
  1288.             CHARRANGE range = new CHARRANGE();
  1289.             this.sendMessage(1076, 0, (CHARRANGE)range);
  1290.             range.cpMax = range.cpMin + selLength;
  1291.             this.sendMessage(1079, 0, (CHARRANGE)range);
  1292.             this.sendMessage(183);
  1293.          }
  1294.  
  1295.       }
  1296.    }
  1297.  
  1298.    public String getRichText() {
  1299.       return ((Control)this).isHandleCreated() ? this.streamOut(2) : "";
  1300.    }
  1301.  
  1302.    public String getSelText() {
  1303.       if (((Component)this).isDesignMode()) {
  1304.          throw new RuntimeException("Not supported at Design time");
  1305.       } else {
  1306.          return ((Control)this).isHandleCreated() ? this.streamOut(32769) : "";
  1307.       }
  1308.    }
  1309.  
  1310.    public void setRichText(String richText) {
  1311.       if (((Control)this).isHandleCreated()) {
  1312.          this.streamIn(richText, 2);
  1313.       }
  1314.  
  1315.    }
  1316.  
  1317.    public void setSelText(String selText) {
  1318.       if (((Component)this).isDesignMode()) {
  1319.          throw new RuntimeException("Not supported at Design time");
  1320.       } else {
  1321.          if (((Control)this).isHandleCreated()) {
  1322.          }
  1323.  
  1324.       }
  1325.    }
  1326.  
  1327.    private synchronized void streamIn(String string, int flags) {
  1328.       if (string.length() == 0) {
  1329.          if (('ΦÇÇ' & flags) != 0) {
  1330.             this.sendMessage(771);
  1331.             this.protectedError = false;
  1332.          } else {
  1333.             ((Control)this).sendMessage(12, 0, "");
  1334.          }
  1335.       } else {
  1336.          if ((flags & 'ΦÇÇ') == 0) {
  1337.             CHARRANGE cr = new CHARRANGE();
  1338.             this.sendMessage(1079, 0, (CHARRANGE)cr);
  1339.          }
  1340.  
  1341.          try {
  1342.             this.bis = new ByteStream();
  1343.             this.bis.getDataWriter().writeStringCharsAnsi(string);
  1344.             this.bis.setPosition(0L);
  1345.             EDITSTREAM es = new EDITSTREAM();
  1346.             es.dwCookie = 0;
  1347.             es.pfnCallback = DllLib.addrOf(this.editStreamProcRoot);
  1348.             this.sendMessage(1097, flags, (EDITSTREAM)es);
  1349.             if (!this.isProtectedError()) {
  1350.                if (es.dwError != 0) {
  1351.                   throw new RuntimeException("streamIn: Unable to load text");
  1352.                }
  1353.  
  1354.                if (!((Component)this).isDesignMode()) {
  1355.                   this.sendMessage(186);
  1356.                }
  1357.  
  1358.                return;
  1359.             }
  1360.          } finally {
  1361.             this.bis = null;
  1362.          }
  1363.  
  1364.       }
  1365.    }
  1366.  
  1367.    public void finalize() {
  1368.       if (this.editStreamProcRoot != 0) {
  1369.          Root.free(this.editStreamProcRoot);
  1370.       }
  1371.  
  1372.    }
  1373.  
  1374.    public String getText() {
  1375.       return ((Control)this).isHandleCreated() ? this.streamOut(1) : new String("");
  1376.    }
  1377.  
  1378.    public int getSelStart() {
  1379.       if (((Component)this).isDesignMode()) {
  1380.          throw new RuntimeException("Not supported at Design time");
  1381.       } else {
  1382.          int selStart = 0;
  1383.          if (((Control)this).isHandleCreated()) {
  1384.             CHARRANGE range = new CHARRANGE();
  1385.             this.sendMessage(1076, 0, (CHARRANGE)range);
  1386.             selStart = range.cpMin;
  1387.          }
  1388.  
  1389.          return selStart;
  1390.       }
  1391.    }
  1392. }
  1393.