home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / vibrant / vibtexts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-05  |  94.0 KB  |  3,770 lines  |  [TEXT/R*ch]

  1. /*   vibtexts.c
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *            National Center for Biotechnology Information (NCBI)
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government do not place any restriction on its use or reproduction.
  13. *  We would, however, appreciate having the NCBI and the author cited in
  14. *  any work or product based on this material
  15. *
  16. *  Although all reasonable efforts have been taken to ensure the accuracy
  17. *  and reliability of the software and data, the NLM and the U.S.
  18. *  Government do not and cannot warrant the performance or results that
  19. *  may be obtained by using this software or data. The NLM and the U.S.
  20. *  Government disclaim all warranties, express or implied, including
  21. *  warranties of performance, merchantability or fitness for any particular
  22. *  purpose.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:  vibtexts.c
  27. *
  28. * Author:  Jonathan Kans
  29. *
  30. * Version Creation Date:   7/1/91
  31. *
  32. * $Revision: 2.32 $
  33. *
  34. * File Description: 
  35. *       Vibrant edit text functions
  36. *
  37. * Modifications:  
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. *
  42. *
  43. * ==========================================================================
  44. */
  45.  
  46. #include <vibtypes.h>
  47. #include <vibprocs.h>
  48. #include <vibincld.h>
  49.  
  50. #ifdef WIN_MAC
  51. #define Nlm_TextTool TEHandle
  52. #endif
  53.  
  54. #ifdef WIN_MSWIN
  55. #define Nlm_TextTool HWND
  56. #endif
  57.  
  58. #ifdef WIN_MOTIF
  59. #define Nlm_TextTool Widget
  60. #endif
  61.  
  62. #define HSCROLL_POSITIONS 100
  63.  
  64. typedef  struct  Nlm_textdata {
  65.   Nlm_TextTool     handle;
  66.   Nlm_BaR          vScrollBar;
  67.   Nlm_BaR          hScrollBar;
  68.   Nlm_Boolean      wrap;
  69.   Nlm_FonT         font;
  70.   Nlm_Int2         texthght;
  71.   Nlm_Boolean      active;
  72.   Nlm_Boolean      changed;
  73.   Nlm_Boolean      hidden;
  74.   Nlm_Int2         visLines;
  75.   Nlm_TxtActnProc  select;
  76.   Nlm_TxtActnProc  deselect;
  77.   Nlm_TxtActnProc  tabnotify;
  78. } Nlm_TextData;
  79.  
  80. typedef  struct  Nlm_textrec {
  81.   Nlm_GraphicRec  graphicR;
  82.   Nlm_TextData    text;
  83. } Nlm_TextRec, PNTR Nlm_TxtPtr;
  84.  
  85. typedef  struct  Nlm_passwdrec {
  86.   Nlm_TextRec  textR;
  87.   Nlm_Char     password [32];
  88. } Nlm_PasswdRec, PNTR Nlm_PwdPtr;
  89.  
  90. static Nlm_GphPrcsPtr  gphprcsptr = NULL;
  91.  
  92. static Nlm_GphPrcsPtr  dialogTextProcs;
  93. static Nlm_GphPrcsPtr  hiddenTextProcs;
  94. static Nlm_GphPrcsPtr  passwordTextProcs;
  95. static Nlm_GphPrcsPtr  scrollTextProcs;
  96.  
  97. static Nlm_TexT        recentText = NULL;
  98. static Nlm_TextData    recentTextData;
  99.  
  100. static Nlm_TexT        currentText = NULL;
  101.  
  102. #ifdef WIN_MSWIN
  103. static WNDPROC         lpfnNewTextProc = NULL;
  104. static WNDPROC         lpfnOldTextProc = NULL;
  105. static Nlm_Boolean     handlechar;
  106. #endif
  107.  
  108. #ifdef WIN_MOTIF
  109. static Nlm_Boolean     allowTextCallback = TRUE;
  110. #endif
  111.  
  112. /* dgg */
  113. Nlm_FonT        gDialogTextFont = NULL;
  114. static Nlm_Int2        gDlogTextHeight = 0;
  115.  
  116. static void SelectDialogFont()
  117. {
  118. #ifdef DCLAP
  119.     if (gDialogTextFont == NULL) 
  120.         gDialogTextFont= Nlm_systemFont;  /* mswin,?xwin needs work to use other fonts */
  121.     Nlm_SelectFont (gDialogTextFont); 
  122.     gDlogTextHeight= Nlm_LineHeight ();
  123. #else
  124.   Nlm_SelectFont (Nlm_systemFont);
  125.   gDialogTextFont= Nlm_systemFont;
  126.   gDlogTextHeight= Nlm_stdLineHeight;
  127. #endif
  128. }
  129.  
  130.  
  131. static void Nlm_LoadTextData (Nlm_TexT t, Nlm_TextTool hdl,
  132.                               Nlm_BaR vbar, Nlm_BaR hbar,
  133.                               Nlm_Boolean wrp, Nlm_FonT fnt,
  134.                               Nlm_Int2 hght, Nlm_Boolean actv,
  135.                               Nlm_Boolean chgd, Nlm_Boolean hidn,
  136.                               Nlm_Int2 visl, Nlm_TxtActnProc slct,
  137.                               Nlm_TxtActnProc dslct, Nlm_TxtActnProc tabn)
  138.  
  139. {
  140.   Nlm_TextData  PNTR tdptr;
  141.   Nlm_TxtPtr   tp;
  142.  
  143.   if (t != NULL) {
  144.     tp = (Nlm_TxtPtr) Nlm_HandLock (t);
  145.     tdptr = &(tp->text);
  146.     tdptr->handle = hdl;
  147.     tdptr->vScrollBar = vbar;
  148.     tdptr->hScrollBar = hbar;
  149.     tdptr->wrap = wrp;
  150.     tdptr->font = fnt;
  151.     tdptr->texthght = hght;
  152.     tdptr->active = actv;
  153.     tdptr->changed = chgd;
  154.     tdptr->hidden = hidn;
  155.     tdptr->visLines = visl;
  156.     tdptr->select = slct;
  157.     tdptr->deselect = dslct;
  158.     tdptr->tabnotify = tabn;
  159.     Nlm_HandUnlock (t);
  160.     recentText = NULL;
  161.   }
  162. }
  163.  
  164. static void Nlm_SetTextData (Nlm_TexT t, Nlm_TextData * tdata)
  165.  
  166. {
  167.   Nlm_TxtPtr  tp;
  168.  
  169.   if (t != NULL && tdata != NULL) {
  170.     tp = (Nlm_TxtPtr) Nlm_HandLock (t);
  171.     tp->text = *tdata;
  172.     Nlm_HandUnlock (t);
  173.     recentText = t;
  174.     recentTextData = *tdata;
  175.   }
  176. }
  177.  
  178. static void Nlm_GetTextData (Nlm_TexT t, Nlm_TextData * tdata)
  179.  
  180. {
  181.   Nlm_TxtPtr  tp;
  182.  
  183.   if (t != NULL && tdata != NULL) {
  184.     if (t == recentText && NLM_RISKY) {
  185.       *tdata = recentTextData;
  186.     } else {
  187.       tp = (Nlm_TxtPtr) Nlm_HandLock (t);
  188.       *tdata = tp->text;
  189.       Nlm_HandUnlock (t);
  190.       recentText = t;
  191.       recentTextData = *tdata;
  192.     }
  193.   }
  194. }
  195.  
  196. static void Nlm_SetTextHandle (Nlm_TexT t, Nlm_TextTool hdl)
  197.  
  198. {
  199.   Nlm_TextData  tdata;
  200.  
  201.   Nlm_GetTextData (t, &tdata);
  202.   tdata.handle = hdl;
  203.   Nlm_SetTextData (t, &tdata);
  204. }
  205.  
  206. static Nlm_TextTool Nlm_GetTextHandle (Nlm_TexT t)
  207.  
  208. {
  209.   Nlm_TextData  tdata;
  210.  
  211.   Nlm_GetTextData (t, &tdata);
  212.   return tdata.handle;
  213. }
  214.  
  215. static Nlm_BaR Nlm_GetTextVScrollBar (Nlm_TexT t)
  216.  
  217. {
  218.   Nlm_TextData  tdata;
  219.  
  220.   Nlm_GetTextData (t, &tdata);
  221.   return tdata.vScrollBar;
  222. }
  223.  
  224. static Nlm_BaR Nlm_GetTextHScrollBar (Nlm_TexT t)
  225.  
  226. {
  227.   Nlm_TextData  tdata;
  228.  
  229.   Nlm_GetTextData (t, &tdata);
  230.   return tdata.hScrollBar;
  231. }
  232.  
  233. static Nlm_Boolean Nlm_GetTextWrap (Nlm_TexT t)
  234.  
  235. {
  236.   Nlm_TextData  tdata;
  237.  
  238.   Nlm_GetTextData (t, &tdata);
  239.   return tdata.wrap;
  240. }
  241.  
  242. static Nlm_Int2 Nlm_GetFontHeight (Nlm_TexT t)
  243.  
  244. {
  245.   Nlm_TextData  tdata;
  246.  
  247.   Nlm_GetTextData (t, &tdata);
  248.   return tdata.texthght;
  249. }
  250.  
  251. static void Nlm_SetActive (Nlm_TexT t, Nlm_Boolean act)
  252.  
  253. {
  254.   Nlm_TextData  tdata;
  255.  
  256.   Nlm_GetTextData (t, &tdata);
  257.   tdata.active = act;
  258.   Nlm_SetTextData (t, &tdata);
  259. }
  260.  
  261. static Nlm_Boolean Nlm_GetActive (Nlm_TexT t)
  262.  
  263. {
  264.   Nlm_TextData  tdata;
  265.  
  266.   Nlm_GetTextData (t, &tdata);
  267.   return tdata.active;
  268. }
  269.  
  270. static void Nlm_SetChanged (Nlm_TexT t, Nlm_Boolean chd)
  271.  
  272. {
  273.   Nlm_TextData  tdata;
  274.  
  275.   Nlm_GetTextData (t, &tdata);
  276.   tdata.changed = chd;
  277.   Nlm_SetTextData (t, &tdata);
  278. }
  279.  
  280. static Nlm_Boolean Nlm_GetChanged (Nlm_TexT t)
  281.  
  282. {
  283.   Nlm_TextData  tdata;
  284.  
  285.   Nlm_GetTextData (t, &tdata);
  286.   return tdata.changed;
  287. }
  288.  
  289. static Nlm_Boolean Nlm_IsHiddenText (Nlm_TexT t)
  290.  
  291. {
  292.   Nlm_TextData  tdata;
  293.  
  294.   Nlm_GetTextData (t, &tdata);
  295.   return tdata.hidden;
  296. }
  297.  
  298. static Nlm_Int2 Nlm_GetVisLines (Nlm_TexT t)
  299.  
  300. {
  301.   Nlm_TextData  tdata;
  302.  
  303.   Nlm_GetTextData (t, &tdata);
  304.   return tdata.visLines;
  305. }
  306.  
  307. extern void Nlm_SetTextSelect (Nlm_TexT t, Nlm_TxtActnProc slct, Nlm_TxtActnProc dslct)
  308.  
  309. {
  310.   Nlm_TextData  tdata;
  311.  
  312.   if (t != NULL) {
  313.     Nlm_GetTextData (t, &tdata);
  314.     tdata.select = slct;
  315.     tdata.deselect = dslct;
  316.     Nlm_SetTextData (t, &tdata);
  317.   }
  318. }
  319.  
  320. static void Nlm_SetPassword (Nlm_TexT t, Nlm_CharPtr passwd)
  321.  
  322. {
  323.   Nlm_PwdPtr  pp;
  324.  
  325.   if (t != NULL && passwd != NULL) {
  326.     pp = (Nlm_PwdPtr) Nlm_HandLock (t);
  327.     Nlm_StringNCpy ((Nlm_CharPtr) pp->password, passwd, 31);
  328.     Nlm_HandUnlock (t);
  329.   }
  330. }
  331.  
  332. static void Nlm_GetPassword (Nlm_TexT t, Nlm_CharPtr passwd, Nlm_sizeT maxsize)
  333.  
  334. {
  335.   Nlm_PwdPtr  pp;
  336.  
  337.   if (t != NULL && passwd != NULL) {
  338.     pp = (Nlm_PwdPtr) Nlm_HandLock (t);
  339.     Nlm_StringNCpy (passwd, (Nlm_CharPtr) pp->password, maxsize);
  340.     Nlm_HandUnlock (t);
  341.   }
  342. }
  343.  
  344. #ifdef WIN_MAC
  345. static Nlm_Int2 Nlm_GetTextLines (Nlm_TexT t)
  346.  
  347. {
  348.   Nlm_TextTool  h;
  349.   Nlm_Int2      lines;
  350.   TEPtr         tptr;
  351.  
  352.   h = Nlm_GetTextHandle (t);
  353.   HLock ((Handle) h);
  354.   tptr = (TEPtr) *((Handle) h);
  355.   lines = tptr->nLines;
  356.   HUnlock ((Handle) h);
  357.   return lines;
  358. }
  359.  
  360. static Nlm_Int2 Nlm_GetLineHeight (Nlm_TexT t)
  361.  
  362. {
  363.   Nlm_TextTool  h;
  364.   Nlm_Int2      height;
  365.   TEPtr         tptr;
  366.  
  367.   h = Nlm_GetTextHandle (t);
  368.   HLock ((Handle) h);
  369.   tptr = (TEPtr) *((Handle) h);
  370.   height = tptr->lineHeight;
  371.   HUnlock ((Handle) h);
  372.   return height;
  373. }
  374.  
  375. static Nlm_Int2 Nlm_GetInsertionStartLine (Nlm_TexT t)
  376.  
  377. {
  378.   Nlm_TextTool  h;
  379.   Nlm_Int2      i;
  380.   short         *lines;
  381.   Nlm_Int2      numLines;
  382.   Nlm_Int2      startLoc;
  383.   TEPtr         tptr;
  384.  
  385.   h = Nlm_GetTextHandle (t);
  386.   HLock ((Handle) h);
  387.   tptr = (TEPtr) *((Handle) h);
  388.   numLines = tptr->nLines;
  389.   startLoc = tptr->selStart;
  390.   i = 0;
  391.   lines = &(tptr->lineStarts[0]);
  392.   while (i < numLines && startLoc > lines [i]) {
  393.     i++;
  394.   }
  395.   HUnlock ((Handle) h);
  396.   return i;
  397. }
  398.  
  399. static void Nlm_ScrollToInsertionPoint (Nlm_TexT t)
  400.  
  401. {
  402.   Nlm_BaR   sb;
  403.   Nlm_Int2  start;
  404.   Nlm_Int2  val;
  405.   Nlm_Int2  vis;
  406.  
  407.   sb = Nlm_GetTextVScrollBar (t);
  408.   if (sb != NULL) {
  409.     start = Nlm_GetInsertionStartLine (t);
  410.     vis = Nlm_GetVisLines (t);
  411.     val = Nlm_DoGetValue ((Nlm_GraphiC) sb);
  412.     if (val + vis < start) {
  413.       Nlm_DoSetValue ((Nlm_GraphiC) sb, start - (vis / 2), TRUE);
  414.     } else if (val > start) {
  415.       Nlm_DoSetValue ((Nlm_GraphiC) sb, start - (vis / 2), TRUE);
  416.     }
  417.   }
  418. }
  419.  
  420. static void Nlm_UpdateScrollBar (Nlm_TexT t)
  421.  
  422. {
  423.   Nlm_Int2  lines;
  424.   Nlm_Int2  newval;
  425.   Nlm_BaR   sb;
  426.   Nlm_Int2  start;
  427.   Nlm_Int2  vis;
  428.  
  429.   sb = Nlm_GetTextVScrollBar (t);
  430.   if (sb != NULL) {
  431.     lines = Nlm_GetTextLines (t);
  432.     start = Nlm_GetInsertionStartLine (t);
  433.     vis = Nlm_GetVisLines (t);
  434.     newval = 0;
  435.     if (lines > vis) {
  436.       newval = lines - vis;
  437.     }
  438.     Nlm_DoSetRange ((Nlm_GraphiC) sb, vis - 1, vis - 1, newval, FALSE);
  439.     if (Nlm_DoGetValue ((Nlm_GraphiC) sb) > newval) {
  440.       Nlm_DoSetValue ((Nlm_GraphiC) sb, newval, FALSE);
  441.     }
  442.   }
  443.   sb = Nlm_GetTextHScrollBar (t);
  444.   if (sb != NULL) {
  445.     Nlm_CorrectBarMax (sb, HSCROLL_POSITIONS);
  446.   }
  447. }
  448. #endif
  449.  
  450. static void Nlm_DeactivateBoxesInList (Nlm_TexT t)
  451.  
  452. {
  453.   Nlm_WindoW  w;
  454.  
  455.   w = Nlm_GetParentWindow ((Nlm_GraphiC) t);
  456.   Nlm_DoLoseFocus ((Nlm_GraphiC) w, (Nlm_GraphiC) t, FALSE);
  457. }
  458.  
  459. static void Nlm_DoTextSelect (Nlm_TexT t)
  460.  
  461. {
  462.   Nlm_TxtActnProc  sel;
  463.   Nlm_TextData     tdata;
  464.  
  465.   if (t != NULL) {
  466.     Nlm_GetTextData (t, &tdata);
  467.     sel = tdata.select;
  468.     if (sel != NULL && currentText != t) {
  469.       currentText = t;
  470.       sel (t);
  471.     }
  472.   }
  473.   currentText = t;
  474. }
  475.  
  476. static void Nlm_DoTextDeselect (Nlm_TexT t)
  477.  
  478. {
  479.   Nlm_TxtActnProc  desel;
  480.   Nlm_TextData     tdata;
  481.  
  482.   if (t != NULL) {
  483.     Nlm_GetTextData (t, &tdata);
  484.     desel = tdata.deselect;
  485.     if (desel != NULL) {
  486.       desel (t);
  487.     }
  488.   }
  489. }
  490.  
  491. static void Nlm_DoTabCallback (Nlm_TexT t)
  492.  
  493. {
  494.   Nlm_TextData  tdata;
  495.  
  496.   Nlm_GetTextData (t, &tdata);
  497.   if (tdata.tabnotify != NULL) {
  498.     tdata.tabnotify (t);
  499.   }
  500. }
  501.  
  502.  
  503.  
  504. #ifdef DCLAP
  505. extern void Nlm_TextEnableNewlines(Nlm_TexT t, Nlm_Boolean turnon)
  506. {
  507. #ifdef WIN_MAC
  508.   Nlm_TextTool  h;
  509.   h = Nlm_GetTextHandle (t);
  510.     if (turnon) (**h).crOnly= 0;
  511.     else (**h).crOnly= -1;
  512. #endif
  513. }
  514. #endif
  515.  
  516.  
  517. static void Nlm_SelectAText (Nlm_TexT t, Nlm_Int2 begin, Nlm_Int2 end)
  518.  
  519. {
  520. #ifdef WIN_MAC
  521.   Nlm_TextTool  h;
  522.   TEPtr         hp;
  523.   short         len;
  524.   Nlm_Int4      selStart;
  525.   Nlm_Int4      selEnd;
  526.  
  527.   Nlm_DeactivateBoxesInList (t);
  528.   h = Nlm_GetTextHandle (t);
  529.   HLock ((Handle) h);
  530.   hp = (TEPtr) *((Handle) h);
  531.   len = hp->teLength;
  532.   HUnlock ((Handle) h);
  533.   selStart = begin;
  534.   selEnd = end;
  535.   if (selEnd > (Nlm_Int4) len) {
  536.     selEnd = (Nlm_Int4) len;
  537.   }
  538.   TESetSelect (selStart, selEnd, h);
  539.   Nlm_SetActive (t, TRUE);
  540.   Nlm_DoActivate ((Nlm_GraphiC) t, FALSE);
  541.   Nlm_DoTextSelect (t);
  542. #endif
  543. #ifdef WIN_MSWIN
  544.   Nlm_TextTool  h;
  545.  
  546.   h = Nlm_GetTextHandle (t);
  547.   Edit_SetSel (h, begin, end);
  548.   if (Nlm_Visible (t) && Nlm_AllParentsVisible (t)) {
  549.     SetFocus (h);
  550.     Nlm_DoTextSelect (t);
  551.   }
  552. #endif
  553. #ifdef WIN_MOTIF
  554.   Nlm_TextTool    h;
  555.   XmTextPosition  max;
  556.  
  557.   if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  558.     allowTextCallback = FALSE;
  559.     h = Nlm_GetTextHandle (t);
  560.     XmProcessTraversal (h, XmTRAVERSE_CURRENT);
  561.     max = XmTextGetLastPosition (h);
  562.     if (max > (XmTextPosition) end) {
  563.       max = (XmTextPosition) end;
  564.     }
  565.     XmTextSetSelection (h, (XmTextPosition) begin,
  566.                         (XmTextPosition) max, (Time) 0);
  567.     XmTextSetHighlight (h, (XmTextPosition) begin,
  568.                         (XmTextPosition) max, XmHIGHLIGHT_SELECTED);
  569.     allowTextCallback = TRUE;
  570.   }
  571.   Nlm_DoTextSelect (t);
  572. #endif
  573. }
  574.  
  575. extern void Nlm_TextSelectionRange (Nlm_TexT t, Nlm_Int2Ptr begin, Nlm_Int2Ptr end)
  576.  
  577. {
  578. #ifdef WIN_MAC
  579.   Nlm_TextTool  h;
  580.   TEPtr         hp;
  581.   Nlm_Int4      selStart;
  582.   Nlm_Int4      selEnd;
  583.  
  584.   if (t != NULL) {
  585.     h = Nlm_GetTextHandle (t);
  586.     HLock ((Handle) h);
  587.     hp = (TEPtr) *((Handle) h);
  588.     selStart = hp->selStart;
  589.     selEnd = hp->selEnd;
  590.     HUnlock ((Handle) h);
  591.     if (begin != NULL) {
  592.       *begin = (Nlm_Int2) selStart;
  593.     }
  594.     if (end != NULL) {
  595.       *end = (Nlm_Int2) selEnd;
  596.     }
  597.   }
  598. #endif
  599. #ifdef WIN_MSWIN
  600.   Nlm_TextTool  h;
  601.   DWORD         val;
  602.  
  603.   if (t != NULL) {
  604.     h = Nlm_GetTextHandle (t);
  605.     val = Edit_GetSel (h);
  606.     if (begin != NULL) {
  607.       *begin = (Nlm_Int2) (LOWORD (val));
  608.     }
  609.     if (end != NULL) {
  610.       *end = (Nlm_Int2) (HIWORD (val));
  611.     }
  612.   }
  613. #endif
  614. #ifdef WIN_MOTIF
  615.   Nlm_TextTool    h;
  616.   XmTextPosition  left;
  617.   XmTextPosition  right;
  618.  
  619.   if (t != NULL) {
  620.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  621.       h = Nlm_GetTextHandle (t);
  622.       XmTextGetSelectionPosition (h, &left, &right);
  623.       if (begin != NULL) {
  624.         *begin = (Nlm_Int2) left;
  625.       }
  626.       if (end != NULL) {
  627.         *end = (Nlm_Int2) right;
  628.       }
  629.     }
  630.   }
  631. #endif
  632. }
  633.  
  634. #ifdef WIN_MAC
  635. static Nlm_Boolean Nlm_DialogTextClick (Nlm_GraphiC t, Nlm_PoinT pt)
  636.  
  637. {
  638.   Nlm_TextTool   h;
  639.   Nlm_PointTool  ptool;
  640.   Nlm_RecT       r;
  641.   Nlm_Boolean    rsult;
  642.   Nlm_WindoW     w;
  643.  
  644.   rsult = FALSE;
  645.   Nlm_GetRect (t, &r);
  646.   if (Nlm_PtInRect (pt, &r)) {
  647.     Nlm_DeactivateBoxesInList ((Nlm_TexT) t);
  648.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  649.     Nlm_GetRect (t, &r);
  650.     Nlm_PoinTToPointTool (pt, &ptool);
  651.     TEClick (ptool, Nlm_shftKey, h);
  652.     Nlm_SetActive ((Nlm_TexT) t, TRUE);
  653.     w = Nlm_GetParentWindow (t);
  654.     Nlm_DoActivate (t, FALSE);
  655.     do {
  656.     } while (Nlm_MouseButton ());
  657.     Nlm_DoTextSelect ((Nlm_TexT) t);
  658.     rsult = TRUE;
  659.   }
  660.   return rsult;
  661. }
  662.  
  663. static Nlm_Boolean Nlm_ScrollTextClick (Nlm_GraphiC t, Nlm_PoinT pt)
  664.  
  665. {
  666.   Nlm_TextTool   h;
  667.   Nlm_BaR        hsb;
  668.   Nlm_PointTool  ptool;
  669.   Nlm_RecT       r;
  670.   Nlm_Boolean    rsult;
  671.   Nlm_BaR        vsb;
  672.   Nlm_WindoW     w;
  673.   Nlm_Boolean    wrap;
  674.  
  675.   rsult = FALSE;
  676.   Nlm_GetRect (t, &r);
  677.   wrap = Nlm_GetTextWrap ((Nlm_TexT) t);
  678.   r.right += Nlm_vScrollBarWidth;
  679.   if (! wrap) {
  680.     r.bottom += Nlm_hScrollBarHeight;
  681.   }
  682.   if (Nlm_PtInRect (pt, &r)) {
  683.     vsb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  684.     hsb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  685.     if (vsb != NULL && Nlm_DoClick ((Nlm_GraphiC) vsb, pt)) {
  686.     } else if (hsb != NULL && Nlm_DoClick ((Nlm_GraphiC) hsb, pt)) {
  687.     } else {
  688.       Nlm_DeactivateBoxesInList ((Nlm_TexT) t);
  689.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  690.       r.right -= Nlm_vScrollBarWidth;
  691.       if (! wrap) {
  692.         r.bottom -= Nlm_hScrollBarHeight;
  693.       }
  694.       Nlm_PoinTToPointTool (pt, &ptool);
  695.       TEClick (ptool, Nlm_shftKey, h);
  696.  
  697. #ifdef DCLAP
  698. /* only call the DoActivate if we were inactive -- it is a big time drag w/ TERecal ! */
  699. /* note that SetActive must be done before DoActivate call !! */
  700.           {
  701.           Nlm_Boolean   act;
  702.           act = Nlm_GetActive ((Nlm_TexT) t);
  703.       Nlm_SetActive ((Nlm_TexT) t, TRUE);
  704.       if (!act) Nlm_DoActivate (t, FALSE);
  705.       }
  706. #else
  707.       Nlm_SetActive ((Nlm_TexT) t, TRUE);
  708.       w = Nlm_GetParentWindow (t);
  709.       Nlm_DoActivate (t, FALSE);
  710. #endif
  711.  
  712.       do {
  713.       } while (Nlm_MouseButton ());
  714.       Nlm_DoTextSelect ((Nlm_TexT) t);
  715.       rsult = TRUE;
  716.     }
  717.   }
  718.   return rsult;
  719. }
  720.  
  721. static Nlm_Boolean Nlm_TextKey (Nlm_GraphiC t, Nlm_Char ch)
  722.  
  723. {
  724.   Nlm_Boolean   act;
  725.   Nlm_TextTool  h;
  726.   Nlm_Boolean   rsult;
  727.  
  728.   rsult = FALSE;
  729.   act = Nlm_GetActive ((Nlm_TexT) t);
  730.   if (act && ! Nlm_cmmdKey) {
  731.     if (ch != '\0') {
  732.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  733.       Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
  734.       TEKey (ch, h);
  735.       TECalText (h);
  736.       Nlm_UpdateScrollBar ((Nlm_TexT) t);
  737.       Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
  738.       Nlm_DoAction (t);
  739.       Nlm_SetChanged ((Nlm_TexT) t, TRUE);
  740.       rsult = TRUE;
  741.     }
  742.   }
  743.   return rsult;
  744. }
  745.  
  746. static Nlm_Boolean Nlm_DialogKey (Nlm_GraphiC t, Nlm_Char ch)
  747.  
  748. {
  749.   Nlm_Boolean  act;
  750.   Nlm_Boolean  rsult;
  751.  
  752.   rsult = FALSE;
  753.   act = Nlm_GetActive ((Nlm_TexT) t);
  754.   if (act && ! Nlm_cmmdKey) {
  755.     if (ch == '\t' && Nlm_IsHiddenText ((Nlm_TexT) t)) {
  756.       Nlm_DoTabCallback ((Nlm_TexT) t);
  757.     } else if (ch == '\t') {
  758.       Nlm_DoSendFocus (t, ch);
  759.       rsult = TRUE;
  760.     } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
  761.     } else if (ch != '\0') {
  762.       rsult = Nlm_TextKey (t, ch);
  763.     }
  764.   }
  765.   return rsult;
  766. }
  767.  
  768. static Nlm_Boolean Nlm_PasswordKey (Nlm_GraphiC t, Nlm_Char ch)
  769.  
  770. {
  771.   Nlm_Boolean   act;
  772.   Nlm_TextTool  h;
  773.   TEPtr         hp;
  774.   Nlm_Int2      len;
  775.   Nlm_Char      password [32];
  776.   Nlm_RecT      r;
  777.   Nlm_RectTool  rtool;
  778.   Nlm_Boolean   rsult;
  779.   Nlm_Int4      selStart;
  780.   Nlm_Int4      selEnd;
  781.  
  782.   rsult = FALSE;
  783.   act = Nlm_GetActive ((Nlm_TexT) t);
  784.   if (act && ! Nlm_cmmdKey) {
  785.     if (ch == '\t') {
  786.       Nlm_DoSendFocus (t, ch);
  787.       rsult = TRUE;
  788.     } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
  789.     } else if (ch == '\b') {
  790.       rsult = TRUE;
  791.       Nlm_SetPassword ((Nlm_TexT) t, "");
  792.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  793.       selStart = 0;
  794.       HLock ((Handle) h);
  795.       hp = (TEPtr) *((Handle) h);
  796.       selEnd = hp->teLength;
  797.       HUnlock ((Handle) h);
  798.       TESetSelect (selStart, selEnd, h);
  799.       TEDelete (h);
  800.       Nlm_GetRect (t, &r);
  801.       if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  802.         Nlm_InsetRect (&r, 2, 2);
  803.         Nlm_EraseRect (&r);
  804.         Nlm_RecTToRectTool (&r, &rtool);
  805.         TEUpdate (&rtool, h);
  806.       }
  807.     } else if (ch != '\0') {
  808.       Nlm_GetPassword ((Nlm_TexT) t, password, sizeof (password));
  809.       len = (Nlm_Int2) Nlm_StringLen (password);
  810.       if (len < sizeof (password) - 2) {
  811.         password [len] = ch;
  812.         password [len + 1] = '\0';
  813.       }
  814.       Nlm_SetPassword ((Nlm_TexT) t, password);
  815.       rsult = Nlm_TextKey (t, '*');
  816.     }
  817.   }
  818.   return rsult;
  819. }
  820.  
  821. static void Nlm_DrawDialogText (Nlm_GraphiC t)
  822.  
  823. {
  824.   Nlm_TextTool  h;
  825.   Nlm_RecT      r;
  826.   Nlm_RectTool  ttool;
  827.  
  828.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  829.     Nlm_GetRect (t, &r);
  830.     if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
  831.       Nlm_EraseRect (&r);
  832.       if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  833.         h = Nlm_GetTextHandle ((Nlm_TexT) t);
  834.         if (Nlm_GetActive ((Nlm_TexT) t)) {
  835.           TEActivate (h);
  836.         } else {
  837.           TEDeactivate (h);
  838.         }
  839.         TECalText (h);
  840.         Nlm_InsetRect (&r, 2, 2);
  841.         Nlm_RecTToRectTool (&r, &ttool);
  842.         SelectDialogFont();
  843.         TEUpdate (&ttool, h);
  844.         Nlm_InsetRect (&r, -2, -2);
  845.         Nlm_FrameRect (&r);
  846.       } else {
  847. #ifdef DCLAP
  848.     /* dgg -- we want to show this text, just not edit it... */
  849.         h = Nlm_GetTextHandle ((Nlm_TexT) t);
  850.             TEDeactivate (h);
  851.         TECalText (h);
  852.         Nlm_InsetRect (&r, 2, 2);
  853.         Nlm_RecTToRectTool (&r, &ttool);
  854.                 SelectDialogFont();
  855.         TEUpdate (&ttool, h);
  856.         Nlm_InsetRect (&r, -2, -2);
  857. #endif
  858.         Nlm_Dotted ();
  859.         Nlm_FrameRect (&r);
  860.         Nlm_Solid ();
  861.       }
  862.     }
  863.   }
  864. }
  865.  
  866. static void Nlm_DrawHiddenText (Nlm_GraphiC t)
  867.  
  868. {
  869.   Nlm_TextTool  h;
  870.   Nlm_RecT      r;
  871.   Nlm_RectTool  ttool;
  872.  
  873.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  874.     Nlm_GetRect (t, &r);
  875.     if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
  876.       Nlm_EraseRect (&r);
  877.       if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  878.         h = Nlm_GetTextHandle ((Nlm_TexT) t);
  879.         if (Nlm_GetActive ((Nlm_TexT) t)) {
  880.           TEActivate (h);
  881.         } else {
  882.           TEDeactivate (h);
  883.         }
  884.         TECalText (h);
  885.         Nlm_RecTToRectTool (&r, &ttool);
  886.                 SelectDialogFont();
  887.         TEUpdate (&ttool, h);
  888.       }
  889.     }
  890.   }
  891. }
  892.  
  893. static void Nlm_DrawScrollText (Nlm_GraphiC t)
  894.  
  895. {
  896.   Nlm_TextTool  h;
  897.   Nlm_BaR       hsb;
  898.   Nlm_RecT      r;
  899.   Nlm_RectTool  rtool;
  900.   Nlm_BaR       vsb;
  901.   Nlm_Boolean   wrap;
  902.  
  903.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  904.     Nlm_GetRect (t, &r);
  905.     r.right += Nlm_vScrollBarWidth;
  906.     wrap = Nlm_GetTextWrap ((Nlm_TexT) t);
  907.     if (! wrap) {
  908.       r.bottom += Nlm_hScrollBarHeight;
  909.     }
  910.     if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
  911.       if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  912.         Nlm_FrameRect (&r);
  913.         vsb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  914.         if (vsb != NULL) {
  915.           Nlm_DoDraw ((Nlm_GraphiC) vsb);
  916.         }
  917.         hsb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  918.         if (hsb != NULL) {
  919.           Nlm_DoDraw ((Nlm_GraphiC) hsb);
  920.         }
  921.         r.right -= Nlm_vScrollBarWidth;
  922.         if (! wrap) {
  923.           r.bottom -= Nlm_hScrollBarHeight;
  924.         }
  925.         Nlm_InsetRect (&r, 4, 2);
  926.         r.bottom = r.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
  927.         h = Nlm_GetTextHandle ((Nlm_TexT) t);
  928.         if (Nlm_GetActive ((Nlm_TexT) t)) {
  929.           TEActivate (h);
  930.         } else {
  931.           TEDeactivate (h);
  932.         }
  933.         TECalText (h);
  934.         Nlm_RecTToRectTool (&r, &rtool);
  935.                 SelectDialogFont();
  936.         TEUpdate (&rtool, h);
  937.       } else {
  938. #ifdef DCLAP
  939.          /* dgg -- we want to see text, just not edit it */
  940.          /* this may need some work */
  941.         h = Nlm_GetTextHandle ((Nlm_TexT) t);
  942.         TEDeactivate (h);
  943.         TECalText (h);
  944.         Nlm_RecTToRectTool (&r, &rtool);
  945.                 SelectDialogFont();
  946.         TEUpdate (&rtool, h);
  947. #else
  948.         Nlm_EraseRect (&r);
  949. #endif
  950.         Nlm_Dotted ();
  951.         Nlm_FrameRect (&r);
  952.         Nlm_Solid ();
  953.       }
  954.     }
  955.   }
  956. }
  957.  
  958. static Nlm_Boolean Nlm_IdleText (Nlm_GraphiC t, Nlm_PoinT pt)
  959.  
  960. {  Nlm_TextTool  h;
  961.  
  962.   if (Nlm_GetVisible (t) && Nlm_GetEnabled (t) && Nlm_GetActive ((Nlm_TexT) t)) {
  963.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  964.     TEIdle (h);
  965.   }
  966.   return TRUE;
  967. }
  968. #endif
  969.  
  970. #ifdef WIN_MSWIN
  971. static Nlm_Boolean Nlm_DialogTextCommand (Nlm_GraphiC t)
  972.  
  973. {
  974.   if (Nlm_currentCode == EN_CHANGE) {
  975.     Nlm_DoAction (t);
  976.   }
  977.   return TRUE;
  978. }
  979.  
  980. static Nlm_Boolean Nlm_PasswordTextCommand (Nlm_GraphiC t)
  981.  
  982. {
  983.   Nlm_TextTool  h;
  984.   Nlm_Char      password [32];
  985.  
  986.   if (Nlm_currentCode == EN_CHANGE) {
  987.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  988.     GetWindowText (h, password, sizeof (password) - 2);
  989.     Nlm_SetPassword ((Nlm_TexT) t, password);
  990.     Nlm_DoAction (t);
  991.   }
  992.   return TRUE;
  993. }
  994.  
  995. static Nlm_Boolean Nlm_ScrollTextCommand (Nlm_GraphiC t)
  996.  
  997. {
  998.   if (Nlm_currentCode == EN_CHANGE) {
  999.     Nlm_DoAction (t);
  1000.   }
  1001.   return TRUE;
  1002. }
  1003. #endif
  1004.  
  1005. #ifdef WIN_MOTIF
  1006. #endif
  1007.  
  1008. static void Nlm_ShowText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1009.  
  1010. {
  1011.   Nlm_TextTool  h;
  1012.   Nlm_WindoW    tempPort;
  1013.  
  1014.   if (setFlag) {
  1015.     Nlm_SetVisible (t, TRUE);
  1016.   }
  1017.   if (Nlm_GetVisible (t) && Nlm_AllParentsButWindowVisible (t)) {
  1018.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1019.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1020. #ifdef WIN_MAC
  1021.     Nlm_DoDraw (t);
  1022. #endif
  1023. #ifdef WIN_MSWIN
  1024.     ShowWindow (h, SW_SHOW);
  1025.     UpdateWindow (h);
  1026. #endif
  1027. #ifdef WIN_MOTIF
  1028.     XtManageChild (h);
  1029. #endif
  1030.     Nlm_RestorePort (tempPort);
  1031.   }
  1032. }
  1033.  
  1034. static void Nlm_ShowScrollText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1035.  
  1036. {
  1037.   Nlm_TextTool  h;
  1038.   Nlm_BaR       sb;
  1039.   Nlm_WindoW    tempPort;
  1040.  
  1041.   if (setFlag) {
  1042.     Nlm_SetVisible (t, TRUE);
  1043.   }
  1044.   if (Nlm_GetVisible (t) && Nlm_AllParentsButWindowVisible (t)) {
  1045.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1046.     sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1047.     if (sb != NULL) {
  1048.       Nlm_DoShow ((Nlm_GraphiC) sb, TRUE, FALSE);
  1049.     }
  1050.     sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1051.     if (sb != NULL) {
  1052.       Nlm_DoShow ((Nlm_GraphiC) sb, TRUE, FALSE);
  1053.     }
  1054.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1055. #ifdef WIN_MAC
  1056.     Nlm_DoDraw (t);
  1057. #endif
  1058. #ifdef WIN_MSWIN
  1059.     ShowWindow (h, SW_SHOW);
  1060.     UpdateWindow (h);
  1061. #endif
  1062. #ifdef WIN_MOTIF
  1063.     XtManageChild (XtParent (h));
  1064. #endif
  1065.     Nlm_RestorePort (tempPort);
  1066.   }
  1067. }
  1068.  
  1069. static void Nlm_HideText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1070.  
  1071. {
  1072.   Nlm_TextTool  h;
  1073.   Nlm_WindoW    tempPort;
  1074. #ifdef WIN_MAC
  1075.   Nlm_RecT      r;
  1076. #endif
  1077.  
  1078.   if (setFlag) {
  1079.     Nlm_SetVisible (t, FALSE);
  1080.   }
  1081.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1082.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1083. #ifdef WIN_MAC
  1084.   if (Nlm_GetAllParentsVisible (t)) {
  1085.     Nlm_GetRect (t, &r);
  1086.     Nlm_InsetRect (&r, -1, -1);
  1087.     Nlm_EraseRect (&r);
  1088.     Nlm_ValidRect (&r);
  1089.   }
  1090. #endif
  1091. #ifdef WIN_MSWIN
  1092.   ShowWindow (h, SW_HIDE);
  1093.   UpdateWindow (h);
  1094. #endif
  1095. #ifdef WIN_MOTIF
  1096.   XtUnmanageChild (h);
  1097. #endif
  1098.   Nlm_RestorePort (tempPort);
  1099. }
  1100.  
  1101. static void Nlm_HideScrollText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1102.  
  1103. {
  1104.   Nlm_TextTool  h;
  1105.   Nlm_BaR       sb;
  1106.   Nlm_WindoW    tempPort;
  1107. #ifdef WIN_MAC
  1108.   Nlm_RecT      r;
  1109. #endif
  1110.  
  1111.   if (setFlag) {
  1112.     Nlm_SetVisible (t, FALSE);
  1113.   }
  1114.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1115.   sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1116.   if (sb != NULL) {
  1117.     Nlm_DoHide ((Nlm_GraphiC) sb, TRUE, FALSE);
  1118.   }
  1119.   sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1120.   if (sb != NULL) {
  1121.     Nlm_DoHide ((Nlm_GraphiC) sb, TRUE, FALSE);
  1122.   }
  1123.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1124. #ifdef WIN_MAC
  1125.   if (Nlm_GetAllParentsVisible (t)) {
  1126.     Nlm_GetRect (t, &r);
  1127.     r.right += Nlm_vScrollBarWidth;
  1128.     Nlm_InsetRect (&r, -1, -1);
  1129.     Nlm_EraseRect (&r);
  1130.     Nlm_ValidRect (&r);
  1131.   }
  1132. #endif
  1133. #ifdef WIN_MSWIN
  1134.   ShowWindow (h, SW_HIDE);
  1135.   UpdateWindow (h);
  1136. #endif
  1137. #ifdef WIN_MOTIF
  1138.   XtUnmanageChild (XtParent (h));
  1139. #endif
  1140.   Nlm_RestorePort (tempPort);
  1141. }
  1142.  
  1143. static void Nlm_EnableText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1144.  
  1145. {
  1146.   Nlm_TextTool  h;
  1147.   Nlm_BaR       sb;
  1148.   Nlm_WindoW    tempPort;
  1149.  
  1150.   if (setFlag) {
  1151.     Nlm_SetEnabled (t, TRUE);
  1152.   }
  1153.   if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  1154.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1155.     sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1156.     if (sb != NULL) {
  1157.       Nlm_DoEnable ((Nlm_GraphiC) sb, TRUE, FALSE);
  1158.     }
  1159.     sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1160.     if (sb != NULL) {
  1161.       Nlm_DoEnable ((Nlm_GraphiC) sb, TRUE, FALSE);
  1162.     }
  1163.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1164. #ifdef WIN_MAC
  1165.     if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1166.       Nlm_DoDraw (t);
  1167.     }
  1168. #endif
  1169. #ifdef WIN_MSWIN
  1170.     EnableWindow (h, TRUE);
  1171. #endif
  1172. #ifdef WIN_MOTIF
  1173.     XtVaSetValues (h, XmNsensitive, TRUE, NULL);
  1174. #endif
  1175.     Nlm_RestorePort (tempPort);
  1176.   }
  1177. }
  1178.  
  1179. static void Nlm_DisableText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  1180.  
  1181. {
  1182.   Nlm_TextTool  h;
  1183.   Nlm_BaR       sb;
  1184.   Nlm_WindoW    tempPort;
  1185.  
  1186.   if (setFlag) {
  1187.     Nlm_SetEnabled (t, FALSE);
  1188.   }
  1189.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1190.   sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1191.   if (sb != NULL) {
  1192.     Nlm_DoDisable ((Nlm_GraphiC) sb, TRUE, FALSE);
  1193.   }
  1194.   sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1195.   if (sb != NULL) {
  1196.     Nlm_DoDisable ((Nlm_GraphiC) sb, TRUE, FALSE);
  1197.   }
  1198.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1199. #ifdef WIN_MAC
  1200.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1201.     Nlm_DoDraw (t);
  1202.   }
  1203. #endif
  1204. #ifdef WIN_MSWIN
  1205.   EnableWindow (h, FALSE);
  1206. #endif
  1207. #ifdef WIN_MOTIF
  1208.   XtVaSetValues (h, XmNsensitive, FALSE, NULL);
  1209. #endif
  1210.   Nlm_RestorePort (tempPort);
  1211. }
  1212.  
  1213. static void Nlm_ActivateText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1214.  
  1215. {
  1216. #ifdef WIN_MAC
  1217.   Nlm_TextTool  h;
  1218.   Nlm_RecT      r;
  1219.   Nlm_RectTool  rtool;
  1220. #endif
  1221.  
  1222.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1223.     if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t) && Nlm_GetActive ((Nlm_TexT) t)) {
  1224. #ifdef WIN_MAC
  1225.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1226.       Nlm_GetRect (t, &r);
  1227.       Nlm_InsetRect (&r, 2, 2);
  1228.       TEActivate (h);
  1229.       TECalText (h);
  1230.       Nlm_RecTToRectTool (&r, &rtool);
  1231.       TEUpdate (&rtool, h);
  1232. #endif
  1233. #ifdef WIN_MSWIN
  1234.       if (t != NULL) {
  1235.         Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  1236.       }
  1237. #endif
  1238. #ifdef WIN_MOTIF
  1239.       if (t != NULL) {
  1240.         Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  1241.       }
  1242. #endif
  1243.     }
  1244.   }
  1245. }
  1246.  
  1247. static void Nlm_ActivateHiddenText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1248.  
  1249. {
  1250. #ifdef WIN_MAC
  1251.   Nlm_TextTool  h;
  1252.   Nlm_RecT      r;
  1253.   Nlm_RectTool  rtool;
  1254. #endif
  1255. #ifdef WIN_MSWIN
  1256.   Nlm_TextTool  h;
  1257. #endif
  1258.  
  1259.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1260.     if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t) && Nlm_GetActive ((Nlm_TexT) t)) {
  1261. #ifdef WIN_MAC
  1262.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1263.       Nlm_GetRect (t, &r);
  1264.       TEActivate (h);
  1265.       TECalText (h);
  1266.       Nlm_RecTToRectTool (&r, &rtool);
  1267.       TEUpdate (&rtool, h);
  1268. #endif
  1269. #ifdef WIN_MSWIN
  1270.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1271.       if (t != NULL && h != NULL) {
  1272.         if (Nlm_Visible (t) && Nlm_AllParentsVisible (t)) {
  1273.           SetFocus (h);
  1274.         }
  1275.       }
  1276. #endif
  1277.     }
  1278.   }
  1279. }
  1280.  
  1281. static void Nlm_ActivateScrollText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1282.  
  1283. {
  1284.   Nlm_TextTool  h;
  1285. #ifdef WIN_MAC
  1286.   Nlm_RecT      r;
  1287.   Nlm_RectTool  rtool;
  1288. #endif
  1289.  
  1290.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1291.     if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t) && Nlm_GetActive ((Nlm_TexT) t)) {
  1292. #ifdef WIN_MAC
  1293.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1294.       Nlm_GetRect (t, &r);
  1295.       Nlm_InsetRect (&r, 4, 2);
  1296.       r.bottom = r.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
  1297.       TEActivate (h);
  1298.       TECalText (h);
  1299.       Nlm_RecTToRectTool (&r, &rtool);
  1300.       TEUpdate (&rtool, h);
  1301. #endif
  1302. #ifdef WIN_MSWIN
  1303.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1304.       if (t != NULL && h != NULL) {
  1305.         if (Nlm_Visible (t) && Nlm_AllParentsVisible (t)) {
  1306.           SetFocus (h);
  1307.         }
  1308.       }
  1309. #endif
  1310.     }
  1311.   }
  1312. }
  1313.  
  1314. static void Nlm_DeactivateText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1315.  
  1316. {
  1317. #ifdef WIN_MAC
  1318.   Nlm_TextTool  h;
  1319.   Nlm_RecT      r;
  1320.   Nlm_RectTool  rtool;
  1321.  
  1322.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1323.     if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  1324.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1325.       Nlm_GetRect (t, &r);
  1326.       Nlm_InsetRect (&r, 2, 2);
  1327.       TEDeactivate (h);
  1328.       TECalText (h);
  1329.       Nlm_RecTToRectTool (&r, &rtool);
  1330.       TEUpdate (&rtool, h);
  1331.     }
  1332.   }
  1333. #endif
  1334. }
  1335.  
  1336. static void Nlm_DeactivateScrollText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1337.  
  1338. {
  1339. #ifdef WIN_MAC
  1340.   Nlm_TextTool  h;
  1341.   Nlm_RecT      r;
  1342.   Nlm_RectTool  rtool;
  1343.  
  1344.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1345.     if (Nlm_GetEnabled (t) && Nlm_GetAllParentsEnabled (t)) {
  1346.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1347.       Nlm_GetRect (t, &r);
  1348.       Nlm_InsetRect (&r, 4, 2);
  1349.       r.bottom = r.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
  1350.       TEDeactivate (h);
  1351.       TECalText (h);
  1352.       Nlm_RecTToRectTool (&r, &rtool);
  1353.       TEUpdate (&rtool, h);
  1354.     }
  1355.   }
  1356. #endif
  1357. }
  1358.  
  1359. static void Nlm_ResetText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1360.  
  1361. {
  1362. #ifdef WIN_MAC
  1363.   Nlm_Int2      delta;
  1364.   Nlm_TextTool  h;
  1365.   Nlm_Int2      height;
  1366.   Nlm_BaR       sb;
  1367.   Nlm_WindoW    tempPort;
  1368.   Nlm_Int2      width;
  1369.  
  1370.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1371.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1372.   TESetSelect (0, 32767, h);
  1373.   TEDelete (h);
  1374.   sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1375.   if (sb != NULL) {
  1376.     delta = Nlm_DoGetValue ((Nlm_GraphiC) sb);
  1377.     height = Nlm_GetLineHeight ((Nlm_TexT) t);
  1378.     TEScroll (0, delta * height, h);
  1379.     Nlm_DoReset ((Nlm_GraphiC) sb, FALSE);
  1380.   }
  1381.   sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1382.   if (sb != NULL) {
  1383.     delta = Nlm_DoGetValue ((Nlm_GraphiC) sb);
  1384.     width = Nlm_stdCharWidth;
  1385.     TEScroll (delta * width, 0, h);
  1386.     Nlm_DoReset ((Nlm_GraphiC) sb, FALSE);
  1387.   }
  1388.   Nlm_RestorePort (tempPort);
  1389. #endif
  1390. #ifdef WIN_MSWIN
  1391.   Nlm_TextTool  h;
  1392.  
  1393.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1394.   SetWindowText (h, "");
  1395. #endif
  1396. #ifdef WIN_MOTIF
  1397.   Nlm_TextTool  h;
  1398.   Nlm_Char      str [5];
  1399.  
  1400.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1401.   allowTextCallback = FALSE;
  1402.   str [0] = '\0';
  1403.   XmTextSetString (h, str);
  1404.   XmTextShowPosition (h, 0);
  1405.   allowTextCallback = TRUE;
  1406. #endif
  1407. }
  1408.  
  1409. static void Nlm_RemoveText (Nlm_GraphiC t, Nlm_Boolean savePort)
  1410.  
  1411. {
  1412.   Nlm_TextTool  h;
  1413.   Nlm_WindoW    tempPort;
  1414. #ifdef WIN_MAC
  1415.   Nlm_BaR       sb;
  1416. #endif
  1417.  
  1418.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1419.   if (currentText == (Nlm_TexT) t) {
  1420.     currentText = NULL;
  1421.   }
  1422.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1423. #ifdef WIN_MAC
  1424.   TEDispose (h);
  1425.   sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  1426.   if (sb != NULL) {
  1427.     Nlm_DoRemove ((Nlm_GraphiC) sb, FALSE);
  1428.   }
  1429.   sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  1430.   if (sb != NULL) {
  1431.     Nlm_DoRemove ((Nlm_GraphiC) sb, FALSE);
  1432.   }
  1433. #endif
  1434. #ifdef WIN_MSWIN
  1435.   RemoveProp (h, (LPSTR) "Nlm_VibrantProp");
  1436.   DestroyWindow (h);
  1437. #endif
  1438. #ifdef WIN_MOTIF
  1439.   XtDestroyWidget (h);
  1440. #endif
  1441.   Nlm_RemoveLink (t);
  1442.   recentText = NULL;
  1443.   Nlm_RestorePort (tempPort);
  1444. }
  1445.  
  1446. static void Nlm_TextSelectProc (Nlm_GraphiC t, Nlm_Boolean savePort)
  1447.  
  1448. {
  1449. #ifdef WIN_MAC
  1450.   Nlm_Int2      end;
  1451.   Nlm_TextTool  h;
  1452.   TEPtr         hp;
  1453.   Nlm_WindoW    tempPort;
  1454.  
  1455.   if (t != NULL) {
  1456.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1457.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1458.     HLock ((Handle) h);
  1459.     hp = (TEPtr) *((Handle) h);
  1460.     end = hp->teLength;
  1461.     HUnlock ((Handle) h);
  1462.     Nlm_SelectAText ((Nlm_TexT) t, 0, end);
  1463.     Nlm_RestorePort (tempPort);
  1464.   }
  1465. #endif
  1466. #ifdef WIN_MSWIN
  1467.   Nlm_WindoW  tempPort;
  1468.  
  1469.   if (t != NULL) {
  1470.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1471.     Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  1472.     Nlm_RestorePort (tempPort);
  1473.   }
  1474. #endif
  1475. #ifdef WIN_MOTIF
  1476.   Nlm_WindoW  tempPort;
  1477.  
  1478.   if (t != NULL) {
  1479.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1480.     Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  1481.     Nlm_RestorePort (tempPort);
  1482.   }
  1483. #endif
  1484. }
  1485.  
  1486. extern Nlm_sizeT Nlm_TextLength (Nlm_TexT t)
  1487.  
  1488. {
  1489.   Nlm_TextTool  h;
  1490.   Nlm_sizeT        len;
  1491. #ifdef WIN_MAC
  1492.   TEPtr         hp;
  1493. #endif
  1494. #ifdef WIN_MOTIF
  1495.   Nlm_CharPtr   ptr;
  1496. #endif
  1497.  
  1498.   len = 0;
  1499.   if (t != NULL) {
  1500.     h = Nlm_GetTextHandle (t);
  1501. #ifdef WIN_MAC
  1502.     HLock ((Handle) h);
  1503.     hp = (TEPtr) *((Handle) h);
  1504.     len = hp->teLength;
  1505.     HUnlock ((Handle) h);
  1506. #endif
  1507. #ifdef WIN_MSWIN
  1508.     len = (Nlm_sizeT) GetWindowTextLength (h);
  1509. #endif
  1510. #ifdef WIN_MOTIF
  1511.     ptr = XmTextGetString (h);
  1512.     len = Nlm_StringLen (ptr);
  1513.     XtFree (ptr);
  1514. #endif
  1515.   }
  1516.   return len;
  1517. }
  1518.  
  1519. extern void Nlm_SelectText (Nlm_TexT t, Nlm_Int2 begin, Nlm_Int2 end)
  1520.  
  1521. {
  1522.   Nlm_WindoW  tempPort;
  1523.  
  1524.   if (t != NULL) {
  1525.     tempPort = Nlm_SavePortIfNeeded ((Nlm_GraphiC) t, TRUE);
  1526.     begin = MAX (begin, 0);
  1527.     end = MAX (end, 0);
  1528.     Nlm_SelectAText ((Nlm_TexT) t, begin, end);
  1529.     Nlm_RestorePort (tempPort);
  1530.   }
  1531. }
  1532.  
  1533. static void Nlm_SetDialogText (Nlm_GraphiC t, Nlm_Int2 item,
  1534.                                Nlm_CharPtr title, Nlm_Boolean savePort)
  1535.  
  1536. {
  1537.   Nlm_TextTool  h;
  1538.   Nlm_WindoW    tempPort;
  1539. #ifdef WIN_MAC
  1540.   TEPtr         hp;
  1541.   Nlm_Uint4     len;
  1542.   Nlm_RecT      r;
  1543.   Nlm_Int4      selStart;
  1544.   Nlm_Int4      selEnd;
  1545. #endif
  1546. #ifdef WIN_MOTIF
  1547.   Nlm_CharPtr   str;
  1548. #endif
  1549.  
  1550.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1551.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1552. #ifdef WIN_MAC
  1553.   len = Nlm_StringLen (title);
  1554.   if (len > 0) {
  1555.     TESetText (title, len, h);
  1556.     TECalText (h);
  1557.   } else {
  1558.     selStart = 0;
  1559.     HLock ((Handle) h);
  1560.     hp = (TEPtr) *((Handle) h);
  1561.     selEnd = hp->teLength;
  1562.     HUnlock ((Handle) h);
  1563.     TESetSelect (selStart, selEnd, h);
  1564.     TEDelete (h);
  1565.   }
  1566.   Nlm_GetRect (t, &r);
  1567.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1568.     Nlm_InsetRect (&r, 1, 1);
  1569.     Nlm_InvalRect (&r);
  1570.   }
  1571.   Nlm_UpdateScrollBar ((Nlm_TexT) t);
  1572. #endif
  1573. #ifdef WIN_MSWIN
  1574.   SetWindowText (h, title);
  1575. #endif
  1576. #ifdef WIN_MOTIF
  1577.   allowTextCallback = FALSE;
  1578.   str = Nlm_StringSave (title);
  1579.   XmTextSetString (h, str);
  1580.   Nlm_MemFree (str);
  1581.   XmTextShowPosition (h, 0);
  1582.   allowTextCallback = TRUE;
  1583. #endif
  1584.   Nlm_RestorePort (tempPort);
  1585. }
  1586.  
  1587. static void Nlm_SetPasswordText (Nlm_GraphiC t, Nlm_Int2 item,
  1588.                                  Nlm_CharPtr title, Nlm_Boolean savePort)
  1589.  
  1590. {
  1591.   Nlm_TextTool  h;
  1592.   Nlm_Int2      leng;
  1593.   Nlm_Char      stars [32];
  1594.   Nlm_WindoW    tempPort;
  1595. #ifdef WIN_MAC
  1596.   TEPtr         hp;
  1597.   Nlm_Uint4     len;
  1598.   Nlm_RecT      r;
  1599.   Nlm_Int4      selStart;
  1600.   Nlm_Int4      selEnd;
  1601. #endif
  1602. #ifdef WIN_MOTIF
  1603.   Nlm_Char      bspace [5];
  1604.   Nlm_CharPtr   str;
  1605. #endif
  1606.  
  1607.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1608.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1609.   Nlm_SetPassword ((Nlm_TexT) t, title);
  1610.   Nlm_StringCpy (stars, "******************************");
  1611.   leng = (Nlm_Int2) Nlm_StringLen (title);
  1612.   if (leng < 32) {
  1613.     stars [leng] = '\0';
  1614.   }
  1615. #ifdef WIN_MAC
  1616.   len = Nlm_StringLen (stars);
  1617.   if (len > 0) {
  1618.     TESetText (stars, len, h);
  1619.     TECalText (h);
  1620.   } else {
  1621.     selStart = 0;
  1622.     HLock ((Handle) h);
  1623.     hp = (TEPtr) *((Handle) h);
  1624.     selEnd = hp->teLength;
  1625.     HUnlock ((Handle) h);
  1626.     TESetSelect (selStart, selEnd, h);
  1627.     TEDelete (h);
  1628.   }
  1629.   Nlm_GetRect (t, &r);
  1630.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1631.     Nlm_InsetRect (&r, 1, 1);
  1632.     Nlm_InvalRect (&r);
  1633.   }
  1634.   Nlm_UpdateScrollBar ((Nlm_TexT) t);
  1635. #endif
  1636. #ifdef WIN_MSWIN
  1637.   SetWindowText (h, title);
  1638. #endif
  1639. #ifdef WIN_MOTIF
  1640.   allowTextCallback = FALSE;
  1641.   Nlm_StringCpy (bspace, "\b");
  1642.   XmTextSetString (h, bspace);
  1643.   str = Nlm_StringSave (title);
  1644.   XmTextSetString (h, str);
  1645.   Nlm_MemFree (str);
  1646.   allowTextCallback = TRUE;
  1647. #endif
  1648.   Nlm_RestorePort (tempPort);
  1649. }
  1650.  
  1651. static void Nlm_SetScrollText (Nlm_GraphiC t, Nlm_Int2 item,
  1652.                                Nlm_CharPtr title, Nlm_Boolean savePort)
  1653.  
  1654. {
  1655.   Nlm_TextTool  h;
  1656.   Nlm_WindoW    tempPort;
  1657. #ifdef WIN_MAC
  1658.   TEPtr         hp;
  1659.   Nlm_Uint4     len;
  1660.   Nlm_RecT      r;
  1661.   Nlm_Int4      selStart;
  1662.   Nlm_Int4      selEnd;
  1663. #endif
  1664.  
  1665.   tempPort = Nlm_SavePortIfNeeded (t, savePort);
  1666.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1667. #ifdef WIN_MAC
  1668.   len = Nlm_StringLen (title);
  1669.   if (len > 0) {
  1670.     TESetText (title, len, h);
  1671.     TECalText (h);
  1672.   } else {
  1673.     selStart = 0;
  1674.     HLock ((Handle) h);
  1675.     hp = (TEPtr) *((Handle) h);
  1676.     selEnd = hp->teLength;
  1677.     HUnlock ((Handle) h);
  1678.     TESetSelect (selStart, selEnd, h);
  1679.     TEDelete (h);
  1680.   }
  1681.   Nlm_GetRect (t, &r);
  1682.   Nlm_InsetRect (&r, 4, 2);
  1683.   r.bottom = r.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
  1684.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  1685.     Nlm_InsetRect (&r, -1, -1);
  1686.     Nlm_InvalRect (&r);
  1687.   }
  1688.   Nlm_UpdateScrollBar ((Nlm_TexT) t);
  1689. #endif
  1690. #ifdef WIN_MSWIN
  1691.   SetWindowText (h, title);
  1692. #endif
  1693. #ifdef WIN_MOTIF
  1694.   allowTextCallback = FALSE;
  1695.   /*
  1696.      The gcc compiler puts static strings in read only memory.  Motif 1.1 dies
  1697.      at this point for text objects (Dialog, Hidden and Password) that use the
  1698.      modifyVerify callback.  In those cases, the strings are copied.
  1699.   */
  1700.   XmTextSetString (h, title);
  1701.   allowTextCallback = TRUE;
  1702. #endif
  1703.   Nlm_RestorePort (tempPort);
  1704. }
  1705.  
  1706. static void Nlm_GetDialogText (Nlm_GraphiC t, Nlm_Int2 item,
  1707.                                Nlm_CharPtr title, Nlm_sizeT maxsize)
  1708.  
  1709. {
  1710.   Nlm_TextTool  h;
  1711. #ifdef WIN_MAC
  1712.   Nlm_Char      **chars;
  1713.   TEPtr         hp;
  1714.   Nlm_Int2      i;
  1715.   Nlm_Int2      length;
  1716.   Nlm_Char      *ptr;
  1717. #endif
  1718. #ifdef WIN_MOTIF
  1719.   Nlm_CharPtr   ptr;
  1720. #endif
  1721.  
  1722.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1723. #ifdef WIN_MAC
  1724.   i = 0;
  1725.   HLock ((Handle) h);
  1726.   hp = (TEPtr) *((Handle) h);
  1727.   chars = hp->hText;
  1728.   length = hp->teLength;
  1729.   if (length > maxsize - 1) {
  1730.     length = maxsize - 1;
  1731.   }
  1732.   HUnlock ((Handle) h);
  1733.   if (chars != NULL) {
  1734.     HLock ((Handle) chars);
  1735.     ptr = (Nlm_Char *) *((Handle) chars);
  1736.     Nlm_StringNCpy (title, ptr, length);
  1737.     title [length] = '\0';
  1738.     HUnlock ((Handle) chars);
  1739.   }
  1740. #endif
  1741. #ifdef WIN_MSWIN
  1742.     GetWindowText (h, title, maxsize);
  1743.     title [maxsize - 1] = '\0';
  1744. #endif
  1745. #ifdef WIN_MOTIF
  1746.   ptr = XmTextGetString (h);
  1747.   Nlm_StringNCpy (title, ptr, maxsize);
  1748.   XtFree (ptr);
  1749. #endif
  1750. }
  1751.  
  1752. static void Nlm_GetPasswordText (Nlm_GraphiC t, Nlm_Int2 item,
  1753.                                  Nlm_CharPtr title, Nlm_sizeT maxsize)
  1754.  
  1755. {
  1756.   Nlm_GetPassword ((Nlm_TexT) t, title, maxsize);
  1757. }
  1758.  
  1759. static void Nlm_GetScrollText (Nlm_GraphiC t, Nlm_Int2 item,
  1760.                                Nlm_CharPtr title, Nlm_sizeT maxsize)
  1761.  
  1762. {
  1763.   Nlm_TextTool  h;
  1764. #ifdef WIN_MAC
  1765.   Nlm_Char      **chars;
  1766.   TEPtr         hp;
  1767.   Nlm_Int2      i;
  1768.   Nlm_Int2      length;
  1769.   Nlm_Char      *ptr;
  1770. #endif
  1771. #ifdef WIN_MOTIF
  1772.   Nlm_CharPtr   ptr;
  1773. #endif
  1774.  
  1775.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  1776. #ifdef WIN_MAC
  1777.   i = 0;
  1778.   HLock ((Handle) h);
  1779.   hp = (TEPtr) *((Handle) h);
  1780.   chars = hp->hText;
  1781.   length = hp->teLength;
  1782.   if (length > maxsize - 1) {
  1783.     length = maxsize - 1;
  1784.   }
  1785.   HUnlock ((Handle) h);
  1786.   if (chars != NULL) {
  1787.     HLock ((Handle) chars);
  1788.     ptr = (Nlm_Char *) *((Handle) chars);
  1789.     Nlm_StringNCpy (title, ptr, length);
  1790.     title [length] = '\0';
  1791.     HUnlock ((Handle) chars);
  1792.   }
  1793. #endif
  1794. #ifdef WIN_MSWIN
  1795.     GetWindowText (h, title, maxsize);
  1796.     title [maxsize - 1] = '\0';
  1797. #endif
  1798. #ifdef WIN_MOTIF
  1799.   ptr = XmTextGetString (h);
  1800.   Nlm_StringNCpy (title, ptr, maxsize);
  1801.   XtFree (ptr);
  1802. #endif
  1803. }
  1804.  
  1805. extern Nlm_TexT Nlm_CurrentText (void)
  1806.  
  1807. {
  1808.   return currentText;
  1809. }
  1810.  
  1811. extern void Nlm_CutText (Nlm_TexT t)
  1812.  
  1813. {
  1814.   Nlm_TextTool  h;
  1815.  
  1816.   if (t != NULL) {
  1817.     h = Nlm_GetTextHandle (t);
  1818. #ifdef WIN_MAC
  1819.     TECut (h);
  1820. #endif
  1821. #ifdef WIN_MSWIN
  1822.     SendMessage (h, WM_CUT, 0, 0);
  1823. #endif
  1824. #ifdef WIN_MOTIF
  1825.     allowTextCallback = FALSE;
  1826.     XmTextCut (h, CurrentTime);
  1827.     allowTextCallback = TRUE;
  1828. #endif
  1829.     Nlm_DoAction ((Nlm_GraphiC) t);
  1830.   }
  1831. }
  1832.  
  1833. extern void Nlm_CopyText (Nlm_TexT t)
  1834.  
  1835. {
  1836.   Nlm_TextTool  h;
  1837.  
  1838.   if (t != NULL) {
  1839.     h = Nlm_GetTextHandle (t);
  1840. #ifdef WIN_MAC
  1841.     TECopy (h);
  1842. #endif
  1843. #ifdef WIN_MSWIN
  1844.     SendMessage (h, WM_COPY, 0, 0);
  1845. #endif
  1846. #ifdef WIN_MOTIF
  1847.     allowTextCallback = FALSE;
  1848.     XmTextCopy (h, CurrentTime);
  1849.     allowTextCallback = TRUE;
  1850. #endif
  1851.   }
  1852. }
  1853.  
  1854. extern void Nlm_PasteText (Nlm_TexT t)
  1855.  
  1856. {
  1857.   Nlm_TextTool  h;
  1858.  
  1859.   if (t != NULL) {
  1860.     h = Nlm_GetTextHandle (t);
  1861. #ifdef WIN_MAC
  1862.     TEPaste (h);
  1863. #endif
  1864. #ifdef WIN_MSWIN
  1865.     SendMessage (h, WM_PASTE, 0, 0);
  1866. #endif
  1867. #ifdef WIN_MOTIF
  1868.     allowTextCallback = FALSE;
  1869.     XmTextPaste (h);
  1870.     allowTextCallback = TRUE;
  1871. #endif
  1872.     Nlm_DoAction ((Nlm_GraphiC) t);
  1873.   }
  1874. }
  1875.  
  1876. extern void Nlm_ClearText (Nlm_TexT t)
  1877.  
  1878. {
  1879.   Nlm_TextTool  h;
  1880.  
  1881.   if (t != NULL) {
  1882.     h = Nlm_GetTextHandle (t);
  1883. #ifdef WIN_MAC
  1884.     TEDelete (h);
  1885. #endif
  1886. #ifdef WIN_MSWIN
  1887.     SendMessage (h, WM_CLEAR, 0, 0);
  1888. #endif
  1889. #ifdef WIN_MOTIF
  1890.     allowTextCallback = FALSE;
  1891.     XmTextClearSelection (h, CurrentTime);
  1892.     allowTextCallback = TRUE;
  1893. #endif
  1894.     Nlm_DoAction ((Nlm_GraphiC) t);
  1895.   }
  1896. }
  1897.  
  1898. #ifdef WIN_MSWIN
  1899. /* Message cracker functions */
  1900.  
  1901. static void MyCls_OnChar (HWND hwnd, UINT ch, int cRepeat)
  1902.  
  1903. {
  1904.   Nlm_TexT  t;
  1905.  
  1906.   t = (Nlm_TexT) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
  1907.   handlechar = FALSE;
  1908.   if (ch == '\t' && Nlm_IsHiddenText ((Nlm_TexT) t)) {
  1909.     Nlm_DoTabCallback (t);
  1910.   } else if (ch == '\t') {
  1911.     Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
  1912.   } else if (ch == '\n' || ch == '\r') {
  1913.     Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
  1914.   } else {
  1915.     handlechar = TRUE;
  1916.   }
  1917. }
  1918.  
  1919. static void MyCls_OnSetFocus (HWND hwnd, HWND hwndOldFocus)
  1920.  
  1921. {
  1922.   Nlm_TexT  t;
  1923.  
  1924.   t = (Nlm_TexT) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
  1925.   Nlm_SetActive (t, TRUE);
  1926.   Nlm_DoTextSelect (t);
  1927. }
  1928.  
  1929. static void MyCls_OnKillFocus (HWND hwnd, HWND hwndNewFocus)
  1930.  
  1931. {
  1932.   Nlm_TexT  t;
  1933.  
  1934.   t = (Nlm_TexT) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
  1935.   if (Nlm_GetActive (t)) {
  1936.     Nlm_DoTextDeselect (t);
  1937.   }
  1938.   /*
  1939.   currentText = NULL;
  1940.   */
  1941. }
  1942.  
  1943. LRESULT CALLBACK EXPORT TextProc (HWND hwnd, UINT message,
  1944.                                   WPARAM wParam, LPARAM lParam)
  1945.  
  1946. {
  1947.   LRESULT   rsult;
  1948.   Nlm_TexT  t;
  1949.   HDC       tempHDC;
  1950.   HWND      tempHWnd;
  1951.  
  1952.   if (Nlm_VibrantDisabled ()) {
  1953.     return CallWindowProc (lpfnOldTextProc, hwnd, message, wParam, lParam);
  1954.   }
  1955.  
  1956.   rsult = 0;
  1957.   tempHWnd = Nlm_currentHWnd;
  1958.   tempHDC = Nlm_currentHDC;
  1959.   t = (Nlm_TexT) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
  1960.   Nlm_theWindow = Nlm_GetParentWindow ((Nlm_GraphiC) t);
  1961.   Nlm_currentHWnd = GetParent (hwnd);
  1962.   Nlm_currentHDC = Nlm_ParentWindowPort ((Nlm_GraphiC) t);
  1963.   Nlm_currentWindowTool = hwnd;
  1964.   Nlm_currentKey = '\0';
  1965.   Nlm_currentWParam = wParam;
  1966.   Nlm_currentLParam = lParam;
  1967.   Nlm_cmmdKey = FALSE;
  1968.   Nlm_ctrlKey = FALSE;
  1969.   Nlm_optKey = FALSE;
  1970.   Nlm_shftKey = FALSE;
  1971.   Nlm_dblClick = FALSE;
  1972.  
  1973.   switch (message) {
  1974.     case WM_CHAR:
  1975.       HANDLE_WM_CHAR (hwnd, wParam, lParam, MyCls_OnChar);
  1976.       if (handlechar) {
  1977.         rsult = CallWindowProc (lpfnOldTextProc, hwnd, message, wParam, lParam);
  1978.       }
  1979.       break;
  1980.     case WM_SETFOCUS:
  1981.       HANDLE_WM_SETFOCUS (hwnd, wParam, lParam, MyCls_OnSetFocus);
  1982.       rsult = CallWindowProc (lpfnOldTextProc, hwnd, message, wParam, lParam);
  1983.       break;
  1984.     case WM_KILLFOCUS:
  1985.       HANDLE_WM_KILLFOCUS (hwnd, wParam, lParam, MyCls_OnKillFocus);
  1986.       rsult = CallWindowProc (lpfnOldTextProc, hwnd, message, wParam, lParam);
  1987.       break;
  1988.     default:
  1989.       rsult = CallWindowProc (lpfnOldTextProc, hwnd, message, wParam, lParam);
  1990.       break;
  1991.   }
  1992.   Nlm_currentHWnd = tempHWnd;
  1993.   Nlm_currentHDC = tempHDC;
  1994.   Nlm_currentWindowTool = tempHWnd;
  1995.   return rsult;
  1996. }
  1997. #endif
  1998.  
  1999. static Nlm_GraphiC Nlm_TextGainFocus (Nlm_GraphiC t, Nlm_Char ch, Nlm_Boolean savePort)
  2000.  
  2001. {
  2002. #ifdef WIN_MAC
  2003.   Nlm_TextTool  h;
  2004.   TEPtr         hp;
  2005.   Nlm_Int2      len;
  2006.   Nlm_GraphiC   rsult;
  2007.  
  2008.   rsult = NULL;
  2009.   if (ch == '\t' && Nlm_GetVisible (t) && Nlm_GetEnabled (t)) {
  2010.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2011.     HLock ((Handle) h);
  2012.     hp = (TEPtr) *((Handle) h);
  2013.     len = hp->teLength;
  2014.     HUnlock ((Handle) h);
  2015.     Nlm_SetActive ((Nlm_TexT) t, TRUE);
  2016.     Nlm_SelectAText ((Nlm_TexT) t, 0, len);
  2017.     rsult = t;
  2018.   }
  2019.   return rsult;
  2020. #endif
  2021. #ifdef WIN_MSWIN
  2022.   Nlm_GraphiC   rsult;
  2023.  
  2024.   rsult = NULL;
  2025.   if (ch == '\t' && Nlm_GetVisible (t) && Nlm_GetEnabled (t)) {
  2026.     Nlm_SetActive ((Nlm_TexT) t, TRUE);
  2027.     Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  2028.     rsult = t;
  2029.   }
  2030.   return rsult;
  2031. #endif
  2032. #ifdef WIN_MOTIF
  2033.   Nlm_GraphiC   rsult;
  2034.  
  2035.   rsult = NULL;
  2036.   if (ch == '\t' && Nlm_GetVisible (t) && Nlm_GetEnabled (t)) {
  2037.     Nlm_SetActive ((Nlm_TexT) t, TRUE);
  2038.     Nlm_SelectAText ((Nlm_TexT) t, 0, 32767);
  2039.     rsult = t;
  2040.   }
  2041.   return rsult;
  2042. #endif
  2043. }
  2044.  
  2045. static void Nlm_TextLoseFocus (Nlm_GraphiC t, Nlm_GraphiC excpt, Nlm_Boolean savePort)
  2046.  
  2047. {
  2048.   Nlm_WindoW  tempPort;
  2049.  
  2050.   if (t != excpt) {
  2051.     if (Nlm_GetActive ((Nlm_TexT) t)) {
  2052.       Nlm_DoTextDeselect ((Nlm_TexT) t);
  2053.     }
  2054.     Nlm_SetActive ((Nlm_TexT) t, FALSE);
  2055.     tempPort = Nlm_SavePortIfNeeded (t, savePort);
  2056.     Nlm_DeactivateText (t, FALSE);
  2057.     Nlm_RestorePort (tempPort);
  2058.   }
  2059. }
  2060.  
  2061. #ifdef WIN_MAC
  2062. static void Nlm_InvalText (Nlm_GraphiC t)
  2063.  
  2064. {
  2065.   Nlm_RecT  r;
  2066.  
  2067.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  2068.     Nlm_GetRect (t, &r);
  2069.     Nlm_InsetRect (&r, -1, -1);
  2070.     Nlm_InvalRect (&r);
  2071.   }
  2072. }
  2073.  
  2074. static void Nlm_InvalScrollText (Nlm_GraphiC t)
  2075.  
  2076. {
  2077.   Nlm_RecT  r;
  2078.  
  2079.   if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  2080.     Nlm_GetRect (t, &r);
  2081.     r.right += Nlm_vScrollBarWidth;
  2082.     if (! Nlm_GetTextWrap ((Nlm_TexT) t)) {
  2083.       r.bottom += Nlm_hScrollBarHeight;
  2084.     }
  2085.     Nlm_InsetRect (&r, -1, -1);
  2086.     Nlm_InvalRect (&r);
  2087.   }
  2088. }
  2089. #endif
  2090.  
  2091. static void Nlm_SetTextPosition (Nlm_GraphiC t, Nlm_RectPtr r, Nlm_Boolean savePort)
  2092.  
  2093. {
  2094.   Nlm_TextTool  h;
  2095.   Nlm_RecT      oldRect;
  2096.   Nlm_WindoW    tempPort;
  2097.   Nlm_RecT      tr;
  2098. #ifdef WIN_MAC
  2099.   TEPtr         hp;
  2100.   Nlm_RectTool  rtool;
  2101. #endif
  2102.  
  2103.   if (r != NULL) {
  2104.     Nlm_DoGetPosition (t, &oldRect);
  2105.     if (! Nlm_EqualRect (r, &oldRect)) {
  2106.       tempPort = Nlm_SavePortIfNeeded (t, savePort);
  2107.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2108. #ifdef WIN_MAC
  2109.       Nlm_InvalText (t);
  2110. #endif
  2111.       tr = *r;
  2112. #ifdef WIN_MAC
  2113.       Nlm_InsetRect (&tr, 2, 2);
  2114.       Nlm_RecTToRectTool (&tr, &rtool);
  2115.       HLock ((Handle) h);
  2116.       hp = (TEPtr) *((Handle) h);
  2117.       hp->destRect = rtool;
  2118.       hp->viewRect = rtool;
  2119.       HUnlock ((Handle) h);
  2120.       Nlm_SetRect (t, r);
  2121.       Nlm_InvalText (t);
  2122. #endif
  2123. #ifdef WIN_MSWIN
  2124.       MoveWindow (h, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, TRUE);
  2125.       Nlm_SetRect (t, r);
  2126.       UpdateWindow (h);
  2127. #endif
  2128. #ifdef WIN_MOTIF
  2129.       allowTextCallback = FALSE;
  2130.       XtVaSetValues (h,
  2131.                      XmNx, (Position) tr.left + 3,
  2132.                      XmNy, (Position) tr.top + 3,
  2133.                      XmNwidth, (Dimension) (tr.right - tr.left - 6),
  2134.                      XmNheight, (Dimension) (tr.bottom - tr.top - 6), 
  2135.                      NULL);
  2136.       Nlm_SetRect (t, r);
  2137.       allowTextCallback = TRUE;
  2138. #endif
  2139.       Nlm_RestorePort (tempPort);
  2140.     }
  2141.   }
  2142. }
  2143.  
  2144. static void Nlm_SetHiddenTextPosition (Nlm_GraphiC t, Nlm_RectPtr r, Nlm_Boolean savePort)
  2145.  
  2146. {
  2147.   Nlm_TextTool  h;
  2148.   Nlm_RecT      oldRect;
  2149.   Nlm_WindoW    tempPort;
  2150.   Nlm_RecT      tr;
  2151. #ifdef WIN_MAC
  2152.   TEPtr         hp;
  2153.   Nlm_RectTool  rtool;
  2154. #endif
  2155.  
  2156.   if (r != NULL) {
  2157.     Nlm_DoGetPosition (t, &oldRect);
  2158.     if (! Nlm_EqualRect (r, &oldRect)) {
  2159.       tempPort = Nlm_SavePortIfNeeded (t, savePort);
  2160.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2161. #ifdef WIN_MAC
  2162.       Nlm_InvalText (t);
  2163. #endif
  2164.       tr = *r;
  2165. #ifdef WIN_MAC
  2166.       Nlm_RecTToRectTool (&tr, &rtool);
  2167.       HLock ((Handle) h);
  2168.       hp = (TEPtr) *((Handle) h);
  2169.       hp->destRect = rtool;
  2170.       hp->viewRect = rtool;
  2171.       HUnlock ((Handle) h);
  2172.       Nlm_SetRect (t, r);
  2173.       Nlm_InvalText (t);
  2174. #endif
  2175. #ifdef WIN_MSWIN
  2176.       MoveWindow (h, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, TRUE);
  2177.       Nlm_SetRect (t, r);
  2178.       UpdateWindow (h);
  2179. #endif
  2180. #ifdef WIN_MOTIF
  2181.       allowTextCallback = FALSE;
  2182.       XtVaSetValues (h,
  2183.                      XmNx, (Position) tr.left,
  2184.                      XmNy, (Position) tr.top,
  2185.                      XmNwidth, (Dimension) (tr.right - tr.left),
  2186.                      XmNheight, (Dimension) (tr.bottom - tr.top), 
  2187.                      NULL);
  2188.       Nlm_SetRect (t, r);
  2189.       allowTextCallback = TRUE;
  2190. #endif
  2191.       Nlm_RestorePort (tempPort);
  2192.     }
  2193.   }
  2194. }
  2195.  
  2196. static void Nlm_SetScrollTextPosition (Nlm_GraphiC t, Nlm_RectPtr r, Nlm_Boolean savePort)
  2197.  
  2198. {
  2199.   Nlm_TextTool  h;
  2200.   Nlm_RecT      oldRect;
  2201.   Nlm_WindoW    tempPort;
  2202.   Nlm_RecT      tr;
  2203.   Nlm_Boolean   wrap;
  2204. #ifdef WIN_MAC
  2205.   Nlm_RectTool  dtool;
  2206.   TEPtr         hp;
  2207.   Nlm_RectTool  rtool;
  2208.   Nlm_BaR       sb;
  2209. #endif
  2210.  
  2211.   if (r != NULL) {
  2212.     Nlm_DoGetPosition (t,&oldRect);
  2213.     if (! Nlm_EqualRect (r, &oldRect)) {
  2214.       tempPort = Nlm_SavePortIfNeeded (t, savePort);
  2215.       h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2216.       if (h != NULL) {
  2217.         wrap = Nlm_GetTextWrap ((Nlm_TexT) t);
  2218.         tr = *r;
  2219. #ifdef WIN_MAC
  2220.         Nlm_InvalScrollText (t);
  2221.         tr.right -= Nlm_vScrollBarWidth;
  2222.         if (! wrap) {
  2223.           tr.bottom -= Nlm_hScrollBarHeight;
  2224.         }
  2225.         Nlm_SetRect (t, &tr);
  2226.         Nlm_InsetRect (&tr, 4, 2);
  2227.         tr.bottom = tr.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
  2228.         Nlm_RecTToRectTool (&tr, &rtool);
  2229.         Nlm_RecTToRectTool (&tr, &dtool);
  2230.         if (! wrap) {
  2231. #ifdef DCLAP
  2232.           dtool.right = 32767;
  2233. #else
  2234.           dtool.right += HSCROLL_POSITIONS * Nlm_stdCharWidth;
  2235. #endif
  2236.         }
  2237.         HLock ((Handle) h);
  2238.         hp = (TEPtr) *((Handle) h);
  2239.         hp->destRect = dtool;
  2240.         hp->viewRect = rtool;
  2241.         HUnlock ((Handle) h);
  2242.         Nlm_InvalScrollText (t);
  2243.         sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
  2244.         if (sb != NULL) {
  2245.           Nlm_GetRect (t, &tr);
  2246.           tr.left = tr.right;
  2247.           tr.right += Nlm_vScrollBarWidth;
  2248.           Nlm_DoSetPosition ((Nlm_GraphiC) sb, &tr, FALSE);
  2249.         }
  2250.         sb = Nlm_GetTextHScrollBar ((Nlm_TexT) t);
  2251.         if (sb != NULL) {
  2252.           Nlm_GetRect (t, &tr);
  2253.           tr.top = tr.bottom;
  2254.           tr.bottom += Nlm_hScrollBarHeight;
  2255.           Nlm_DoSetPosition ((Nlm_GraphiC) sb, &tr, FALSE);
  2256.         }
  2257. #endif
  2258. #ifdef WIN_MSWIN
  2259.         MoveWindow (h, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, TRUE);
  2260.         tr.right -= Nlm_vScrollBarWidth;
  2261.         if (! wrap) {
  2262.           tr.bottom -= Nlm_hScrollBarHeight;
  2263.         }
  2264.         Nlm_SetRect (t, &tr);
  2265.         UpdateWindow (h);
  2266. #endif
  2267. #ifdef WIN_MOTIF
  2268.         allowTextCallback = FALSE;
  2269.         XtVaSetValues (XtParent (h),
  2270.                        XmNx, (Position) tr.left + 3,
  2271.                        XmNy, (Position) tr.top + 3,
  2272.                        XmNwidth, (Dimension) (tr.right - tr.left) - 6,
  2273.                        XmNheight, (Dimension) (tr.bottom - tr.top) - 6,
  2274.                        NULL);
  2275.         tr.right -= Nlm_vScrollBarWidth;
  2276.         if (! wrap) {
  2277.           tr.bottom -= Nlm_hScrollBarHeight;
  2278.         }
  2279.         Nlm_SetRect (t, &tr);
  2280.         allowTextCallback = TRUE;
  2281. #endif
  2282.       }
  2283.       Nlm_RestorePort (tempPort);
  2284.     }
  2285.   }
  2286. }
  2287.  
  2288. static void Nlm_GetTextPosition (Nlm_GraphiC t, Nlm_RectPtr r)
  2289.  
  2290. {
  2291.   if (r != NULL) {
  2292.     Nlm_GetRect (t, r);
  2293.   }
  2294. }
  2295.  
  2296. static void Nlm_GetScrollTextPosition (Nlm_GraphiC t, Nlm_RectPtr r)
  2297.  
  2298. {
  2299.   if (r != NULL) {
  2300.     Nlm_GetRect (t, r);
  2301.     r->right += Nlm_vScrollBarWidth;
  2302.     if (! Nlm_GetTextWrap ((Nlm_TexT) t)) {
  2303.       r->bottom += Nlm_hScrollBarHeight;
  2304.     }
  2305.   }
  2306. }
  2307.  
  2308. #ifdef WIN_MAC
  2309. static void Nlm_VScrollAction (Nlm_BaR sb, Nlm_GraphiC t,
  2310.                                Nlm_Int2 newval, Nlm_Int2 oldval)
  2311.  
  2312. {
  2313.   Nlm_Int2      delta;
  2314.   Nlm_TextTool  h;
  2315.   Nlm_Int2      height;
  2316.   Nlm_RecT      r;
  2317.  
  2318.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2319.   delta = oldval - newval;
  2320.   if (oldval != newval) {
  2321.         SelectDialogFont();
  2322.       height = Nlm_GetLineHeight ((Nlm_TexT) t);
  2323.     TEScroll (0, delta * height, h);
  2324.   } else if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  2325.     Nlm_GetRect (t, &r);
  2326.     Nlm_InsetRect (&r, 2, 1);
  2327.     Nlm_InvalRect (&r);
  2328.   }
  2329.   Nlm_Update ();
  2330. }
  2331.  
  2332. static void Nlm_HScrollAction (Nlm_BaR sb, Nlm_GraphiC t,
  2333.                                Nlm_Int2 newval, Nlm_Int2 oldval)
  2334. {
  2335.   Nlm_Int2      delta;
  2336.   Nlm_TextTool  h;
  2337.   Nlm_Int2      width;
  2338.   Nlm_RecT      r;
  2339.  
  2340.   h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2341.   delta = oldval - newval;
  2342.   if (oldval != newval) {
  2343.         SelectDialogFont();
  2344. #ifdef DCLAP
  2345.         width= Nlm_CharWidth('G');
  2346. #else
  2347.     width = Nlm_stdCharWidth;
  2348. #endif
  2349.     TEScroll (delta * width, 0, h);
  2350.   } else if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
  2351.     Nlm_GetRect (t, &r);
  2352.     Nlm_InsetRect (&r, 2, 1);
  2353.     Nlm_InvalRect (&r);
  2354.   }
  2355.   Nlm_Update ();
  2356. }
  2357. #endif
  2358.  
  2359.  
  2360. #ifdef DCLAP
  2361. extern void Nlm_HScrollText(Nlm_BaR sb, Nlm_GraphiC t, Nlm_Int2 newval, Nlm_Int2 oldval)
  2362. {
  2363. #ifdef WIN_MAC
  2364.     Nlm_HScrollAction( sb, t, newval, oldval);
  2365. #endif
  2366.  
  2367. #ifdef WIN_MSWIN
  2368.   Nlm_TextTool  h;
  2369.   if (t && oldval != newval) {
  2370.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2371.         SendMessage( h, WM_HSCROLL, SB_THUMBTRACK, newval);
  2372.         }
  2373. #endif
  2374.  
  2375. #ifdef WIN_MOTIF
  2376.   Nlm_TextTool  h;
  2377.   if (t && oldval != newval) {
  2378.     h = Nlm_GetTextHandle ((Nlm_TexT) t);
  2379.         if (newval < 0) newval= 0; 
  2380.     XmTextShowPosition( h, newval); 
  2381.         }
  2382. #endif
  2383. }
  2384.  
  2385. extern void Nlm_SetTextColumns( Nlm_GraphiC t, Nlm_Int2 ncolumns)
  2386. {
  2387. #ifdef WIN_MOTIF
  2388.   if (t) {
  2389.         Nlm_TextTool h;
  2390.         short n;
  2391.       Arg   wargs [20];
  2392.       n= 0;
  2393.       XtSetArg( wargs[n], XmNcolumns, ncolumns); n++;
  2394.         h = Nlm_GetTextHandle(( Nlm_TexT) t);
  2395.       XtSetValues( h, wargs, n);
  2396.       }
  2397. #endif
  2398. }
  2399.  
  2400. #endif
  2401.  
  2402. #ifdef WIN_MOTIF
  2403. static void Nlm_ReturnCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2404.  
  2405. {
  2406.   XmAnyCallbackStruct  *cbs;
  2407.   Nlm_GraphiC          t;
  2408.  
  2409.   cbs = (XmAnyCallbackStruct *) call_data;
  2410.   t = (Nlm_GraphiC) client_data;
  2411.   if (cbs->event != NULL) {
  2412.     Nlm_DoSendFocus ((Nlm_GraphiC) t, '\r');
  2413.   }
  2414. }
  2415.  
  2416. static void Nlm_TextCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2417.  
  2418. {
  2419.   XmAnyCallbackStruct  *cbs;
  2420.   Nlm_GraphiC          t;
  2421.  
  2422.   cbs = (XmAnyCallbackStruct *) call_data;
  2423.   t = (Nlm_GraphiC) client_data;
  2424.   if (cbs->event != NULL) {
  2425.     Nlm_DoAction (t);
  2426.   } else if (allowTextCallback) {
  2427.     Nlm_DoAction (t);
  2428.   }
  2429. }
  2430.  
  2431. static void Nlm_FocusCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2432.  
  2433. {
  2434.   XmAnyCallbackStruct  *cbs;
  2435.   Nlm_TexT             t;
  2436.  
  2437.   cbs = (XmAnyCallbackStruct *) call_data;
  2438.   t = (Nlm_TexT) client_data;
  2439.   Nlm_SetActive (t, TRUE);
  2440.   Nlm_DoTextSelect (t);
  2441. }
  2442.  
  2443. static void Nlm_LoseFocusCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2444.  
  2445. {
  2446.   XmAnyCallbackStruct  *cbs;
  2447.   Nlm_TexT             t;
  2448.  
  2449.   cbs = (XmAnyCallbackStruct *) call_data;
  2450.   t = (Nlm_TexT) client_data;
  2451.   if (Nlm_GetActive (t)) {
  2452.     Nlm_DoTextDeselect (t);
  2453.   }
  2454.   /*
  2455.   currentText = NULL;
  2456.   */
  2457. }
  2458.  
  2459. static void Nlm_RefreshCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2460.  
  2461. {
  2462.   XmTextVerifyCallbackStruct  *cbs;
  2463.   Nlm_RecT                    r;
  2464.   Nlm_TexT                    t;
  2465.  
  2466.   cbs = (XmTextVerifyCallbackStruct *) call_data;
  2467.   t = (Nlm_TexT) client_data;
  2468.   if (cbs->text->ptr == NULL) {
  2469.     Nlm_ObjectRect ((Nlm_GraphiC) t, &r);
  2470.     Nlm_OffsetRect (&r, -r.left, -r.top);
  2471.     if (! Nlm_IsHiddenText (t)) {
  2472.       Nlm_InsetRect (&r, 4, 4);
  2473. #ifdef OS_VMS
  2474.       Nlm_InsetRect (&r, 5, 3);
  2475. #else
  2476.       Nlm_InsetRect (&r, 5, 5);
  2477. #endif
  2478.     }
  2479.     if (Nlm_currentXDisplay != NULL) {
  2480.       XClearArea (Nlm_currentXDisplay, XtWindow (w), r.left, r.top,
  2481.                   r.right - r.left, r.bottom - r.top, TRUE);
  2482.     }
  2483.   }
  2484. }
  2485.  
  2486. static void Nlm_PasswordCallback (Widget w, XtPointer client_data, XtPointer call_data)
  2487.  
  2488. {
  2489.   XmTextVerifyCallbackStruct  *cbs;
  2490.   int                         len;
  2491.   Nlm_Char                    password [32];
  2492.   Nlm_GraphiC                 t;
  2493.  
  2494.   cbs = (XmTextVerifyCallbackStruct *) call_data;
  2495.   t = (Nlm_GraphiC) client_data;
  2496.   if (cbs->text->length > 1) {
  2497.     cbs->doit = FALSE;
  2498.     return;
  2499.   }
  2500.   if (cbs->text->ptr == NULL) {
  2501.     Nlm_GetPassword ((Nlm_TexT) t, password, sizeof (password) - 1);
  2502.     cbs->endPos = (long) Nlm_StringLen (password);
  2503.     cbs->startPos = 0;
  2504.     password [cbs->startPos] = '\0';
  2505.     Nlm_SetPassword ((Nlm_TexT) t, password);
  2506.     return;
  2507.   }
  2508.   Nlm_GetPassword ((Nlm_TexT) t, password, sizeof (password) - 1);
  2509.   Nlm_StringNCat (password, cbs->text->ptr, cbs->text->length);
  2510.   password [cbs->endPos + cbs->text->length] = '\0';
  2511.   Nlm_SetPassword ((Nlm_TexT) t, password);
  2512.   for (len = 0; len < cbs->text->length; len++) {
  2513.     cbs->text->ptr [len] = '*';
  2514.   }
  2515. }
  2516.  
  2517. static void Nlm_TabCallback (Widget w, XEvent *ev, String *args, Cardinal *num_args)
  2518.  
  2519. {
  2520.   XKeyEvent  *event;
  2521.   XtPointer     ptr;
  2522.   Nlm_TexT   t;
  2523.  
  2524.   event = (XKeyEvent *) ev;
  2525.   XtVaGetValues (w, XmNuserData, &ptr, NULL);
  2526.   t = (Nlm_TexT) ptr;
  2527.   Nlm_DoTabCallback (t);
  2528. }
  2529. #endif
  2530.  
  2531. static void Nlm_NewDialogText (Nlm_TexT t, Nlm_CharPtr dfault, Nlm_TxtActnProc actn)
  2532.  
  2533. {
  2534.   Nlm_TextTool    h;
  2535.   Nlm_Int2        leng;
  2536.   Nlm_Char        local [128];
  2537.   Nlm_RecT        r;
  2538.   Nlm_Char        stars [32];
  2539.   Nlm_WindowTool  wptr;
  2540. #ifdef WIN_MAC
  2541.   Nlm_RectTool    rtool;
  2542. #endif
  2543. #ifdef WIN_MSWIN
  2544.   Nlm_Uint4       style;
  2545. #endif
  2546. #ifdef WIN_MOTIF
  2547.   Cardinal        n;
  2548.   Arg             wargs [20];
  2549.   XmFontList      fontlist;
  2550. #endif
  2551.  
  2552.   Nlm_StringCpy (stars, "******************************");
  2553.   local [0] = '\0';
  2554.   Nlm_StringNCpy (local, dfault, sizeof (local) - 1);
  2555.   leng = (Nlm_Int2) Nlm_StringLen (local);
  2556.   if (leng < 32) {
  2557.     stars [leng] = '\0';
  2558.   }
  2559.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  2560.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) t);
  2561. #ifdef WIN_MAC
  2562.   Nlm_InsetRect (&r, 2, 2);
  2563.   Nlm_RecTToRectTool (&r, &rtool);
  2564.   h = TENew (&rtool, &rtool);
  2565.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2566.           FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2567.   Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
  2568.   if (h != NULL) {
  2569.     TEAutoView (TRUE, h);
  2570.   }
  2571. #endif
  2572. #ifdef WIN_MSWIN
  2573.   style = WS_CHILD | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | ES_LEFT;
  2574.   h = CreateWindow ("Edit", local, style,
  2575.                     r.left, r.top, r.right - r.left,
  2576.                     r.bottom - r.top, wptr, 0,
  2577.                     Nlm_currentHInst, NULL);
  2578.   if (h != NULL) {
  2579.     SetProp (h, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) t);
  2580. #ifdef DCLAP
  2581. #if 1
  2582. {
  2583.     /* this is vibrant way */
  2584.   HFONT    oldFont;
  2585.   Nlm_FntPtr      fntptr;
  2586.   oldFont = NULL;
  2587.   if (gDialogTextFont != NULL) {
  2588.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  2589.     if (fntptr != NULL && fntptr->handle != NULL) {
  2590.       oldFont = SelectObject (Nlm_currentHDC, fntptr->handle);
  2591.     }
  2592.     Nlm_HandUnlock (gDialogTextFont);
  2593.   } else {
  2594.     oldFont = SelectObject (Nlm_currentHDC, GetStockObject (ANSI_FIXED_FONT));
  2595.   }
  2596.   if (oldFont != NULL) {
  2597.     SelectObject (Nlm_currentHDC, oldFont);
  2598.     SetWindowFont (h, oldFont, FALSE);
  2599.   }
  2600.  }
  2601. #else
  2602.         {
  2603.         /* dgg way */
  2604.         Nlm_FontData    fdata;
  2605.         Nlm_GetFontData( gDialogTextFont, &fdata);
  2606.         PostMessage( h, WM_SETFONT, fdata.handle, 0L);
  2607.         }
  2608. #endif
  2609. #endif
  2610.   }
  2611.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight,
  2612.            FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2613.   if (lpfnNewTextProc == NULL) {
  2614.     lpfnNewTextProc = (WNDPROC) MakeProcInstance ((FARPROC) TextProc, Nlm_currentHInst);
  2615.   }
  2616.   if (lpfnOldTextProc == NULL) {
  2617.     lpfnOldTextProc = (WNDPROC) GetWindowLong (h, GWL_WNDPROC);
  2618.   } else if (lpfnOldTextProc != (WNDPROC) GetWindowLong (h, GWL_WNDPROC)) {
  2619.     Nlm_Message (MSG_ERROR, "TextProc subclass error");
  2620.   }
  2621.   SetWindowLong (h, GWL_WNDPROC, (LONG) lpfnNewTextProc);
  2622. #endif
  2623. #ifdef WIN_MOTIF
  2624.   allowTextCallback = FALSE;
  2625.   Nlm_InsetRect (&r, 3, 3);
  2626.   fontlist = NULL;
  2627. #ifdef DCLAP
  2628.   if (gDialogTextFont != NULL) {
  2629.       Nlm_FntPtr fntptr;
  2630.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  2631.     if (fntptr != NULL && fntptr->handle != NULL) {
  2632.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  2633.     }
  2634.     Nlm_HandUnlock (font);
  2635.   }
  2636. #endif
  2637.   n = 0;
  2638.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  2639.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  2640.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  2641.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  2642. #ifdef OS_VMS
  2643.   XtSetArg (wargs [n], XmNmarginHeight, 1); n++;
  2644. #else
  2645.   XtSetArg (wargs [n], XmNmarginHeight, 3); n++;
  2646. #endif
  2647.   XtSetArg (wargs [n], XmNmarginWidth, 3); n++;
  2648.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  2649.   XtSetArg (wargs [n], XmNeditMode, XmSINGLE_LINE_EDIT); n++;
  2650. #ifdef DCLAP
  2651.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  2652. #else
  2653.   XtSetArg (wargs [n], XmNfontList, NULL); n++;
  2654. #endif
  2655.   XtSetArg (wargs [n], XmNhighlightThickness, 0); n++;
  2656.   XtSetArg (wargs [n], XmNautoShowCursorPosition, TRUE); n++;
  2657.   h = XmCreateText (wptr, (String) "", wargs, n);
  2658.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2659.           FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2660.   XmTextSetString (h, local);
  2661.   XmTextShowPosition (h, 0);
  2662.   XtAddCallback (h, XmNmodifyVerifyCallback, Nlm_RefreshCallback, (XtPointer) t);
  2663.   XtAddCallback (h, XmNvalueChangedCallback, Nlm_TextCallback, (XtPointer) t);
  2664.   XtAddCallback (h, XmNactivateCallback, Nlm_ReturnCallback, (XtPointer) t);
  2665.   XtAddCallback (h, XmNfocusCallback, Nlm_FocusCallback, (XtPointer) t);
  2666.   XtAddCallback (h, XmNlosingFocusCallback, Nlm_LoseFocusCallback, (XtPointer) t);
  2667.   if (NLM_QUIET) {
  2668.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  2669.       XtRealizeWidget (h);
  2670.     }
  2671.   } else {
  2672.     XtRealizeWidget (h);
  2673.   }
  2674.   allowTextCallback = TRUE;
  2675. #ifdef DCLAP
  2676.   if (fontlist != NULL) {
  2677.     XmFontListFree (fontlist);
  2678.   }
  2679. #endif
  2680. #endif
  2681.   Nlm_LoadAction ((Nlm_GraphiC) t, (Nlm_ActnProc) actn);
  2682. }
  2683.  
  2684. static void Nlm_NewPasswordText (Nlm_TexT t, Nlm_CharPtr dfault, Nlm_TxtActnProc actn)
  2685.  
  2686. {
  2687.   Nlm_TextTool    h;
  2688.   Nlm_Int2        leng;
  2689.   Nlm_Char        local [128];
  2690.   Nlm_RecT        r;
  2691.   Nlm_Char        stars [32];
  2692.   Nlm_WindowTool  wptr;
  2693. #ifdef WIN_MAC
  2694.   Nlm_RectTool    rtool;
  2695. #endif
  2696. #ifdef WIN_MSWIN
  2697.   Nlm_Uint4       style;
  2698. #endif
  2699. #ifdef WIN_MOTIF
  2700.   Cardinal        n;
  2701.   Arg             wargs [20];
  2702.   XmFontList      fontlist;
  2703. #endif
  2704.  
  2705.   Nlm_StringCpy (stars, "******************************");
  2706.   local [0] = '\0';
  2707.   Nlm_StringNCpy (local, dfault, sizeof (local) - 1);
  2708.   leng = (Nlm_Int2) Nlm_StringLen (local);
  2709.   if (leng < 32) {
  2710.     stars [leng] = '\0';
  2711.   }
  2712.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  2713.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) t);
  2714. #ifdef WIN_MAC
  2715.   Nlm_InsetRect (&r, 2, 2);
  2716.   Nlm_RecTToRectTool (&r, &rtool);
  2717.   h = TENew (&rtool, &rtool);
  2718.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2719.           FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2720.   Nlm_SetPasswordText ((Nlm_GraphiC) t, 0, local, FALSE);
  2721. #endif
  2722. #ifdef WIN_MSWIN
  2723.   style = WS_CHILD | WS_BORDER |  ES_AUTOVSCROLL | ES_LEFT | ES_PASSWORD;
  2724.   h = CreateWindow ("Edit", local, style,
  2725.                     r.left, r.top, r.right - r.left,
  2726.                     r.bottom - r.top, wptr, 0,
  2727.                     Nlm_currentHInst, NULL);
  2728.   if (h != NULL) {
  2729.     SetProp (h, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) t);
  2730.   }
  2731.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2732.           FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2733.   if (lpfnNewTextProc == NULL) {
  2734.     lpfnNewTextProc = (WNDPROC) MakeProcInstance ((FARPROC) TextProc, Nlm_currentHInst);
  2735.   }
  2736.   if (lpfnOldTextProc == NULL) {
  2737.     lpfnOldTextProc = (WNDPROC) GetWindowLong (h, GWL_WNDPROC);
  2738.   } else if (lpfnOldTextProc != (WNDPROC) GetWindowLong (h, GWL_WNDPROC)) {
  2739.     Nlm_Message (MSG_ERROR, "TextProc subclass error");
  2740.   }
  2741.   SetWindowLong (h, GWL_WNDPROC, (LONG) lpfnNewTextProc);
  2742.   Nlm_SetPassword (t, local);
  2743. #endif
  2744. #ifdef WIN_MOTIF
  2745.   allowTextCallback = FALSE;
  2746.   Nlm_InsetRect (&r, 3, 3);
  2747.   fontlist = NULL;
  2748. #ifdef DCLAP
  2749.   if (gDialogTextFont != NULL) {
  2750.       Nlm_FntPtr fntptr;
  2751.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  2752.     if (fntptr != NULL && fntptr->handle != NULL) {
  2753.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  2754.     }
  2755.     Nlm_HandUnlock (font);
  2756.   }
  2757. #endif
  2758.   n = 0;
  2759.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  2760.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  2761.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  2762.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  2763.   XtSetArg (wargs [n], XmNmarginHeight, 3); n++;
  2764.   XtSetArg (wargs [n], XmNmarginWidth, 3); n++;
  2765.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  2766.   XtSetArg (wargs [n], XmNeditMode, XmSINGLE_LINE_EDIT); n++;
  2767. #ifdef DCLAP
  2768.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  2769. #else
  2770.   XtSetArg (wargs [n], XmNfontList, NULL); n++;
  2771. #endif
  2772.   XtSetArg (wargs [n], XmNhighlightThickness, 0); n++;
  2773.   h = XmCreateText (wptr, (String) "", wargs, n);
  2774.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2775.       FALSE, FALSE, FALSE, 1, NULL, NULL, NULL);
  2776.   XmTextSetString (h, local);
  2777.   XtAddCallback (h, XmNmodifyVerifyCallback, Nlm_PasswordCallback, (XtPointer) t);
  2778.   XtAddCallback (h, XmNvalueChangedCallback, Nlm_TextCallback, (XtPointer) t);
  2779.   XtAddCallback (h, XmNactivateCallback, Nlm_ReturnCallback, (XtPointer) t);
  2780.   XtAddCallback (h, XmNfocusCallback, Nlm_FocusCallback, (XtPointer) t);
  2781.   XtAddCallback (h, XmNlosingFocusCallback, Nlm_LoseFocusCallback, (XtPointer) t);
  2782.   if (NLM_QUIET) {
  2783.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  2784.       XtRealizeWidget (h);
  2785.     }
  2786.   } else {
  2787.     XtRealizeWidget (h);
  2788.   }
  2789.   Nlm_SetPassword (t, dfault);
  2790.   allowTextCallback = TRUE;
  2791. #ifdef DCLAP
  2792.   if (fontlist != NULL) {
  2793.     XmFontListFree (fontlist);
  2794.   }
  2795. #endif
  2796. #endif
  2797.   Nlm_LoadAction ((Nlm_GraphiC) t, (Nlm_ActnProc) actn);
  2798. }
  2799.  
  2800. static void Nlm_NewHiddenText (Nlm_TexT t, Nlm_CharPtr dfault,
  2801.                                Nlm_TxtActnProc actn, Nlm_TxtActnProc tabProc)
  2802.  
  2803. {
  2804.   Nlm_TextTool    h;
  2805.   Nlm_Int2        leng;
  2806.   Nlm_Char        local [128];
  2807.   Nlm_RecT        r;
  2808.   Nlm_Char        stars [32];
  2809.   Nlm_WindowTool  wptr;
  2810. #ifdef WIN_MAC
  2811.   Nlm_RectTool    rtool;
  2812.   Nlm_RectTool    dtool;
  2813. #endif
  2814. #ifdef WIN_MSWIN
  2815.   Nlm_Uint4       style;
  2816. #endif
  2817. #ifdef WIN_MOTIF
  2818.   Cardinal        n;
  2819.   Arg             wargs [20];
  2820.   XmFontList      fontlist;
  2821. #endif
  2822.  
  2823.   Nlm_StringCpy (stars, "******************************");
  2824.   local [0] = '\0';
  2825.   Nlm_StringNCpy (local, dfault, sizeof (local) - 1);
  2826.   leng = (Nlm_Int2) Nlm_StringLen (local);
  2827.   if (leng < 32) {
  2828.     stars [leng] = '\0';
  2829.   }
  2830.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  2831.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) t);
  2832. #ifdef WIN_MAC
  2833.   Nlm_RecTToRectTool (&r, &rtool);  
  2834.   h = TENew (&rtool, &rtool);
  2835.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2836.           FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc);
  2837.   Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
  2838.   if (h != NULL) {
  2839.     TEAutoView (TRUE, h);
  2840.   }
  2841. #endif
  2842. #ifdef WIN_MSWIN
  2843.   style = WS_CHILD | ES_MULTILINE | ES_AUTOVSCROLL | ES_LEFT;
  2844.   h = CreateWindow ("Edit", local, style,
  2845.                     r.left, r.top, r.right - r.left,
  2846.                     r.bottom - r.top, wptr, 0,
  2847.                     Nlm_currentHInst, NULL);
  2848.   if (h != NULL) {
  2849.     SetProp (h, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) t);
  2850. #ifdef DCLAP
  2851. #if 1
  2852. {
  2853.     /* vibrant way */
  2854.   HFONT    oldFont;
  2855.   Nlm_FntPtr      fntptr;
  2856.   oldFont = NULL;
  2857.   if (gDialogTextFont != NULL) {
  2858.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  2859.     if (fntptr != NULL && fntptr->handle != NULL) {
  2860.       oldFont = SelectObject (Nlm_currentHDC, fntptr->handle);
  2861.     }
  2862.     Nlm_HandUnlock (gDialogTextFont);
  2863.   } else {
  2864.     oldFont = SelectObject (Nlm_currentHDC, GetStockObject (ANSI_FIXED_FONT));
  2865.   }
  2866.   if (oldFont != NULL) {
  2867.     SelectObject (Nlm_currentHDC, oldFont);
  2868.     SetWindowFont (h, oldFont, FALSE);
  2869.   }
  2870.  }
  2871. #else
  2872.     /* dgg way */
  2873.         {
  2874.         Nlm_FontData    fdata;
  2875.         Nlm_GetFontData( gDialogTextFont, &fdata);
  2876.         PostMessage( h, WM_SETFONT, fdata.handle, 0L);
  2877.         }
  2878. #endif
  2879. #endif
  2880.   }
  2881.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2882.           FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc);
  2883.   if (lpfnNewTextProc == NULL) {
  2884.     lpfnNewTextProc = (WNDPROC) MakeProcInstance ((FARPROC) TextProc, Nlm_currentHInst);
  2885.   }
  2886.   if (lpfnOldTextProc == NULL) {
  2887.     lpfnOldTextProc = (WNDPROC) GetWindowLong (h, GWL_WNDPROC);
  2888.   } else if (lpfnOldTextProc != (WNDPROC) GetWindowLong (h, GWL_WNDPROC)) {
  2889.     Nlm_Message (MSG_ERROR, "TextProc subclass error");
  2890.   }
  2891.   SetWindowLong (h, GWL_WNDPROC, (LONG) lpfnNewTextProc);
  2892. #endif
  2893.  
  2894. #ifdef WIN_MOTIF
  2895.   allowTextCallback = FALSE;
  2896.   fontlist = NULL;
  2897. #ifdef DCLAP
  2898.   if (gDialogTextFont != NULL) {
  2899.       Nlm_FntPtr fntptr;
  2900.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  2901.     if (fntptr != NULL && fntptr->handle != NULL) {
  2902.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  2903.     }
  2904.     Nlm_HandUnlock (font);
  2905.   }
  2906. #endif
  2907.   n = 0;
  2908.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  2909.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  2910.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  2911.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  2912. #ifdef OS_VMS
  2913.   XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
  2914. #else
  2915.   XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
  2916. #endif
  2917.   XtSetArg (wargs [n], XmNmarginWidth, 0); n++;
  2918.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  2919.   XtSetArg (wargs [n], XmNshadowThickness, (Dimension) 0); n++;
  2920.   XtSetArg (wargs [n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  2921. #ifdef DCLAP
  2922.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  2923. #else
  2924.   XtSetArg (wargs [n], XmNfontList, NULL); n++;
  2925. #endif
  2926.   XtSetArg (wargs [n], XmNhighlightThickness, 0); n++;
  2927.   XtSetArg (wargs [n], XmNautoShowCursorPosition, TRUE); n++;
  2928.   XtSetArg (wargs [n], XmNverifyBell, FALSE); n++;
  2929.   h = XmCreateText (wptr, (String) "", wargs, n);
  2930.   XtOverrideTranslations (h, XtParseTranslationTable ("<Key>Tab: do_tab()"));
  2931.   XtVaSetValues (h, XmNuserData, (XtPointer) t, NULL);
  2932.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2933.           FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc);
  2934.   XmTextSetString (h, local);
  2935.   XmTextShowPosition (h, 0);
  2936.   XtAddCallback (h, XmNmodifyVerifyCallback, Nlm_RefreshCallback, (XtPointer) t);
  2937.   XtAddCallback (h, XmNvalueChangedCallback, Nlm_TextCallback, (XtPointer) t);
  2938.   XtAddCallback (h, XmNactivateCallback, Nlm_ReturnCallback, (XtPointer) t);
  2939.   XtAddCallback (h, XmNfocusCallback, Nlm_FocusCallback, (XtPointer) t);
  2940.   XtAddCallback (h, XmNlosingFocusCallback, Nlm_LoseFocusCallback, (XtPointer) t);
  2941.   if (NLM_QUIET) {
  2942.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  2943.       XtRealizeWidget (h);
  2944.     }
  2945.   } else {
  2946.     XtRealizeWidget (h);
  2947.   }
  2948. #ifdef DCLAP
  2949.   if (fontlist != NULL) {
  2950.     XmFontListFree (fontlist);
  2951.   }
  2952. #endif
  2953.   allowTextCallback = TRUE;
  2954. #endif
  2955.   Nlm_LoadAction ((Nlm_GraphiC) t, (Nlm_ActnProc) actn);
  2956. }
  2957.  
  2958.  
  2959. #ifdef DCLAP
  2960.  
  2961. static void Nlm_NewTextLine (Nlm_TexT t, Nlm_CharPtr dfault, Nlm_Int2 charWidth, 
  2962.                                Nlm_TxtActnProc actn, Nlm_TxtActnProc tabProc)
  2963.  
  2964. {
  2965.   Nlm_TextTool    h;
  2966.   Nlm_Int2        leng;
  2967.   Nlm_Char        local [128];
  2968.   Nlm_RecT        r;
  2969.   Nlm_WindowTool  wptr;
  2970. #ifdef WIN_MAC
  2971.   Nlm_RectTool    rtool;
  2972.   Nlm_RectTool    dtool;
  2973. #endif
  2974. #ifdef WIN_MSWIN
  2975.   Nlm_Uint4       style;
  2976. #endif
  2977. #ifdef WIN_MOTIF
  2978.   Cardinal        n;
  2979.   Arg             wargs [20];
  2980.   XmFontList      fontlist;
  2981. #endif
  2982.  
  2983.   local [0] = '\0';
  2984.   Nlm_StringNCpy (local, dfault, sizeof (local) - 1);
  2985.   leng = (Nlm_Int2) Nlm_StringLen (local);
  2986.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  2987.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) t);
  2988.  
  2989. #ifdef WIN_MAC
  2990.   Nlm_RecTToRectTool (&r, &rtool);
  2991.     Nlm_RecTToRectTool (&r, &dtool);
  2992.     dtool.right= 32000;  
  2993.     h = TENew (&rtool, &dtool);
  2994.     (**h).crOnly= -1;
  2995.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  2996.           FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc);
  2997.   Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
  2998.   if (h != NULL) {
  2999.     TEAutoView (TRUE, h);
  3000.   }
  3001. #endif
  3002.  
  3003. #ifdef WIN_MSWIN
  3004.   style = WS_CHILD | ES_LEFT | ES_AUTOHSCROLL;
  3005.   h = CreateWindow ("Edit", local, style,
  3006.                     r.left, r.top, r.right - r.left,
  3007.                     r.bottom - r.top, wptr, 0,
  3008.                     Nlm_currentHInst, NULL);
  3009.   if (h != NULL) {
  3010.     SetProp (h, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) t);
  3011. #if 1
  3012. {
  3013.     /* vibrant way */
  3014.   HFONT    oldFont;
  3015.   Nlm_FntPtr      fntptr;
  3016.   oldFont = NULL;
  3017.   if (gDialogTextFont != NULL) {
  3018.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  3019.     if (fntptr != NULL && fntptr->handle != NULL) {
  3020.       oldFont = SelectObject (Nlm_currentHDC, fntptr->handle);
  3021.     }
  3022.     Nlm_HandUnlock (gDialogTextFont);
  3023.   } else {
  3024.     oldFont = SelectObject (Nlm_currentHDC, GetStockObject (ANSI_FIXED_FONT));
  3025.   }
  3026.   if (oldFont != NULL) {
  3027.     SelectObject (Nlm_currentHDC, oldFont);
  3028.     SetWindowFont (h, oldFont, FALSE);
  3029.   }
  3030.  }
  3031. #else
  3032.     /* dgg way */
  3033.         {
  3034.         Nlm_FontData    fdata;
  3035.         Nlm_GetFontData( gDialogTextFont, &fdata);
  3036.         PostMessage( h, WM_SETFONT, fdata.handle, 0L);
  3037.         }
  3038. #endif
  3039.  
  3040.   }
  3041.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  3042.       FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc);
  3043.   if (lpfnNewTextProc == NULL) {
  3044.     lpfnNewTextProc = (WNDPROC) MakeProcInstance ((FARPROC) TextProc, Nlm_currentHInst);
  3045.   }
  3046.   if (lpfnOldTextProc == NULL) {
  3047.     lpfnOldTextProc = (WNDPROC) GetWindowLong (h, GWL_WNDPROC);
  3048.   } else if (lpfnOldTextProc != (WNDPROC) GetWindowLong (h, GWL_WNDPROC)) {
  3049.     Nlm_Message (MSG_ERROR, "TextProc subclass error");
  3050.   }
  3051.   SetWindowLong (h, GWL_WNDPROC, (LONG) lpfnNewTextProc);
  3052. #endif
  3053.  
  3054. #ifdef WIN_MOTIF
  3055.   allowTextCallback = FALSE;
  3056.   fontlist = NULL;
  3057. #ifdef DCLAP
  3058.   if (gDialogTextFont != NULL) {
  3059.       Nlm_FntPtr fntptr;
  3060.     fntptr = (Nlm_FntPtr) Nlm_HandLock (gDialogTextFont);
  3061.     if (fntptr != NULL && fntptr->handle != NULL) {
  3062.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  3063.     }
  3064.     Nlm_HandUnlock (font);
  3065.   }
  3066. #endif
  3067.   n = 0;
  3068.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  3069.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  3070.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  3071.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  3072. #ifdef OS_VMS
  3073.   XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
  3074. #else
  3075.   XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
  3076. #endif
  3077.   XtSetArg (wargs [n], XmNmarginWidth, 0); n++;
  3078.       /* dgg -- need XmNcolumns for horiz. scrolling - must be accurate & reset w/ resize !! */
  3079.   if (charWidth) { XtSetArg( wargs[n], XmNcolumns, charWidth); n++; }
  3080.   
  3081.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  3082.   XtSetArg (wargs [n], XmNshadowThickness, (Dimension) 0); n++;
  3083.   XtSetArg (wargs [n], XmNeditMode, XmSINGLE_LINE_EDIT); n++; /* XmMULTI_LINE_EDIT */
  3084. #ifdef DCLAP
  3085.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  3086. #else
  3087.   XtSetArg (wargs [n], XmNfontList, NULL); n++;
  3088. #endif
  3089.   XtSetArg (wargs [n], XmNhighlightThickness, 0); n++;
  3090.   XtSetArg (wargs [n], XmNautoShowCursorPosition, TRUE); n++;
  3091.   XtSetArg (wargs [n], XmNverifyBell, FALSE); n++;
  3092.   h = XmCreateText (wptr, (String) "", wargs, n);
  3093.   XtOverrideTranslations (h, XtParseTranslationTable ("<Key>Tab: do_tab()"));
  3094.   XtVaSetValues (h, XmNuserData, (XtPointer) t, NULL);
  3095.   Nlm_LoadTextData (t, h, NULL, NULL, FALSE, gDialogTextFont, gDlogTextHeight, 
  3096.                           FALSE, FALSE, FALSE, 1, NULL, NULL, tabProc); 
  3097.   XmTextSetString (h, local);
  3098.   XmTextShowPosition (h, 0);
  3099.   XtAddCallback (h, XmNmodifyVerifyCallback, Nlm_RefreshCallback, (XtPointer) t);
  3100.   XtAddCallback (h, XmNvalueChangedCallback, Nlm_TextCallback, (XtPointer) t);
  3101.   XtAddCallback (h, XmNactivateCallback, Nlm_ReturnCallback, (XtPointer) t);
  3102.   XtAddCallback (h, XmNfocusCallback, Nlm_FocusCallback, (XtPointer) t);
  3103.   XtAddCallback (h, XmNlosingFocusCallback, Nlm_LoseFocusCallback, (XtPointer) t);
  3104.   if (NLM_QUIET) {
  3105.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  3106.       XtRealizeWidget (h);
  3107.     }
  3108.   } else {
  3109.     XtRealizeWidget (h);
  3110.   }
  3111.   allowTextCallback = TRUE;
  3112. #ifdef DCLAP
  3113.   if (fontlist != NULL) {
  3114.     XmFontListFree (fontlist);
  3115.   }
  3116. #endif
  3117. #endif
  3118.   Nlm_LoadAction ((Nlm_GraphiC) t, (Nlm_ActnProc) actn);
  3119. }
  3120.  
  3121. extern Nlm_TexT Nlm_TextLine(Nlm_GrouP prnt, Nlm_CharPtr dfault,
  3122.                                 Nlm_Int2 charWidth, Nlm_TxtActnProc actn,
  3123.                                 Nlm_TxtActnProc tabProc)
  3124.  
  3125. {
  3126.   Nlm_Int2    cwid;
  3127.   Nlm_Int2    hbounds;
  3128.   Nlm_PoinT   npt;
  3129.   Nlm_RecT    r;
  3130.   Nlm_Int2    swid;
  3131.   Nlm_TexT    t;
  3132.   Nlm_WindoW  tempPort;
  3133.   Nlm_Int2    vbounds;
  3134.  
  3135.   t = NULL;
  3136.   if (prnt != NULL) {
  3137.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  3138.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  3139.         SelectDialogFont();
  3140.     cwid = charWidth * Nlm_MaxCharWidth();
  3141.     swid = Nlm_StringWidth (dfault);
  3142.     if (cwid > swid) {
  3143.       swid = cwid;
  3144.     }
  3145. #ifdef WIN_MAC
  3146.     hbounds = 0;
  3147.     vbounds = 0;
  3148. #endif
  3149. #ifdef WIN_MSWIN
  3150.     hbounds = 0;
  3151.     vbounds = 0;
  3152. #endif
  3153. #ifdef WIN_MOTIF
  3154.     hbounds = 0;
  3155.     vbounds = 0;
  3156. #endif
  3157.     r.left = npt.x;
  3158.     r.top = npt.y;
  3159.     r.right = r.left + swid + 2 + hbounds * 2;
  3160.     r.bottom = r.top + gDlogTextHeight + vbounds * 2;
  3161.     t = (Nlm_TexT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r,
  3162.                                    sizeof (Nlm_TextRec), 
  3163.                                    hiddenTextProcs); /* dialogTextProcs/ hiddenTextProcs */
  3164.     if (t != NULL) {
  3165.       Nlm_NewTextLine (t, dfault, charWidth, actn, tabProc);
  3166. #ifdef WIN_MAC
  3167.       Nlm_DoSelect ((Nlm_GraphiC) t, FALSE);
  3168. #endif
  3169.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) t, &r, TRUE, FALSE);
  3170.       Nlm_DoShow ((Nlm_GraphiC) t, TRUE, FALSE);
  3171.     }
  3172.     Nlm_RestorePort (tempPort);
  3173.   }
  3174.   return t;
  3175. }
  3176.  
  3177. #endif /* DCLAP */
  3178.  
  3179.  
  3180. static void Nlm_NewScrollText (Nlm_TexT t, Nlm_Int2 height,
  3181.                                Nlm_FonT font, Nlm_Int2 fnthgt,
  3182.                                Nlm_Boolean wrap, Nlm_TxtActnProc actn)
  3183.  
  3184. {
  3185.   Nlm_TextTool    h;
  3186.   Nlm_BaR         hsb;
  3187.   Nlm_RecT        r;
  3188.   Nlm_BaR         vsb;
  3189.   Nlm_WindowTool  wptr;
  3190. #ifdef WIN_MAC
  3191.   Nlm_RectTool    dtool;
  3192.   Nlm_RectTool    rtool;
  3193.   Nlm_Int2        width;
  3194. #endif
  3195. #ifdef WIN_MSWIN
  3196.   Nlm_FntPtr      fntptr;
  3197.   HFONT           oldFont;
  3198.   Nlm_Uint4       style;
  3199. #endif
  3200. #ifdef WIN_MOTIF
  3201.   Nlm_FntPtr      fntptr;
  3202.   XmFontList      fontlist;
  3203.   Cardinal        n;
  3204.   Arg             wargs [15];
  3205. #endif
  3206.  
  3207.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  3208.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) t);
  3209. #ifdef WIN_MAC
  3210.   vsb = NULL;
  3211.   hsb = NULL;
  3212.   r.left = r.right;
  3213.   r.right += Nlm_vScrollBarWidth;
  3214.   vsb = Nlm_VertScrollBar ((Nlm_GraphiC) t, &r, Nlm_VScrollAction);
  3215.   if (! wrap) {
  3216.     Nlm_GetRect ((Nlm_GraphiC) t, &r);
  3217.     r.top = r.bottom;
  3218.     r.bottom += Nlm_hScrollBarHeight;
  3219.     hsb = Nlm_HorizScrollBar ((Nlm_GraphiC) t, &r, Nlm_HScrollAction);
  3220.   }
  3221.   Nlm_GetRect ((Nlm_GraphiC) t, &r);
  3222.   Nlm_InsetRect (&r, 4, 2);
  3223.   if (fnthgt > 0) {
  3224.     height = (r.bottom - r.top + 1) / fnthgt;
  3225.   } else {
  3226.     height = 0;
  3227.   }
  3228.   Nlm_DoSetRange ((Nlm_GraphiC) vsb, height - 1, height - 1, 0, FALSE);
  3229.   r.bottom = r.top + height * fnthgt;
  3230.   Nlm_RecTToRectTool (&r, &rtool);
  3231.   if (! wrap) {
  3232.     width = (r.right - r.left + 1) / Nlm_stdCharWidth;
  3233.     Nlm_DoSetRange ((Nlm_GraphiC) hsb, width - 1, width - 1, 0, FALSE);
  3234.     r.right += HSCROLL_POSITIONS * Nlm_stdCharWidth;
  3235.   }
  3236.   Nlm_RecTToRectTool (&r, &dtool);
  3237.   h = TENew (&dtool, &rtool);
  3238.   Nlm_LoadTextData (t, h, vsb, hsb, wrap, font, fnthgt, 
  3239.               FALSE, FALSE, FALSE, height, NULL, NULL, NULL);
  3240. #endif
  3241. #ifdef WIN_MSWIN
  3242.   vsb = NULL;
  3243.   hsb = NULL;
  3244.   r.right += Nlm_vScrollBarWidth;
  3245.   style = WS_CHILD | WS_BORDER | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_LEFT;
  3246.   if (! wrap) {
  3247.     style |= WS_HSCROLL | ES_AUTOHSCROLL;
  3248.     r.bottom += Nlm_hScrollBarHeight;
  3249.   }
  3250.   h = CreateWindow ("Edit", "", style,
  3251.                     r.left, r.top, r.right - r.left,
  3252.                     r.bottom - r.top, wptr, (Nlm_HandleTool) t,
  3253.                     Nlm_currentHInst, NULL);
  3254.   if (h != NULL) {
  3255.     SetProp (h, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) t);
  3256.   }
  3257.   oldFont = NULL;
  3258.   if (font != NULL) {
  3259.     fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
  3260.     if (fntptr != NULL && fntptr->handle != NULL) {
  3261.       oldFont = SelectObject (Nlm_currentHDC, fntptr->handle);
  3262.     }
  3263.     Nlm_HandUnlock (font);
  3264.   } else {
  3265.     oldFont = SelectObject (Nlm_currentHDC, GetStockObject (ANSI_FIXED_FONT));
  3266.   }
  3267.   if (oldFont != NULL) {
  3268.     SelectObject (Nlm_currentHDC, oldFont);
  3269.     SetWindowFont (h, oldFont, FALSE);
  3270.   }
  3271.   Nlm_LoadTextData (t, h, vsb, hsb, wrap, font, fnthgt, FALSE, FALSE, FALSE, height, NULL, NULL, NULL);
  3272. #endif
  3273. #ifdef WIN_MOTIF
  3274.   allowTextCallback = FALSE;
  3275.   vsb = NULL;
  3276.   hsb = NULL;
  3277.   r.right += Nlm_vScrollBarWidth;
  3278.   if (! wrap) {
  3279.     r.bottom += Nlm_hScrollBarHeight;
  3280.   }
  3281.   Nlm_InsetRect (&r, 3, 3);
  3282.   fontlist = NULL;
  3283.   if (font != NULL) {
  3284.     fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
  3285.     if (fntptr != NULL && fntptr->handle != NULL) {
  3286.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  3287.     }
  3288.     Nlm_HandUnlock (font);
  3289.   }
  3290.   n = 0;
  3291.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  3292.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  3293.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  3294.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  3295.   XtSetArg (wargs [n], XmNmarginHeight, 3); n++;
  3296.   XtSetArg (wargs [n], XmNmarginWidth, 3); n++;
  3297.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  3298.   XtSetArg (wargs [n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  3299.   if (wrap) {
  3300.     XtSetArg (wargs [n], XmNscrollHorizontal, FALSE); n++;
  3301.     XtSetArg (wargs [n], XmNwordWrap, TRUE); n++;
  3302.   }
  3303.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  3304.   XtSetArg (wargs [n], XmNhighlightThickness, 0); n++;
  3305.   h = XmCreateScrolledText (wptr, (String) "", wargs, n);
  3306.   Nlm_LoadTextData (t, h, vsb, hsb, wrap, font, fnthgt, FALSE, FALSE, FALSE, height, NULL, NULL, NULL);
  3307.   XtAddCallback (h, XmNvalueChangedCallback, Nlm_TextCallback, (XtPointer) t);
  3308.   XtAddCallback (h, XmNfocusCallback, Nlm_FocusCallback, (XtPointer) t);
  3309.   XtAddCallback (h, XmNlosingFocusCallback, Nlm_LoseFocusCallback, (XtPointer) t);
  3310.   XtManageChild (h);
  3311.   if (NLM_QUIET) {
  3312.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
  3313.       XtRealizeWidget (h);
  3314.     }
  3315.   } else {
  3316.     XtRealizeWidget (h);
  3317.   }
  3318.   allowTextCallback = TRUE;
  3319.   if (fontlist != NULL) {
  3320.     XmFontListFree (fontlist);
  3321.   }
  3322. #endif
  3323.   Nlm_LoadAction ((Nlm_GraphiC) t, (Nlm_ActnProc) actn);
  3324. }
  3325.  
  3326.  
  3327.  
  3328.  
  3329. /*#ifdef DCLAP*/
  3330.  
  3331. extern void Nlm_SetDialogTextFont(Nlm_FonT theFont)
  3332. {
  3333.     gDialogTextFont= theFont; /* dgg -- let users choose font */
  3334. }
  3335. /*#endif*/
  3336.  
  3337. extern Nlm_TexT Nlm_DialogText (Nlm_GrouP prnt, Nlm_CharPtr dfault,
  3338.                                 Nlm_Int2 charWidth, Nlm_TxtActnProc actn)
  3339.  
  3340. {
  3341.   Nlm_Int2    cwid;
  3342.   Nlm_Int2    hbounds;
  3343.   Nlm_PoinT   npt;
  3344.   Nlm_RecT    r;
  3345.   Nlm_Int2    swid;
  3346.   Nlm_TexT    t;
  3347.   Nlm_WindoW  tempPort;
  3348.   Nlm_Int2    vbounds;
  3349.  
  3350.   t = NULL;
  3351.   if (prnt != NULL) {
  3352.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  3353.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  3354.         SelectDialogFont();
  3355. #ifdef DCLAP
  3356.     cwid = charWidth * Nlm_MaxCharWidth();
  3357. #else
  3358.     cwid = charWidth * Nlm_stdCharWidth;
  3359. #endif
  3360.     swid = Nlm_StringWidth (dfault);
  3361.     if (cwid > swid) {
  3362.       swid = cwid;
  3363.     }
  3364. #ifdef WIN_MAC
  3365.     hbounds = 2;
  3366.     vbounds = 2;
  3367. #endif
  3368. #ifdef WIN_MSWIN
  3369.     hbounds = 3;
  3370. #ifdef DCLAP
  3371.     vbounds = (Nlm_FontHeight() * 3 / 2 - gDlogTextHeight) / 2;
  3372. #else
  3373.     vbounds = (Nlm_stdFontHeight * 3 / 2 - gDlogTextHeight) / 2;
  3374. #endif
  3375. #endif
  3376. #ifdef WIN_MOTIF
  3377.     hbounds = 8;
  3378.     vbounds = 8;
  3379. #endif
  3380.     r.left = npt.x;
  3381.     r.top = npt.y;
  3382.     r.right = r.left + swid + 2 + hbounds * 2;
  3383.     r.bottom = r.top + gDlogTextHeight + vbounds * 2;
  3384.     t = (Nlm_TexT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r,
  3385.                                    sizeof (Nlm_TextRec), dialogTextProcs);
  3386.     if (t != NULL) {
  3387.       Nlm_NewDialogText (t, dfault, actn);
  3388. #ifdef WIN_MAC
  3389.       Nlm_DoSelect ((Nlm_GraphiC) t, FALSE);
  3390. #endif
  3391.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) t, &r, TRUE, FALSE);
  3392.       Nlm_DoShow ((Nlm_GraphiC) t, TRUE, FALSE);
  3393.     }
  3394.     Nlm_RestorePort (tempPort);
  3395.   }
  3396.   return t;
  3397. }
  3398.  
  3399. extern Nlm_TexT Nlm_HiddenText (Nlm_GrouP prnt, Nlm_CharPtr dfault,
  3400.                                 Nlm_Int2 charWidth, Nlm_TxtActnProc actn,
  3401.                                 Nlm_TxtActnProc tabProc)
  3402.  
  3403. {
  3404.   Nlm_Int2    cwid;
  3405.   Nlm_Int2    hbounds;
  3406.   Nlm_PoinT   npt;
  3407.   Nlm_RecT    r;
  3408.   Nlm_Int2    swid;
  3409.   Nlm_TexT    t;
  3410.   Nlm_WindoW  tempPort;
  3411.   Nlm_Int2    vbounds;
  3412.  
  3413.   t = NULL;
  3414.   if (prnt != NULL) {
  3415.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  3416.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  3417.         SelectDialogFont();
  3418. #ifdef DCLAP
  3419.     cwid = charWidth * Nlm_MaxCharWidth();
  3420. #else
  3421.     cwid = charWidth * Nlm_stdCharWidth;
  3422. #endif
  3423.     swid = Nlm_StringWidth (dfault);
  3424.     if (cwid > swid) {
  3425.       swid = cwid;
  3426.     }
  3427. #ifdef WIN_MAC
  3428.     hbounds = 0;
  3429.     vbounds = 0;
  3430. #endif
  3431. #ifdef WIN_MSWIN
  3432.     hbounds = 0;
  3433.     vbounds = 0;
  3434. #endif
  3435. #ifdef WIN_MOTIF
  3436.     hbounds = 0;
  3437.     vbounds = 0;
  3438. #endif
  3439.     r.left = npt.x;
  3440.     r.top = npt.y;
  3441.     r.right = r.left + swid + 2 + hbounds * 2;
  3442.     r.bottom = r.top + gDlogTextHeight + vbounds * 2;
  3443.     t = (Nlm_TexT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r,
  3444.                                    sizeof (Nlm_TextRec), hiddenTextProcs);
  3445.     if (t != NULL) {
  3446.       Nlm_NewHiddenText (t, dfault, actn, tabProc);
  3447. #ifdef WIN_MAC
  3448.       Nlm_DoSelect ((Nlm_GraphiC) t, FALSE);
  3449. #endif
  3450.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) t, &r, TRUE, FALSE);
  3451.       Nlm_DoShow ((Nlm_GraphiC) t, TRUE, FALSE);
  3452.     }
  3453.     Nlm_RestorePort (tempPort);
  3454.   }
  3455.   return t;
  3456. }
  3457.  
  3458. extern Nlm_TexT Nlm_PasswordText (Nlm_GrouP prnt, Nlm_CharPtr dfault,
  3459.                                   Nlm_Int2 charWidth, Nlm_TxtActnProc actn)
  3460.  
  3461. {
  3462.   Nlm_Int2    cwid;
  3463.   Nlm_Int2    hbounds;
  3464.   Nlm_PoinT   npt;
  3465.   Nlm_RecT    r;
  3466.   Nlm_Int2    swid;
  3467.   Nlm_TexT    t;
  3468.   Nlm_WindoW  tempPort;
  3469.   Nlm_Int2    vbounds;
  3470.  
  3471.   t = NULL;
  3472.   if (prnt != NULL) {
  3473.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  3474.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  3475.         SelectDialogFont();
  3476. #ifdef DCLAP
  3477.     cwid = charWidth * Nlm_MaxCharWidth();
  3478. #else
  3479.     cwid = charWidth * Nlm_stdCharWidth;
  3480. #endif
  3481.     swid = Nlm_StringWidth (dfault);
  3482.     if (cwid > swid) {
  3483.       swid = cwid;
  3484.     }
  3485. #ifdef WIN_MAC
  3486.     hbounds = 2;
  3487.     vbounds = 2;
  3488. #endif
  3489. #ifdef WIN_MSWIN
  3490.     hbounds = 3;
  3491.     vbounds = (Nlm_stdFontHeight * 3 / 2 - gDlogTextHeight) / 2;
  3492. #endif
  3493. #ifdef WIN_MOTIF
  3494.     hbounds = 8;
  3495.     vbounds = 8;
  3496. #endif
  3497.     r.left = npt.x;
  3498.     r.top = npt.y;
  3499.     r.right = r.left + swid + 2 + hbounds * 2;
  3500.     r.bottom = r.top + gDlogTextHeight + vbounds * 2;
  3501.     t = (Nlm_TexT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r,
  3502.                                    sizeof (Nlm_PasswdRec), passwordTextProcs);
  3503.     if (t != NULL) {
  3504.       Nlm_NewPasswordText (t, dfault, actn);
  3505. #ifdef WIN_MAC
  3506.       Nlm_DoSelect ((Nlm_GraphiC) t, FALSE);
  3507. #endif
  3508.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) t, &r, TRUE, FALSE);
  3509.       Nlm_DoShow ((Nlm_GraphiC) t, TRUE, FALSE);
  3510.     }
  3511.     Nlm_RestorePort (tempPort);
  3512.   }
  3513.   return t;
  3514. }
  3515.  
  3516. extern Nlm_TexT Nlm_ScrollText (Nlm_GrouP prnt, Nlm_Int2 width,
  3517.                                 Nlm_Int2 height, Nlm_FonT font,
  3518.                                 Nlm_Boolean wrap, Nlm_TxtActnProc actn)
  3519.  
  3520. {
  3521.   Nlm_Int2    dwid;
  3522.   Nlm_Int2    fnthgt;
  3523.   Nlm_PoinT   npt;
  3524.   Nlm_RecT    r;
  3525.   Nlm_TexT    t;
  3526.   Nlm_WindoW  tempPort;
  3527.   Nlm_Int2    thgt;
  3528.  
  3529.   t = NULL;
  3530.   if (prnt != NULL) {
  3531.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  3532.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  3533.     if (font == NULL) {
  3534.       font = Nlm_programFont;
  3535.     }
  3536.     Nlm_SelectFont (font);
  3537.     fnthgt = Nlm_LineHeight ();
  3538. #ifdef DCLAP
  3539.     dwid = width * Nlm_MaxCharWidth();
  3540.     thgt = height * fnthgt;
  3541. #else
  3542.     dwid = width * Nlm_stdCharWidth;
  3543.     thgt = height * Nlm_stdLineHeight;
  3544. #endif
  3545.     Nlm_LoadRect (&r, npt.x, npt.y, npt.x+dwid+8, npt.y+thgt+4);
  3546.     t = (Nlm_TexT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r, sizeof (Nlm_TextRec), scrollTextProcs);
  3547.     if (t != NULL) {
  3548.       Nlm_NewScrollText (t, height, font, fnthgt, wrap, actn);
  3549.       r.right += Nlm_vScrollBarWidth;
  3550.       if (! wrap) {
  3551.         r.bottom += Nlm_hScrollBarHeight;
  3552.       }
  3553.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) t, &r, TRUE, FALSE);
  3554.             SelectDialogFont();
  3555.       Nlm_DoShow ((Nlm_GraphiC) t, TRUE, FALSE);
  3556.     }
  3557.     Nlm_RestorePort (tempPort);
  3558.   }
  3559.   return t;
  3560. }
  3561.  
  3562.  
  3563.  
  3564. extern void Nlm_PassPanelClickToText (Nlm_PaneL p, Nlm_TexT t, Nlm_PoinT pt)
  3565.  
  3566. {
  3567. #ifdef WIN_MSWIN
  3568.   Nlm_TextTool  h;
  3569.   UINT          message;
  3570.   WPARAM        wParam;
  3571. #endif
  3572. #ifdef WIN_MOTIF
  3573.   Nlm_TextTool  h;
  3574. #endif
  3575.  
  3576.   if (t != NULL) {
  3577.     Nlm_KillSlateTimer ();
  3578. #ifdef WIN_MAC
  3579.     Nlm_DoClick ((Nlm_GraphiC) t, pt);
  3580. #endif
  3581. #ifdef WIN_MSWIN
  3582.     ReleaseCapture ();
  3583.     h = Nlm_GetTextHandle (t);
  3584.     if (Nlm_dblClick) {
  3585.       message = WM_LBUTTONDBLCLK;
  3586.     } else {
  3587.       message = WM_LBUTTONDOWN;
  3588.     }
  3589.     if (Nlm_shftKey) {
  3590.       wParam = MK_SHIFT;
  3591.     } else {
  3592.       wParam = 0;
  3593.     }
  3594. /*
  3595.     Edit_SetSel (h, 0, 0);
  3596.     if (Nlm_Visible (t) && Nlm_AllParentsVisible (t)) {
  3597.       SetFocus (h);
  3598.       Nlm_DoTextSelect (t);
  3599.     }
  3600. */
  3601.     SendMessage (h, message, Nlm_currentWParam, Nlm_currentLParam);
  3602. #endif
  3603. #ifdef WIN_MOTIF
  3604.   if (Nlm_WindowHasBeenShown (Nlm_ParentWindow ((Nlm_Handle) t))) {
  3605.     allowTextCallback = FALSE;
  3606.     h = Nlm_GetTextHandle (t);
  3607.     XmTextSetSelection (h, (XmTextPosition) 0,
  3608.                         (XmTextPosition) 0, (Time) 0);
  3609.     XmProcessTraversal (h, XmTRAVERSE_CURRENT);
  3610.     XmTextSetHighlight (h, (XmTextPosition) 0,
  3611.                         (XmTextPosition) 0, XmHIGHLIGHT_SELECTED);
  3612.     allowTextCallback = TRUE;
  3613.   }
  3614.   Nlm_DoTextSelect (t);
  3615. #endif
  3616.   }
  3617. }
  3618.  
  3619. #ifdef WIN_MAC
  3620. extern Nlm_Boolean Nlm_RegisterTexts (void)
  3621.  
  3622. {
  3623.   return TRUE;
  3624. }
  3625. #endif
  3626.  
  3627. #ifdef WIN_MSWIN
  3628. extern Nlm_Boolean Nlm_RegisterTexts (void)
  3629.  
  3630. {
  3631.   return TRUE;
  3632. }
  3633. #endif
  3634.  
  3635. #ifdef WIN_MOTIF
  3636. extern Nlm_Boolean Nlm_RegisterTexts (void)
  3637.  
  3638. {
  3639.   XtActionsRec  actions;
  3640.  
  3641.   actions.string = "do_tab";
  3642.   actions.proc = Nlm_TabCallback;
  3643.   XtAppAddActions (Nlm_appContext, &actions, 1);
  3644.   return TRUE;
  3645. }
  3646. #endif
  3647.  
  3648. extern void Nlm_FreeTexts (void)
  3649.  
  3650. {
  3651.   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemFree (gphprcsptr);
  3652. }
  3653.  
  3654. extern void Nlm_InitTexts (void)
  3655.  
  3656. {
  3657.   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemNew (sizeof (Nlm_GphPrcs) * 4);
  3658.  
  3659.   dialogTextProcs = &(gphprcsptr [0]);
  3660. #ifdef WIN_MAC
  3661.   dialogTextProcs->click = Nlm_DialogTextClick;
  3662.   dialogTextProcs->key = Nlm_DialogKey;
  3663.   dialogTextProcs->draw = Nlm_DrawDialogText;
  3664.   dialogTextProcs->idle = Nlm_IdleText;
  3665. #endif
  3666. #ifdef WIN_MSWIN
  3667.   dialogTextProcs->command = Nlm_DialogTextCommand;
  3668. #endif
  3669. #ifdef WIN_MOTIF
  3670. #endif
  3671.   dialogTextProcs->show = Nlm_ShowText;
  3672.   dialogTextProcs->hide = Nlm_HideText;
  3673.   dialogTextProcs->enable = Nlm_EnableText;
  3674.   dialogTextProcs->disable = Nlm_DisableText;
  3675.   dialogTextProcs->activate = Nlm_ActivateText;
  3676.   dialogTextProcs->deactivate = Nlm_DeactivateText;
  3677.   dialogTextProcs->remove = Nlm_RemoveText;
  3678.   dialogTextProcs->reset = Nlm_ResetText;
  3679.   dialogTextProcs->select = Nlm_TextSelectProc;
  3680.   dialogTextProcs->setTitle = Nlm_SetDialogText;
  3681.   dialogTextProcs->getTitle = Nlm_GetDialogText;
  3682.   dialogTextProcs->setPosition = Nlm_SetTextPosition;
  3683.   dialogTextProcs->getPosition = Nlm_GetTextPosition;
  3684.   dialogTextProcs->gainFocus = Nlm_TextGainFocus;
  3685.   dialogTextProcs->loseFocus = Nlm_TextLoseFocus;
  3686.  
  3687.   hiddenTextProcs = &(gphprcsptr [1]);
  3688. #ifdef WIN_MAC
  3689.   hiddenTextProcs->click = Nlm_DialogTextClick;
  3690.   hiddenTextProcs->key = Nlm_DialogKey;
  3691.   hiddenTextProcs->draw = Nlm_DrawHiddenText;
  3692.   hiddenTextProcs->idle = Nlm_IdleText;
  3693. #endif
  3694. #ifdef WIN_MSWIN
  3695.   hiddenTextProcs->command = Nlm_DialogTextCommand;
  3696. #endif
  3697. #ifdef WIN_MOTIF
  3698. #endif
  3699.   hiddenTextProcs->show = Nlm_ShowText;
  3700.   hiddenTextProcs->hide = Nlm_HideText;
  3701.   hiddenTextProcs->enable = Nlm_EnableText;
  3702.   hiddenTextProcs->disable = Nlm_DisableText;
  3703.   hiddenTextProcs->activate = Nlm_ActivateHiddenText;
  3704.   hiddenTextProcs->deactivate = Nlm_DeactivateText;
  3705.   hiddenTextProcs->remove = Nlm_RemoveText;
  3706.   hiddenTextProcs->reset = Nlm_ResetText;
  3707.   hiddenTextProcs->select = Nlm_TextSelectProc;
  3708.   hiddenTextProcs->setTitle = Nlm_SetDialogText;
  3709.   hiddenTextProcs->getTitle = Nlm_GetDialogText;
  3710.   hiddenTextProcs->setPosition = Nlm_SetHiddenTextPosition;
  3711.   hiddenTextProcs->getPosition = Nlm_GetTextPosition;
  3712.   hiddenTextProcs->gainFocus = Nlm_TextGainFocus;
  3713.   hiddenTextProcs->loseFocus = Nlm_TextLoseFocus;
  3714.  
  3715.   passwordTextProcs = &(gphprcsptr [2]);
  3716. #ifdef WIN_MAC
  3717.   passwordTextProcs->click = Nlm_DialogTextClick;
  3718.   passwordTextProcs->key = Nlm_PasswordKey;
  3719.   passwordTextProcs->draw = Nlm_DrawDialogText;
  3720.   passwordTextProcs->idle = Nlm_IdleText;
  3721. #endif
  3722. #ifdef WIN_MSWIN
  3723.   passwordTextProcs->command = Nlm_PasswordTextCommand;
  3724. #endif
  3725. #ifdef WIN_MOTIF
  3726. #endif
  3727.   passwordTextProcs->show = Nlm_ShowText;
  3728.   passwordTextProcs->hide = Nlm_HideText;
  3729.   passwordTextProcs->enable = Nlm_EnableText;
  3730.   passwordTextProcs->disable = Nlm_DisableText;
  3731.   passwordTextProcs->activate = Nlm_ActivateText;
  3732.   passwordTextProcs->deactivate = Nlm_DeactivateText;
  3733.   passwordTextProcs->remove = Nlm_RemoveText;
  3734.   passwordTextProcs->reset = Nlm_ResetText;
  3735.   passwordTextProcs->select = Nlm_TextSelectProc;
  3736.   passwordTextProcs->setTitle = Nlm_SetPasswordText;
  3737.   passwordTextProcs->getTitle = Nlm_GetPasswordText;
  3738.   passwordTextProcs->setPosition = Nlm_SetTextPosition;
  3739.   passwordTextProcs->getPosition = Nlm_GetTextPosition;
  3740.   passwordTextProcs->gainFocus = Nlm_TextGainFocus;
  3741.   passwordTextProcs->loseFocus = Nlm_TextLoseFocus;
  3742.  
  3743.   scrollTextProcs = &(gphprcsptr [3]);
  3744. #ifdef WIN_MAC
  3745.   scrollTextProcs->click = Nlm_ScrollTextClick;
  3746.   scrollTextProcs->key = Nlm_TextKey;
  3747.   scrollTextProcs->draw = Nlm_DrawScrollText;
  3748.   scrollTextProcs->idle = Nlm_IdleText;
  3749. #endif
  3750. #ifdef WIN_MSWIN
  3751.   scrollTextProcs->command = Nlm_ScrollTextCommand;
  3752. #endif
  3753. #ifdef WIN_MOTIF
  3754. #endif
  3755.   scrollTextProcs->show = Nlm_ShowScrollText;
  3756.   scrollTextProcs->hide = Nlm_HideScrollText;
  3757.   scrollTextProcs->enable = Nlm_EnableText;
  3758.   scrollTextProcs->disable = Nlm_DisableText;
  3759.   scrollTextProcs->activate = Nlm_ActivateScrollText;
  3760.   scrollTextProcs->deactivate = Nlm_DeactivateScrollText;
  3761.   scrollTextProcs->remove = Nlm_RemoveText;
  3762.   scrollTextProcs->reset = Nlm_ResetText;
  3763.   scrollTextProcs->select = Nlm_TextSelectProc;
  3764.   scrollTextProcs->setTitle = Nlm_SetScrollText;
  3765.   scrollTextProcs->getTitle = Nlm_GetScrollText;
  3766.   scrollTextProcs->setPosition = Nlm_SetScrollTextPosition;
  3767.   scrollTextProcs->getPosition = Nlm_GetScrollTextPosition;
  3768.   scrollTextProcs->loseFocus = Nlm_TextLoseFocus;
  3769. }
  3770.