~ubuntu-branches/ubuntu/jaunty/ncbi-tools6/jaunty

« back to all changes in this revision

Viewing changes to vibrant/vibtexts.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-07-14 19:43:15 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080714194315-ed44u9ek7txva2rz
Tags: 6.1.20080302-3
tools/readdb.c: enable madvise()-based code on all glibc (hence all
Debian) systems, not just Linux.  (Closes: #490437.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   7/1/91
31
31
*
32
 
* $Revision: 6.33 $
 
32
* $Revision: 6.36 $
33
33
*
34
34
* File Description: 
35
35
*       Vibrant edit text functions
36
36
*
37
37
* Modifications:  
38
38
* --------------------------------------------------------------------------
39
 
* $Log: vibtexts.c,v $
40
 
* Revision 6.33  2006/09/27 18:30:00  kans
41
 
* support for Int4 scroll bars for switching between text and doc views in Sequin (CB)
42
 
*
43
 
* Revision 6.32  2006/09/14 19:18:29  ivanov
44
 
* Rollback last changes. All missed defines added to corelib/ncbiwin.h.
45
 
*
46
 
* Revision 6.31  2006/09/14 18:05:45  ivanov
47
 
* Fixed compilation errors on MS Windows
48
 
*
49
 
* Revision 6.30  2006/09/14 14:45:39  kans
50
 
* changes for 64-bit Windows (GC) plus a few CodeWarrior complaints (JK)
51
 
*
52
 
* Revision 6.29  2005/07/18 15:15:18  kans
53
 
* fixed minor xcode compiler warnings
54
 
*
55
 
* Revision 6.28  2004/07/19 13:36:43  bollin
56
 
* replaced obsolete XmFontListCreate function to get rid of run-time warnings
57
 
*
58
 
* Revision 6.27  2004/06/24 15:34:48  bollin
59
 
* added lines from Yoon Choi to make ctrl-A select all text in TextMode in
60
 
* Sequin
61
 
*
62
 
* Revision 6.26  2004/03/17 16:09:14  sinyakov
63
 
* WIN_MSWIN: fixed text box activation and text selection logic,
64
 
* do not reset currentText when text window loses focus (to match Motif version),
65
 
* removed scroll text size limit,
66
 
* in Nlm_SelectAText(): scroll selection into view for scroll text,
67
 
* in Nlm_TextGainFocus(), when focus changes to a single-line edit box,
68
 
* do not highlight all text, instead just set the cursor pos to beginning,
69
 
* in MyCls_OnChar(), multiline edit boxes accept tabs
70
 
* as input characters and not as focus change commands.
71
 
*
72
 
* Revision 6.25  2004/02/23 16:36:52  sinyakov
73
 
* Use Int4 instead of Int2 for cursor position and text selection in text boxes
74
 
*
75
 
* Revision 6.24  2004/02/17 16:01:15  bollin
76
 
* implemented Nlm_SetScrollTextOffset for Motif
77
 
*
78
 
* Revision 6.23  2004/02/12 20:29:09  kans
79
 
* put ifdef WIN_MOTIF wrapper around Nlm_KeepCrNlTextFieldCallback
80
 
*
81
 
* Revision 6.22  2004/02/12 20:05:10  bazhin
82
 
* Added callback function "Nlm_SetKeepCrNlTextFieldCallback(Nlm_TexT t)",
83
 
* which allows to copy-paste texts from multiple columns to single string.
84
 
*
85
 
* Revision 6.21  2004/02/09 17:46:27  bollin
86
 
* added fix from Yoon Choi for copy-paste from Windows clipboard into Unix application
87
 
*
88
 
* Revision 6.20  2004/02/06 19:27:33  bollin
89
 
* Use PostMessage to communicate with scrolling function on TextViewer window
90
 
*
91
 
* Revision 6.19  2004/02/05 16:25:05  kans
92
 
* revert to Nlm_GetTextVScrollBar and Nlm_GetTextHScrollBar being static, implement setOffset and getOffset for scroll text, since Windows scroll text has its own scroll bar
93
 
*
94
 
* Revision 6.18  2004/02/04 15:21:03  kans
95
 
* make GetTextVScrollBar and GetTextHScrollBar extern, to add search function to general text viewer
96
 
*
97
 
* Revision 6.17  2003/11/17 17:03:30  kans
98
 
* changed C++ style comments to C comments
99
 
*
100
 
* Revision 6.16  2003/11/03 21:51:34  sinyakov
101
 
* WIN_MSWIN: bugfix: strlen(title) moved out of loop condition
102
 
*
103
 
* Revision 6.15  2003/10/29 19:10:08  bazhin
104
 
* Added function Nlm_SetTextColor(Nlm_TexT t, Nlm_Uint4 r, Nlm_Uint4 g,
105
 
*                                 Nlm_Uint4 b).
106
 
*
107
 
* Revision 6.14  2003/07/30 13:51:42  johnson
108
 
* MSWIN: multi-line text boxes now respond to 'enter' key
109
 
*
110
 
* Revision 6.13  2003/03/28 21:27:18  rsmith
111
 
* on Mac OS took out ClearCurrentScrap after Cut/Copy. It only erased whatever was copied.
112
 
*
113
 
* Revision 6.12  2003/01/07 15:08:11  shomrat
114
 
* Change condition in for loop in Nlm_SetScrollText
115
 
*
116
 
* Revision 6.11  2002/12/04 22:35:11  johnson
117
 
* WIN_MSWIN: replace UNIX '\n' with DOS "\r\n" in Nlm_SetScrollText
118
 
*
119
 
* Revision 6.10  2001/09/10 17:58:28  bazhin
120
 
* Removed odd lines from SetTextCursorBlinkRate() function.
121
 
*
122
 
* Revision 6.9  2001/09/10 17:34:10  bazhin
123
 
* Added function Nlm_SetTextCursorBlinkRate(Nlm_TexT t, Nlm_Int2 msec).
124
 
*
125
 
* Revision 6.8  2001/05/14 20:29:04  juran
126
 
* Redesign Mac clipboard support.
127
 
*
128
 
* Revision 6.7  2000/05/02 22:02:15  vakatov
129
 
* Nlm_TextCallback():  get rid of an extra condition
130
 
*
131
 
* Revision 6.6  2000/03/31 19:20:03  thiessen
132
 
* fix recursion bug
133
 
*
134
 
* Revision 6.5  2000/02/07 20:17:36  lewisg
135
 
* minor bug fixes, use gui font for win32
136
 
*
137
 
* Revision 6.4  1998/07/02 18:24:35  vakatov
138
 
* Cleaned the code & made it pass through the C++ compilation
139
 
*
140
 
* Revision 6.3  1997/12/19 18:01:45  vakatov
141
 
* [X11,MSWIN]  When pasting into a single-line text field, replace all
142
 
* non-printable characters by spaces
143
 
*
144
 
* Revision 6.2  1997/11/26 21:30:42  vakatov
145
 
* Fixed errors and warnings issued by C and C++ (GNU and Sun) compilers
146
 
*
147
 
* Revision 6.1  1997/10/18 23:30:16  kans
148
 
* implemented Nlm_GetTextCursorPos (DV)
149
 
*
150
 
* Revision 6.0  1997/08/25 18:57:44  madden
151
 
* Revision changed to 6.0
152
 
*
153
 
* Revision 5.22  1997/08/07 16:46:39  vakatov
154
 
* [WIN_MOTIF] Nlm_PasswordCallback() -- process <DEL> at the first text pos
155
 
*
156
 
* Revision 5.21  1997/08/07 13:38:32  kans
157
 
* password text does action callback on delete (Mac)
158
 
*
159
 
* Revision 5.20  1997/08/05 16:42:26  kans
160
 
* allowTextCallback not declared in Mac, so ifdefs changed in Nlm_SetTextCursorPos
161
 
*
162
 
* Revision 5.19  1997/08/04 14:15:14  vakatov
163
 
* Added Nlm_SetTextCursorPos() function
164
 
*
165
 
* Revision 5.18  1997/07/21 18:49:09  vakatov
166
 
* [WIN_MAC] SetPasswordText() -- moved "r" and "GetRect()"(sorry, missed
167
 
* that!) back to the if(Visible... scope
168
 
*
169
 
* Revision 5.17  1997/07/21 18:39:42  kans
170
 
* SetPasswordText r in Mac version at top scope
171
 
*
172
 
* Revision 5.16  1997/07/21 18:24:36  vakatov
173
 
* SetPasswordText() -- show all symbols as '*'
174
 
*
175
 
* Revision 5.15  1997/07/17 15:31:47  vakatov
176
 
* [WIN_MSWIN]  Emulate non-editable text(crack WM_CHAR event in TextProc
177
 
* as the WinSDK's Edit_SetReadOnly lead to invalidation bug for ScrollText)
178
 
*
179
 
* Revision 5.14  1997/07/16 13:47:20  kans
180
 
* non-editable scroll text now scrolls on Mac
181
 
*
182
 
* Revision 5.12  1997/07/13 23:03:05  kans
183
 
* ScrollText height is in stdLineHeight units
184
 
*
185
 
* Revision 5.11  1997/07/08 13:42:06  kans
186
 
* ttool to rtool fix in Nlm_DrawScrollText/DCLAP
187
 
*
188
 
* Revision 5.10  1997/06/24 21:30:37  kans
189
 
* implemented SetTextEditable on Mac
190
 
*
191
 
* Revision 5.9  1997/06/24 19:10:00  vakatov
192
 
* Nlm_ScrollText() -- calculate the text box limits using the systemFont
193
 
* (not the current font!) dimensions
194
 
*
195
 
* Revision 5.8  1997/06/23 21:21:05  vakatov
196
 
* Added Nlm_SetTextEditable() function to allow/prohibit text editing
197
 
* [WIN_MOTIF] Made text widgets to fit the specified number of lines
198
 
*
199
 
* Revision 5.7  1997/04/25 16:14:06  vakatov
200
 
* [WIN_MOTIF,WIN_MSWIN] Catch and render(DoSendFocus) navigation key events
201
 
* Extensive code cleaning and type casting
202
 
*
203
 
 * Revision 5.6  1997/02/12  17:47:28  vakatov
204
 
 * [WIN_MOTIF]  Do not reset selection when activating a window containing
205
 
 * a text or when the text is empty
206
 
 *
207
 
 * Revision 5.5  1997/01/29  17:53:59  kans
208
 
 * minor changes due to StringNCpy_0 change
209
 
 *
210
 
 * Revision 5.4  1997/01/29  16:41:22  kans
211
 
 * using StringNCpy_0
212
 
 *
213
 
 * Revision 5.3  1996/07/23  21:07:10  epstein
214
 
 * Vakatov/Epstein avoid trying to clear an area on an unrealized window
215
 
 *
216
 
 * Revision 5.2  1996/06/18  15:44:56  vakatov
217
 
 * Do not assign last (maxsize-1) symbol of output buffer
218
 
 * in Nlm_GetScrollText() and Nlm_GetDialogText() to '\0'.
219
 
 *
220
 
 * Revision 5.1  1996/06/17  19:28:17  vakatov
221
 
 * [WIN_MOTIF]  Positioning of scrolled text postponed until its realization
222
 
 *
223
 
 * Revision 4.9  1996/05/08  20:42:52  vakatov
224
 
 * [WIN_MOTIF]  Nlm_PasswordCallback() function -- rewritten to avoid stack
225
 
 * corruption on the case of too long(>30 symbols) user input and
226
 
 * to make the password text field more convenient to edit;
227
 
 * [ALL]  Nlm_GetPasswordLength() function added (other than
228
 
 * Nlm_TextLength());  a lot of other tiny changes and corrections
229
 
 *
230
 
 * Revision 4.8  1996/05/08  13:43:47  vakatov
231
 
 * [WIN_MOTIF]  Modified Nlm_SetPasswordText() to reset the password
232
 
 *
233
 
 * Revision 4.7  1996/05/03  17:02:08  kans
234
 
 * added a cast to SelectText call
235
 
 *
236
 
 * Revision 4.6  1996/03/02  22:36:38  kans
237
 
 * reduction of X traffic (DV)
238
 
 *
239
 
 * Revision 4.5  1996/02/13  17:24:07  kans
240
 
 * accelerated set position prior to realization (Denis Vakatov)
241
 
 *
242
 
 * Revision 4.4  1995/11/27  16:04:00  kans
243
 
 * ScrollText now handles killfocus and setfocus messages (VL)
244
 
 *
245
 
 * Revision 4.3  1995/11/27  15:13:41  kans
246
 
 * allow select and deselect callbacks for DialogText and ScrollText (VL)
247
 
 *
248
 
 * Revision 4.2  1995/11/08  23:30:31  kans
249
 
 * removed edit block fields, which belong in the application
250
 
 *
251
 
 * Revision 4.1  1995/10/10  15:51:53  kans
252
 
 * fully implemented scroll text resizing
253
 
 *
254
 
 * Revision 2.52  1995/07/14  17:48:26  kans
255
 
 * forces dialog, hidden text to use systemFont (AS)
256
 
 *
257
 
 * Revision 2.51  1995/05/20  18:27:38  kans
258
 
 * corrected accidental prevention of passing returns to other objects
259
 
 *
260
39
*
261
40
* ==========================================================================
262
41
*/
266
45
#include <vibincld.h>
267
46
 
268
47
#ifdef WIN_MAC
 
48
#ifdef WIN_MAC_QUARTZ
 
49
#define Nlm_TextTool TXNObject
 
50
extern CGRect Nlm_RecTToCGRect(Nlm_RecT r);
 
51
#else
269
52
#define Nlm_TextTool TEHandle
270
53
#endif
 
54
#endif
271
55
 
272
56
#ifdef WIN_MSWIN
273
57
#  define Nlm_TextTool HWND
567
351
{
568
352
  Nlm_TextTool  h;
569
353
  Nlm_Int2      lines;
570
 
  TEPtr         tptr;
 
354
#ifdef WIN_MAC_QUARTZ
 
355
  {
 
356
      ItemCount llines = 0;
 
357
      OSStatus stat = TXNGetLineCount(h, &llines);
 
358
      if (stat != noErr) {
 
359
          llines = 0;
 
360
      }
 
361
      lines = lines;
 
362
  }
 
363
#else
 
364
  {
 
365
      TEPtr         tptr;
571
366
 
572
 
  h = Nlm_GetTextHandle (t);
573
 
  HLock ((Handle) h);
574
 
  tptr = (TEPtr) *((Handle) h);
575
 
  lines = tptr->nLines;
576
 
  HUnlock ((Handle) h);
 
367
      h = Nlm_GetTextHandle (t);
 
368
      HLock ((Handle) h);
 
369
      tptr = (TEPtr) *((Handle) h);
 
370
      lines = tptr->nLines;
 
371
      HUnlock ((Handle) h);      
 
372
  }
 
373
#endif
577
374
  return lines;
578
375
}
579
376
 
582
379
{
583
380
  Nlm_TextTool  h;
584
381
  Nlm_Int2      height;
585
 
  TEPtr         tptr;
586
382
 
587
383
  h = Nlm_GetTextHandle (t);
588
 
  HLock ((Handle) h);
589
 
  tptr = (TEPtr) *((Handle) h);
590
 
  height = tptr->lineHeight;
591
 
  HUnlock ((Handle) h);
 
384
#ifdef WIN_MAC_QUARTZ
 
385
  {
 
386
      Fixed lineWidth, lineHeight;
 
387
      OSStatus stat = TXNGetLineMetrics(h, 0, &lineWidth, &lineHeight);
 
388
      if (stat != noErr) {
 
389
          height = 0;
 
390
      } else {
 
391
          float fHeight = FixedToFloat(lineHeight);
 
392
          height = fHeight;
 
393
      }
 
394
  }
 
395
#else
 
396
  {
 
397
      TEPtr         tptr;
 
398
      HLock ((Handle) h);
 
399
      tptr = (TEPtr) *((Handle) h);
 
400
      height = tptr->lineHeight;
 
401
      HUnlock ((Handle) h);      
 
402
  }
 
403
#endif
592
404
  return height;
593
405
}
594
406
 
 
407
#ifndef WIN_MAC_QUARTZ
595
408
static Nlm_Int2 Nlm_GetInsertionStartLine (Nlm_TexT t)
596
409
 
597
410
{
636
449
    }
637
450
  }
638
451
}
 
452
#endif
639
453
 
640
454
static void Nlm_UpdateScrollBar (Nlm_TexT t)
641
455
 
643
457
  Nlm_Int2  lines;
644
458
  Nlm_Int2  newval;
645
459
  Nlm_BaR   sb;
646
 
  Nlm_Int2  start;
647
460
  Nlm_Int2  vis;
648
461
 
649
462
  sb = Nlm_GetTextVScrollBar (t);
650
463
  if (sb != NULL) {
651
464
    lines = Nlm_GetTextLines (t);
652
 
    start = Nlm_GetInsertionStartLine (t);
653
465
    vis = Nlm_GetVisLines (t);
654
466
    newval = 0;
655
467
    if (lines > vis) {
741
553
static void Nlm_SelectAText (Nlm_TexT t, Nlm_Int4 begin, Nlm_Int4 end)
742
554
 
743
555
{
 
556
  Nlm_TextTool  h;
744
557
#ifdef WIN_MAC
745
 
  Nlm_TextTool  h;
 
558
#ifndef WIN_MAC_QUARTZ
746
559
  TEPtr         hp;
747
560
  short         len;
748
561
  Nlm_Int4      selStart;
749
562
  Nlm_Int4      selEnd;
 
563
#endif
750
564
 
751
565
  Nlm_DeactivateBoxesInList (t);
752
566
  h = Nlm_GetTextHandle (t);
 
567
#ifdef WIN_MAC_QUARTZ
 
568
  TXNSetSelection(h, begin, end);
 
569
#else
753
570
  HLock ((Handle) h);
754
571
  hp = (TEPtr) *((Handle) h);
755
572
  len = hp->teLength;
766
583
  Nlm_DoActivate ((Nlm_GraphiC) t, FALSE);
767
584
  Nlm_DoTextSelect (t);
768
585
#endif
 
586
#endif
769
587
#ifdef WIN_MSWIN
770
 
  Nlm_TextTool  h;
771
 
 
772
588
  h = Nlm_GetTextHandle (t);
773
589
  Edit_SetSel (h, begin, end);
774
590
  Edit_ScrollCaret (h);
777
593
  Nlm_DoTextSelect (t);
778
594
#endif
779
595
#ifdef WIN_MOTIF
780
 
  Nlm_TextTool    h;
781
596
  XmTextPosition  max;
782
597
 
783
598
  if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (t))) {
811
626
 
812
627
  {{
813
628
#if defined(WIN_MAC)
 
629
#if defined(WIN_MAC_QUARTZ)
 
630
    TXNGetSelection(h, (TXNOffset*) &x_begin, (TXNOffset*) &x_end);
 
631
#else    
814
632
    TEPtr hp;
815
633
 
816
634
    HLock( (Handle)h );
818
636
    x_begin = hp->selStart;
819
637
    x_end   = hp->selEnd;
820
638
    HUnlock( (Handle)h );
821
 
 
 
639
#endif
822
640
#elif defined(WIN_MSWIN)
823
641
    DWORD dwBegin, dwEnd;
824
642
    SNDMSG(h, EM_GETSEL, (WPARAM)(&dwBegin), (LPARAM)(&dwEnd));
864
682
}
865
683
 
866
684
#ifdef WIN_MAC
 
685
 
867
686
static Nlm_Boolean Nlm_DialogTextClick (Nlm_GraphiC t, Nlm_PoinT pt)
868
687
 
869
688
{
875
694
 
876
695
  rsult = FALSE;
877
696
  if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
 
697
#ifdef WIN_MAC_QUARTZ
 
698
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
699
  TXNClick(h, &Nlm_currentEvent);
 
700
#else
878
701
  Nlm_GetRect (t, &r);
879
702
  if (Nlm_PtInRect (pt, &r)) {
880
703
    Nlm_DeactivateBoxesInList ((Nlm_TexT) t);
890
713
    Nlm_DoTextSelect ((Nlm_TexT) t);
891
714
    rsult = TRUE;
892
715
  }
 
716
#endif
893
717
  return rsult;
894
718
}
895
719
 
 
720
#ifndef WIN_MAC_QUARTZ
896
721
static Nlm_Boolean Nlm_ScrollTextClick (Nlm_GraphiC t, Nlm_PoinT pt)
897
722
 
898
723
{
938
763
  }
939
764
  return rsult;
940
765
}
941
 
 
942
 
static Nlm_Boolean Nlm_TextKey (Nlm_GraphiC t, Nlm_Char ch)
943
 
 
944
 
{
945
 
  Nlm_Boolean   act;
946
 
  Nlm_TextTool  h;
947
 
  Nlm_Boolean   rsult;
948
 
 
949
 
  rsult = FALSE;
950
 
  if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
951
 
  act = Nlm_GetActive ((Nlm_TexT) t);
952
 
  if (act && ! Nlm_cmmdKey) {
953
 
    if (ch != '\0') {
954
 
      h = Nlm_GetTextHandle ((Nlm_TexT) t);
955
 
      Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
956
 
      TEKey (ch, h);
957
 
      TECalText (h);
958
 
      Nlm_UpdateScrollBar ((Nlm_TexT) t);
959
 
      Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
960
 
      Nlm_DoAction (t);
961
 
      Nlm_SetChanged ((Nlm_TexT) t, TRUE);
962
 
      rsult = TRUE;
963
 
    }
964
 
  }
965
 
  return rsult;
966
 
}
967
 
 
968
 
static Nlm_Boolean Nlm_DialogKey (Nlm_GraphiC t, Nlm_Char ch)
969
 
 
970
 
{
971
 
  Nlm_Boolean  act;
972
 
  Nlm_Boolean  rsult;
973
 
 
974
 
  rsult = FALSE;
975
 
  if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
976
 
  act = Nlm_GetActive ((Nlm_TexT) t);
977
 
  if (act && ! Nlm_cmmdKey) {
978
 
    if (ch == '\t' && Nlm_IsHiddenOrSpecialText ((Nlm_TexT) t)) {
979
 
      Nlm_DoTabCallback ((Nlm_TexT) t);
980
 
      rsult = TRUE;
981
 
    } else if (ch == '\t') {
982
 
      Nlm_DoSendFocus (t, ch);
983
 
      rsult = TRUE;
984
 
    } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
985
 
      rsult = Nlm_DoReturnCallback ((Nlm_TexT) t);
986
 
    } else if (ch != '\0') {
987
 
      rsult = Nlm_TextKey (t, ch);
988
 
    }
989
 
  }
990
 
  return rsult;
991
 
}
992
 
 
993
 
static Nlm_Boolean Nlm_PasswordKey (Nlm_GraphiC t, Nlm_Char ch)
994
 
 
995
 
{
996
 
  Nlm_Boolean   act;
997
 
  Nlm_TextTool  h;
998
 
  TEPtr         hp;
999
 
  Nlm_Int2      len;
1000
 
  Nlm_Char      password [MAX_PASSWORD];
1001
 
  Nlm_RecT      r;
1002
 
  Nlm_RectTool  rtool;
1003
 
  Nlm_Boolean   rsult;
1004
 
  Nlm_Int4      selStart;
1005
 
  Nlm_Int4      selEnd;
1006
 
 
1007
 
  rsult = FALSE;
1008
 
  if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
1009
 
  act = Nlm_GetActive ((Nlm_TexT) t);
1010
 
  if (act && ! Nlm_cmmdKey) {
1011
 
    if (ch == '\t') {
1012
 
      Nlm_DoSendFocus (t, ch);
1013
 
      rsult = TRUE;
1014
 
    } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
1015
 
    } else if (ch == '\b') {
1016
 
      rsult = TRUE;
1017
 
      Nlm_SetPassword ((Nlm_TexT) t, "");
1018
 
      h = Nlm_GetTextHandle ((Nlm_TexT) t);
1019
 
      selStart = 0;
1020
 
      HLock ((Handle) h);
1021
 
      hp = (TEPtr) *((Handle) h);
1022
 
      selEnd = hp->teLength;
1023
 
      HUnlock ((Handle) h);
1024
 
      Nlm_GetRect (t, &r);
1025
 
      if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
1026
 
        TESetSelect (selStart, selEnd, h);
1027
 
        TEDelete (h);
1028
 
        Nlm_InsetRect (&r, 2, 2);
1029
 
        Nlm_EraseRect (&r);
1030
 
        Nlm_RecTToRectTool (&r, &rtool);
1031
 
        TEUpdate (&rtool, h);
1032
 
      }
1033
 
      Nlm_DoAction (t);
1034
 
    } else if (ch != '\0') {
1035
 
      Nlm_GetPassword ((Nlm_TexT) t, password, sizeof (password));
1036
 
      len = (Nlm_Int2) Nlm_StringLen (password);
1037
 
      if (len < sizeof (password) - 2) {
1038
 
        password [len] = ch;
1039
 
        password [len + 1] = '\0';
1040
 
      }
1041
 
      Nlm_SetPassword ((Nlm_TexT) t, password);
1042
 
      rsult = Nlm_TextKey (t, '*');
1043
 
    }
1044
 
  }
1045
 
  return rsult;
1046
 
}
 
766
#endif
1047
767
 
1048
768
static void Nlm_DrawDialogText (Nlm_GraphiC t)
1049
769
 
1053
773
  Nlm_RectTool  ttool;
1054
774
 
1055
775
  if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
 
776
#ifdef WIN_MAC_QUARTZ
 
777
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
778
    TXNDrawObject(h, NULL, kTXNDrawItemAllMask );
 
779
#else
1056
780
    Nlm_GetRect (t, &r);
1057
781
    if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
1058
782
      Nlm_EraseRect (&r);
1086
810
        Nlm_Solid ();
1087
811
      }
1088
812
    }
 
813
#endif /* WIN_MAC_QUARTZ */
1089
814
  }
1090
815
}
1091
816
 
1097
822
  Nlm_RectTool  ttool;
1098
823
 
1099
824
  if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
 
825
#ifdef WIN_MAC_QUARTZ
 
826
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
827
    TXNDrawObject(h, NULL, kTXNDrawItemAllMask );
 
828
#else
1100
829
    Nlm_GetRect (t, &r);
1101
830
    if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
1102
831
      Nlm_EraseRect (&r);
1113
842
        TEUpdate (&ttool, h);
1114
843
      }
1115
844
    }
 
845
#endif
1116
846
  }
1117
847
}
1118
848
 
1127
857
  Nlm_Boolean   wrap;
1128
858
 
1129
859
  if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
 
860
#ifdef WIN_MAC_QUARTZ
 
861
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
862
    TXNDrawObject(h, NULL, kTXNDrawItemAllMask );
 
863
#else    
1130
864
    Nlm_GetRect (t, &r);
1131
865
    r.right += Nlm_vScrollBarWidth;
1132
866
    wrap = Nlm_GetTextWrap ((Nlm_TexT) t);
1176
910
        Nlm_Solid ();
1177
911
      }
1178
912
    }
 
913
#endif
1179
914
  }
1180
915
}
1181
916
 
 
917
 
 
918
static Nlm_Boolean Nlm_TextKey (Nlm_GraphiC t, Nlm_Char ch)
 
919
 
 
920
{
 
921
    Nlm_Boolean   act;
 
922
    Nlm_TextTool  h;
 
923
    Nlm_Boolean   rsult;
 
924
    
 
925
    rsult = FALSE;
 
926
    if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
 
927
    act = Nlm_GetActive ((Nlm_TexT) t);
 
928
    if (act && ! Nlm_cmmdKey) {
 
929
        if (ch != '\0') {
 
930
            h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
931
#ifdef WIN_MAC_QUARTZ
 
932
            TXNKeyDown(h, &Nlm_currentEvent );
 
933
#else
 
934
            Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
 
935
            TEKey (ch, h);
 
936
            TECalText (h);
 
937
            Nlm_UpdateScrollBar ((Nlm_TexT) t);
 
938
            Nlm_ScrollToInsertionPoint ((Nlm_TexT) t);
 
939
#endif
 
940
            Nlm_DoAction (t);
 
941
            Nlm_SetChanged ((Nlm_TexT) t, TRUE);
 
942
            rsult = TRUE;
 
943
        }
 
944
    }
 
945
    return rsult;
 
946
}
 
947
 
 
948
static Nlm_Boolean Nlm_DialogKey (Nlm_GraphiC t, Nlm_Char ch)
 
949
 
 
950
{
 
951
    Nlm_Boolean  rsult;
 
952
    Nlm_Boolean  act;
 
953
    
 
954
    rsult = FALSE;
 
955
    if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
 
956
    act = Nlm_GetActive ((Nlm_TexT) t);
 
957
    if (act && ! Nlm_cmmdKey) {
 
958
        if (ch == '\t' && Nlm_IsHiddenOrSpecialText ((Nlm_TexT) t)) {
 
959
            Nlm_DoTabCallback ((Nlm_TexT) t);
 
960
            rsult = TRUE;
 
961
        } else if (ch == '\t') {
 
962
            Nlm_DoSendFocus (t, ch);
 
963
            rsult = TRUE;
 
964
        } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
 
965
            rsult = Nlm_DoReturnCallback ((Nlm_TexT) t);
 
966
        } else if (ch != '\0') {
 
967
            rsult = Nlm_TextKey (t, ch);
 
968
        }
 
969
    }
 
970
    return rsult;
 
971
}
 
972
 
 
973
#ifndef WIN_MAC_QUARTZ
 
974
static Nlm_Boolean Nlm_PasswordKey (Nlm_GraphiC t, Nlm_Char ch)
 
975
 
 
976
{
 
977
    Nlm_Boolean   act;
 
978
    Nlm_TextTool  h;
 
979
    TEPtr         hp;
 
980
    Nlm_Int2      len;
 
981
    Nlm_Char      password [MAX_PASSWORD];
 
982
    Nlm_RecT      r;
 
983
    Nlm_RectTool  rtool;
 
984
    Nlm_Boolean   rsult;
 
985
    Nlm_Int4      selStart;
 
986
    Nlm_Int4      selEnd;
 
987
    
 
988
    rsult = FALSE;
 
989
    if (! Nlm_GetTextEditable ((Nlm_TexT) t)) return FALSE;
 
990
    act = Nlm_GetActive ((Nlm_TexT) t);
 
991
    if (act && ! Nlm_cmmdKey) {
 
992
        if (ch == '\t') {
 
993
            Nlm_DoSendFocus (t, ch);
 
994
            rsult = TRUE;
 
995
        } else if (ch == '\n'  || ch == '\r' || ch == '\3') {
 
996
        } else if (ch == '\b') {
 
997
            rsult = TRUE;
 
998
            Nlm_SetPassword ((Nlm_TexT) t, "");
 
999
            h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
1000
            selStart = 0;
 
1001
            HLock ((Handle) h);
 
1002
            hp = (TEPtr) *((Handle) h);
 
1003
            selEnd = hp->teLength;
 
1004
            HUnlock ((Handle) h);
 
1005
            Nlm_GetRect (t, &r);
 
1006
            if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
 
1007
                TESetSelect (selStart, selEnd, h);
 
1008
                TEDelete (h);
 
1009
                Nlm_InsetRect (&r, 2, 2);
 
1010
                Nlm_EraseRect (&r);
 
1011
                Nlm_RecTToRectTool (&r, &rtool);
 
1012
                TEUpdate (&rtool, h);
 
1013
            }
 
1014
            Nlm_DoAction (t);
 
1015
        } else if (ch != '\0') {
 
1016
            Nlm_GetPassword ((Nlm_TexT) t, password, sizeof (password));
 
1017
            len = (Nlm_Int2) Nlm_StringLen (password);
 
1018
            if (len < sizeof (password) - 2) {
 
1019
                password [len] = ch;
 
1020
                password [len + 1] = '\0';
 
1021
            }
 
1022
            Nlm_SetPassword ((Nlm_TexT) t, password);
 
1023
            rsult = Nlm_TextKey (t, '*');
 
1024
        }
 
1025
    }
 
1026
    return rsult;
 
1027
}
 
1028
#endif /* ! WIN_MAC_QUARTZ */
 
1029
 
1182
1030
static Nlm_Boolean Nlm_IdleText (Nlm_GraphiC t, Nlm_PoinT pt)
1183
1031
 
1184
1032
{  Nlm_TextTool  h;
1185
1033
 
1186
1034
  if (Nlm_GetVisible (t) && Nlm_GetEnabled (t) && Nlm_GetActive ((Nlm_TexT) t)) {
1187
1035
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
1036
#ifdef WIN_MAC_QUARTZ
 
1037
    TXNIdle(h);
 
1038
#else
1188
1039
    TEIdle (h);
 
1040
#endif
1189
1041
  }
1190
1042
  return TRUE;
1191
1043
}
1374
1226
  Nlm_RestorePort (tempPort);
1375
1227
}
1376
1228
 
 
1229
#ifndef WIN_MAC_QUARTZ
1377
1230
static void Nlm_EnableText (Nlm_GraphiC t, Nlm_Boolean setFlag, Nlm_Boolean savePort)
1378
1231
 
1379
1232
{
1444
1297
  Nlm_RestorePort (tempPort);
1445
1298
}
1446
1299
 
 
1300
 
1447
1301
static void Nlm_ActivateText (Nlm_GraphiC t, Nlm_Boolean savePort)
1448
1302
 
1449
1303
{
1591
1445
  }
1592
1446
#endif
1593
1447
}
 
1448
#endif /* ! WIN_MAC_QUARTZ */
1594
1449
 
1595
1450
static void Nlm_ResetText (Nlm_GraphiC t, Nlm_Boolean savePort)
1596
1451
 
1605
1460
 
1606
1461
  tempPort = Nlm_SavePortIfNeeded (t, savePort);
1607
1462
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
1463
#ifdef WIN_MAC_QUARTZ
 
1464
  TXNSetSelection(h, kTXNStartOffset, kTXNEndOffset);
 
1465
  TXNClear(h);
 
1466
#else
1608
1467
  TESetSelect (0, 32767, h);
1609
1468
  TEDelete (h);
1610
1469
  sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
1621
1480
    TEScroll (delta * width, 0, h);
1622
1481
    Nlm_DoReset ((Nlm_GraphiC) sb, FALSE);
1623
1482
  }
 
1483
#endif
1624
1484
  Nlm_RestorePort (tempPort);
1625
1485
#endif
1626
1486
#ifdef WIN_MSWIN
1656
1516
  }
1657
1517
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
1658
1518
#ifdef WIN_MAC
 
1519
#ifdef WIN_MAC_QUARTZ
 
1520
  TXNDeleteObject(h);
 
1521
#else
1659
1522
  TEDispose (h);
1660
1523
  sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
1661
1524
  if (sb != NULL) {
1666
1529
    Nlm_DoRemove ((Nlm_GraphiC) sb, FALSE);
1667
1530
  }
1668
1531
#endif
 
1532
#endif
1669
1533
#ifdef WIN_MSWIN
1670
1534
  RemoveProp (h, (LPSTR) "Nlm_VibrantProp");
1671
1535
  DestroyWindow (h);
1684
1548
#ifdef WIN_MAC
1685
1549
  Nlm_Int2      end;
1686
1550
  Nlm_TextTool  h;
 
1551
  Nlm_WindoW    tempPort;
 
1552
#ifndef WIN_MAC_QUARTZ
1687
1553
  TEPtr         hp;
1688
 
  Nlm_WindoW    tempPort;
 
1554
#endif
1689
1555
 
1690
1556
  if (t != NULL) {
1691
1557
    tempPort = Nlm_SavePortIfNeeded (t, savePort);
1692
1558
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
1559
#ifdef WIN_MAC_QUARTZ
 
1560
    TXNSelectAll(h);
 
1561
#else
1693
1562
    HLock ((Handle) h);
1694
1563
    hp = (TEPtr) *((Handle) h);
1695
1564
    end = hp->teLength;
1696
1565
    HUnlock ((Handle) h);
1697
1566
    Nlm_SelectAText ((Nlm_TexT) t, 0, end);
 
1567
#endif
1698
1568
    Nlm_RestorePort (tempPort);
1699
1569
  }
1700
1570
#endif
1727
1597
{
1728
1598
  Nlm_TextTool  h;
1729
1599
  size_t        len;
1730
 
#ifdef WIN_MAC
 
1600
#if defined(WIN_MAC) && ! defined(WIN_MAC_QUARTZ)
1731
1601
  TEPtr         hp;
1732
1602
#endif
1733
1603
#ifdef WIN_MOTIF
1738
1608
  if (t != NULL) {
1739
1609
    h = Nlm_GetTextHandle (t);
1740
1610
#ifdef WIN_MAC
 
1611
#ifdef WIN_MAC_QUARTZ
 
1612
    len = TXNDataSize(h);
 
1613
#else
1741
1614
    HLock ((Handle) h);
1742
1615
    hp = (TEPtr) *((Handle) h);
1743
1616
    len = hp->teLength;
1744
1617
    HUnlock ((Handle) h);
1745
1618
#endif
 
1619
#endif
1746
1620
#ifdef WIN_MSWIN
1747
1621
    len = (size_t) GetWindowTextLength (h);
1748
1622
#endif
1793
1667
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
1794
1668
#ifdef WIN_MAC
1795
1669
  len = Nlm_StringLen (title);
 
1670
#ifdef WIN_MAC_QUARTZ
 
1671
  TXNSetData(h, kTXNTextData, title, len, kTXNStartOffset, kTXNEndOffset);
 
1672
#else
1796
1673
  TESetText (title, len, h);
1797
1674
  TECalText (h);
1798
1675
  Nlm_GetRect (t, &r);
1802
1679
  }
1803
1680
  Nlm_UpdateScrollBar ((Nlm_TexT) t);
1804
1681
#endif
 
1682
#endif
1805
1683
#ifdef WIN_MSWIN
1806
1684
  allowTextCallback = FALSE;
1807
1685
  SetWindowText (h, title);
1835
1713
  Nlm_MemSet(actual_title, '*', len);
1836
1714
 
1837
1715
#ifdef WIN_MAC
 
1716
#ifdef WIN_MAC_QUARTZ
 
1717
  TXNSetData(h, kTXNTextData, title, len, kTXNStartOffset, kTXNEndOffset);
 
1718
#else
1838
1719
  TESetText (actual_title, len, h);
1839
1720
  TECalText (h);
1840
1721
  if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
1845
1726
  }
1846
1727
  Nlm_UpdateScrollBar ((Nlm_TexT) t);
1847
1728
#endif
 
1729
#endif
1848
1730
#ifdef WIN_MSWIN
1849
1731
  allowTextCallback = FALSE;
1850
1732
  SetWindowText (h, actual_title);
1874
1756
  Nlm_RecT      r;
1875
1757
#endif
1876
1758
#ifdef WIN_MSWIN
1877
 
  Nlm_Uint4     count;
 
1759
  Nlm_Uint4    count;
1878
1760
  Nlm_Uint4     len;
1879
 
  Nlm_CharPtr   tmp, newTitle;
 
1761
  Nlm_CharPtr    tmp, newTitle;
1880
1762
#endif
1881
1763
 
1882
1764
  tempPort = Nlm_SavePortIfNeeded (t, savePort);
1883
1765
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
1884
1766
#ifdef WIN_MAC
1885
1767
  len = Nlm_StringLen (title);
 
1768
#ifdef WIN_MAC_QUARTZ
 
1769
  TXNSetData(h, kTXNTextData, title, len, kTXNStartOffset, kTXNEndOffset);
 
1770
#else
1886
1771
  TESetText (title, len, h);
1887
1772
  TECalText (h);
1888
1773
  Nlm_GetRect (t, &r);
1894
1779
  }
1895
1780
  Nlm_UpdateScrollBar ((Nlm_TexT) t);
1896
1781
#endif
 
1782
#endif
1897
1783
#ifdef WIN_MSWIN
1898
1784
  allowTextCallback = FALSE;
1899
1785
  
1902
1788
  count = 0;
1903
1789
  for (tmp = title; tmp != NULL && *tmp; ++tmp) {
1904
1790
      if (*tmp == '\n')
1905
 
          ++count;
 
1791
      ++count;
1906
1792
  }
1907
1793
 
1908
1794
  if (count == 0)
1912
1798
    newTitle = (Nlm_CharPtr) MemNew(len+count+1);
1913
1799
    tmp = newTitle;
1914
1800
    for (count=0; count < len; ++count) {
1915
 
        if (title[count] == '\n' && (count == 0 || title[count-1] != '\r'))
1916
 
            *tmp++ = '\r';
1917
 
        *tmp++ = title[count];
 
1801
    if (title[count] == '\n' && (count == 0 || title[count-1] != '\r'))
 
1802
        *tmp++ = '\r';
 
1803
    *tmp++ = title[count];
1918
1804
    }
1919
1805
    *tmp = '\0';
1920
1806
    SetWindowText (h, newTitle);
1943
1829
  Nlm_TextTool  h;
1944
1830
#ifdef WIN_MAC
1945
1831
  Nlm_Char      **chars;
1946
 
  TEPtr         hp;
1947
1832
  Nlm_Int2      i;
1948
1833
  Nlm_Int2      length;
1949
1834
  Nlm_Char      *ptr;
 
1835
#ifndef WIN_MAC_QUARTZ
 
1836
  TEPtr         hp;
 
1837
#endif
1950
1838
#endif
1951
1839
#ifdef WIN_MOTIF
1952
1840
  Nlm_CharPtr   ptr;
1956
1844
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
1957
1845
#ifdef WIN_MAC
1958
1846
    i = 0;
 
1847
#ifdef WIN_MAC_QUARTZ
 
1848
    TXNGetDataEncoded(h, kTXNStartOffset, kTXNEndOffset, &chars, kTXNTextData);
 
1849
    length = Nlm_StrLen(*chars);
 
1850
#else
1959
1851
    HLock ((Handle) h);
1960
1852
    hp = (TEPtr) *((Handle) h);
1961
1853
    chars = hp->hText;
1962
1854
    length = hp->teLength;
 
1855
    HUnlock ((Handle) h);
 
1856
#endif
1963
1857
    if (length > maxsize - 1) {
1964
1858
      length = maxsize - 1;
1965
1859
    }
1966
 
    HUnlock ((Handle) h);
1967
1860
    if (chars != NULL) {
1968
1861
      HLock ((Handle) chars);
1969
1862
      ptr = (Nlm_Char *) *((Handle) chars);
1998
1891
  Nlm_TextTool  h;
1999
1892
#ifdef WIN_MAC
2000
1893
  Nlm_Char      **chars;
2001
 
  TEPtr         hp;
2002
1894
  Nlm_Int2      i;
2003
1895
  Nlm_Int2      length;
2004
1896
  Nlm_Char      *ptr;
 
1897
#ifndef WIN_MAC_QUARTZ
 
1898
  TEPtr         hp;
 
1899
#endif
2005
1900
#endif
2006
1901
#ifdef WIN_MOTIF
2007
1902
  Nlm_CharPtr   ptr;
2011
1906
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
2012
1907
#ifdef WIN_MAC
2013
1908
    i = 0;
 
1909
#ifdef WIN_MAC_QUARTZ
 
1910
    TXNGetDataEncoded(h, kTXNStartOffset, kTXNEndOffset, &chars, kTXNTextData);
 
1911
    length = Nlm_StrLen(*chars);
 
1912
#else
2014
1913
    HLock ((Handle) h);
2015
1914
    hp = (TEPtr) *((Handle) h);
2016
1915
    chars = hp->hText;
2017
1916
    length = hp->teLength;
 
1917
    HUnlock ((Handle) h);
 
1918
#endif
2018
1919
    if (length > maxsize - 1) {
2019
1920
      length = maxsize - 1;
2020
1921
    }
2047
1948
 
2048
1949
#ifdef WIN_MAC
2049
1950
 
 
1951
#ifndef WIN_MAC_QUARTZ
2050
1952
static void Clipboard_TEToDeskScrap()
2051
1953
{
2052
 
        OSErr err;
2053
 
        /* Copy the TE scrap to the desk scrap. */
2054
 
        err = TEToScrap();
2055
 
}
2056
 
 
2057
 
static void Clipboard_TECut(TEHandle inTE)
2058
 
{
2059
 
        /* Cut the text into the TE scrap. */
2060
 
        TECut(inTE);
2061
 
        /* Update the desk scrap. */
2062
 
        Clipboard_TEToDeskScrap();
2063
 
}
2064
 
 
2065
 
static void Clipboard_TECopy(TEHandle inTE)
2066
 
{
2067
 
        /* Copy the text into the TE scrap. */
2068
 
        TECopy(inTE);
2069
 
        /* Update the desk scrap. */
2070
 
        Clipboard_TEToDeskScrap();
2071
 
}
2072
 
 
2073
 
static void Clipboard_TEPaste(TEHandle inTE)
2074
 
{
2075
 
    /* #if TARGET_API_MAC_CARBON */
2076
 
        /* ScrapRef scrap; */
2077
 
        /* OSStatus status = GetCurrentScrap(&scrap); */
2078
 
        TEFromScrap();
2079
 
        TEPaste(inTE);
 
1954
  OSErr err;
 
1955
  /* Copy the TE scrap to the desk scrap. */
 
1956
  err = TEToScrap();
 
1957
}
 
1958
#endif
 
1959
 
 
1960
static void Clipboard_TECut(Nlm_TextTool inTE)
 
1961
{
 
1962
#ifdef WIN_MAC_QUARTZ
 
1963
  TXNCut(inTE);
 
1964
#else
 
1965
  /* Cut the text into the TE scrap. */
 
1966
  TECut(inTE);
 
1967
  /* Update the desk scrap. */
 
1968
  Clipboard_TEToDeskScrap();
 
1969
#endif
 
1970
}
 
1971
 
 
1972
static void Clipboard_TECopy(Nlm_TextTool inTE)
 
1973
{
 
1974
#ifdef WIN_MAC_QUARTZ
 
1975
  TXNCopy(inTE);
 
1976
#else
 
1977
  /* Copy the text into the TE scrap. */
 
1978
  TECopy(inTE);
 
1979
  /* Update the desk scrap. */
 
1980
  Clipboard_TEToDeskScrap();
 
1981
#endif
 
1982
}
 
1983
 
 
1984
static void Clipboard_TEPaste(Nlm_TextTool inTE)
 
1985
{
 
1986
#ifdef WIN_MAC_QUARTZ
 
1987
  if (TXNIsScrapPastable()) {
 
1988
    TXNPaste(inTE);    
 
1989
  }
 
1990
#else
 
1991
  TEFromScrap();
 
1992
  TEPaste(inTE);
 
1993
#endif
2080
1994
}
2081
1995
 
2082
1996
#endif  /* WIN_MAC */
2164
2078
    if (! Nlm_GetTextEditable (t)) return;
2165
2079
    h = Nlm_GetTextHandle (t);
2166
2080
#ifdef WIN_MAC
 
2081
#ifdef WIN_MAC_QUARTZ
 
2082
    TXNClear(h);
 
2083
#else
2167
2084
    TEDelete (h);
2168
2085
#endif
 
2086
#endif
2169
2087
#ifdef WIN_MSWIN
2170
2088
    allowTextCallback = FALSE;
2171
2089
    SendMessage (h, WM_CLEAR, 0, 0);
2251
2169
    Nlm_DoReturnCallback (t);
2252
2170
  } else if ((ch == '\n' || ch == '\r') && iseditable) {
2253
2171
    if (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_MULTILINE) {
2254
 
        /* multiline edit box */
2255
 
        if (Nlm_ctrlKey)
2256
 
            /* Ctrl-Enter goes to dialog box buttons */
2257
 
            Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
2258
 
        else
2259
 
            /* plain Enter goes as character to the edit field */
2260
 
            handlechar = TRUE;
 
2172
    /* multiline edit box */
 
2173
    if (Nlm_ctrlKey)
 
2174
        /* Ctrl-Enter goes to dialog box buttons */
 
2175
            Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
 
2176
    else
 
2177
        /* plain Enter goes as character to the edit field */
 
2178
        handlechar = TRUE;
2261
2179
    }
2262
2180
    else
2263
 
        Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
 
2181
    Nlm_DoSendFocus ((Nlm_GraphiC) t, (Nlm_Char) ch);
2264
2182
  } else if (!iseditable && ch == '\3') { /* pass Ctrl-C ("Copy") to default handler */
2265
2183
    handlechar = TRUE;
2266
2184
  } else if (iseditable) {
2325
2243
    case WM_KEYDOWN:
2326
2244
      if(!Nlm_GetTextEditable(t) && Nlm_KeydownToChar( wParam ) == NLM_DEL)
2327
2245
      {
2328
 
          call_win_proc = FALSE;
2329
 
          break;
 
2246
      call_win_proc = FALSE;
 
2247
      break;
2330
2248
      }
2331
2249
      call_win_proc = !(Nlm_GetVisLines(t) == 1  &&
2332
2250
                        Nlm_ProcessKeydown((Nlm_GraphiC)t,
2345
2263
    case WM_PASTE:
2346
2264
      if ( !Nlm_GetTextEditable(t) )
2347
2265
      {
2348
 
          call_win_proc = FALSE;
2349
 
          break;
 
2266
      call_win_proc = FALSE;
 
2267
      break;
2350
2268
      }
2351
2269
      if ( !(GetWindowLongPtr(hwnd, GWL_STYLE) & ES_MULTILINE) ) {
2352
2270
        LPSTR text = NULL, str;
2364
2282
          break;  /* no suitable data found in the clipboard */
2365
2283
 
2366
2284
        for (str = text;  *str;  str++)
2367
 
          if ( !isprint(*str) ) {
 
2285
          if ( !isprint((unsigned char)*str) ) {
2368
2286
            *str = ' ';
2369
2287
            call_win_proc = FALSE;
2370
2288
          }
2390
2308
{
2391
2309
#ifdef WIN_MAC
2392
2310
  Nlm_TextTool  h;
2393
 
  TEPtr         hp;
2394
2311
  Nlm_Int2      len;
2395
2312
  Nlm_GraphiC   rsult;
2396
2313
 
2397
2314
  rsult = NULL;
2398
2315
  if (ch == '\t' && Nlm_GetVisible (t) && Nlm_GetEnabled (t)) {
2399
2316
    h = Nlm_GetTextHandle ((Nlm_TexT) t);
2400
 
    HLock ((Handle) h);
2401
 
    hp = (TEPtr) *((Handle) h);
2402
 
    len = hp->teLength;
2403
 
    HUnlock ((Handle) h);
2404
2317
    Nlm_SetActive ((Nlm_TexT) t, TRUE);
2405
 
    Nlm_SelectAText ((Nlm_TexT) t, 0, len);
 
2318
    Nlm_TextSelectProc(t, savePort);
2406
2319
    rsult = t;
2407
2320
  }
2408
2321
  return rsult;
2415
2328
    Nlm_TextTool h = Nlm_GetTextHandle ((Nlm_TexT) t);
2416
2329
    Nlm_SetActive ((Nlm_TexT) t, TRUE);
2417
2330
    if (GetWindowLongPtr(h, GWL_STYLE) & ES_MULTILINE) {
2418
 
        /* multiline edit box */
2419
 
        Nlm_Int4 begin = 0, end = 0;
2420
 
        Nlm_TextSelectionRange((Nlm_TexT) t, &begin, &end);
2421
 
        Nlm_SelectAText ((Nlm_TexT) t, begin, end);
 
2331
    /* multiline edit box */
 
2332
    Nlm_Int4 begin = 0, end = 0;
 
2333
    Nlm_TextSelectionRange((Nlm_TexT) t, &begin, &end);
 
2334
    Nlm_SelectAText ((Nlm_TexT) t, begin, end);
2422
2335
    } else {
2423
2336
        /* singleline edit box - make it consistent with MOTIF by setting len = 0 
2424
2337
           which just sets the cursor pos to the beginning and does not highlight 
2425
2338
           the text
2426
2339
        */
2427
2340
        size_t len = 0;  /* Nlm_TextLength ((Nlm_TexT) t); */
2428
 
        Nlm_SelectAText ((Nlm_TexT) t, 0, len);
 
2341
    Nlm_SelectAText ((Nlm_TexT) t, 0, len);
2429
2342
    }
2430
2343
    rsult = t;
2431
2344
  }
2449
2362
static void Nlm_TextLoseFocus (Nlm_GraphiC t, Nlm_GraphiC excpt, Nlm_Boolean savePort)
2450
2363
 
2451
2364
{
 
2365
#ifndef WIN_MAC_QUARTZ
2452
2366
  Nlm_WindoW  tempPort;
2453
2367
 
2454
2368
  if (t != excpt) {
2460
2374
    Nlm_DeactivateText (t, FALSE);
2461
2375
    Nlm_RestorePort (tempPort);
2462
2376
  }
 
2377
#endif
2463
2378
}
2464
2379
 
2465
2380
#ifdef WIN_MAC
2494
2409
 
2495
2410
 
2496
2411
static void Nlm_SetTextPosition (Nlm_GraphiC t, Nlm_RectPtr r,
2497
 
                                 Nlm_Boolean savePort, Nlm_Boolean force)
 
2412
                                 Nlm_Boolean savePort, Nlm_Boolean force)
2498
2413
{
2499
2414
  Nlm_TextTool  h;
2500
2415
  Nlm_RecT      oldRect;
2501
2416
  Nlm_WindoW    tempPort;
2502
2417
  Nlm_RecT      tr;
2503
2418
#ifdef WIN_MAC
 
2419
#ifndef WIN_MAC_QUARTZ
2504
2420
  TEPtr         hp;
 
2421
#endif
2505
2422
  Nlm_RectTool  rtool;
2506
2423
#endif
2507
2424
 
2523
2440
#endif
2524
2441
  tr = *r;
2525
2442
#ifdef WIN_MAC
 
2443
#ifdef WIN_MAC_QUARTZ
 
2444
  Nlm_RecTToRectTool (&tr, &rtool);
 
2445
  TXNSetFrameBounds(h, rtool.top, rtool.left, rtool.bottom, rtool.right, 0);
 
2446
#else
2526
2447
  Nlm_InsetRect (&tr, 2, 2);
2527
2448
  Nlm_RecTToRectTool (&tr, &rtool);
2528
2449
  HLock ((Handle) h);
2533
2454
  Nlm_SetRect (t, r);
2534
2455
  Nlm_InvalText (t);
2535
2456
#endif
 
2457
#endif
2536
2458
#ifdef WIN_MSWIN
2537
2459
  MoveWindow (h, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, TRUE);
2538
2460
  Nlm_SetRect (t, r);
2541
2463
#ifdef WIN_MOTIF
2542
2464
  allowTextCallback = FALSE;
2543
2465
  XtVaSetValues (h,
2544
 
                 XmNx, (Position) (tr.left + 1),
2545
 
                 XmNy, (Position) (tr.top  + 1),
2546
 
                 XmNwidth,  (Dimension) (tr.right - tr.left),
2547
 
                 XmNheight, (Dimension) (tr.bottom - tr.top), 
2548
 
                 NULL);
 
2466
       XmNx, (Position) (tr.left + 1),
 
2467
       XmNy, (Position) (tr.top  + 1),
 
2468
       XmNwidth,  (Dimension) (tr.right - tr.left),
 
2469
       XmNheight, (Dimension) (tr.bottom - tr.top), 
 
2470
       NULL);
2549
2471
  Nlm_SetRect (t, r);
2550
2472
  allowTextCallback = TRUE;
2551
2473
#endif
2555
2477
 
2556
2478
 
2557
2479
static void Nlm_SetHiddenTextPosition (Nlm_GraphiC t, Nlm_RectPtr r,
2558
 
                                       Nlm_Boolean savePort, Nlm_Boolean force)
 
2480
                    Nlm_Boolean savePort, Nlm_Boolean force)
2559
2481
{
2560
2482
  Nlm_TextTool  h;
2561
2483
  Nlm_RecT      oldRect;
2562
2484
  Nlm_WindoW    tempPort;
2563
2485
  Nlm_RecT      tr;
2564
2486
#ifdef WIN_MAC
 
2487
#ifndef WIN_MAC_QUARTZ
2565
2488
  TEPtr         hp;
 
2489
#endif
2566
2490
  Nlm_RectTool  rtool;
2567
2491
#endif
2568
2492
 
2585
2509
  tr = *r;
2586
2510
#ifdef WIN_MAC
2587
2511
  Nlm_RecTToRectTool (&tr, &rtool);
 
2512
#ifdef WIN_MAC_QUARTZ
 
2513
  CGRect viewCG = Nlm_RectQDToCG (rtool);
 
2514
  CGRect destCG = Nlm_RectQDToCG (rtool);
 
2515
  TXNSetHIRectBounds (h, &viewCG, &destCG, 1);
 
2516
#else
2588
2517
  HLock ((Handle) h);
2589
2518
  hp = (TEPtr) *((Handle) h);
2590
2519
  hp->destRect = rtool;
2591
2520
  hp->viewRect = rtool;
2592
2521
  HUnlock ((Handle) h);
 
2522
#endif
2593
2523
  Nlm_SetRect (t, r);
2594
2524
  Nlm_InvalText (t);
2595
2525
#endif
2601
2531
#ifdef WIN_MOTIF
2602
2532
  allowTextCallback = FALSE;
2603
2533
  XtVaSetValues (h,
2604
 
                 XmNx, (Position) tr.left + 1,
2605
 
                 XmNy, (Position) tr.top  + 1,
2606
 
                 XmNwidth,  (Dimension) (tr.right - tr.left),
2607
 
                 XmNheight, (Dimension) (tr.bottom - tr.top), 
2608
 
                 NULL);
 
2534
         XmNx, (Position) tr.left + 1,
 
2535
         XmNy, (Position) tr.top  + 1,
 
2536
         XmNwidth,  (Dimension) (tr.right - tr.left),
 
2537
         XmNheight, (Dimension) (tr.bottom - tr.top), 
 
2538
         NULL);
2609
2539
  Nlm_SetRect (t, r);
2610
2540
  allowTextCallback = TRUE;
2611
2541
#endif
2632
2562
}
2633
2563
 
2634
2564
 
2635
 
extern void Nlm_SetScrollTextOffset4 (Nlm_GraphiC t, Nlm_Int4 horiz,
2636
 
                                     Nlm_Int4 vert, Nlm_Boolean savePort)
2637
 
 
2638
 
{
2639
 
#ifdef WIN_MAC
2640
 
  Nlm_BaR  sb;
2641
 
 
2642
 
  sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
2643
 
  if (sb != NULL) {
2644
 
    Nlm_DoSetValue ((Nlm_GraphiC) sb, vert, savePort);
2645
 
  }
2646
 
#endif
2647
 
#ifdef WIN_MSWIN
2648
 
  Nlm_TextTool  h;
2649
 
 
2650
 
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
2651
 
  PostMessage (h, WM_VSCROLL, MAKEWPARAM (SB_THUMBPOSITION, vert), 0L);
2652
 
  SetScrollPos (h, SB_VERT, vert, TRUE);
2653
 
 
2654
 
#endif
2655
 
#ifdef WIN_MOTIF
2656
 
  Nlm_Int4 value, slider_size, increment, page_increment;
2657
 
  Nlm_TextTool  h;
2658
 
  Widget        scrolled_window;
2659
 
  Widget        vscroll;
2660
 
 
2661
 
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
2662
 
  value = 0;
2663
 
  slider_size = 0;
2664
 
  increment = 0;
2665
 
  page_increment = 0;
2666
 
  vscroll = NULL;
2667
 
 
2668
 
  scrolled_window = XtParent (h);
2669
 
  if (scrolled_window == NULL) return;
2670
 
 
2671
 
  XtVaGetValues (scrolled_window, XmNverticalScrollBar, &vscroll, NULL);
2672
 
  if (vscroll == NULL) return;
2673
 
 
2674
 
  XmScrollBarGetValues (vscroll, &value, &slider_size, &increment, &page_increment);
2675
 
  XmScrollBarSetValues (vscroll, vert, slider_size, increment, page_increment, TRUE);
2676
 
 
2677
 
#endif
2678
 
}
2679
 
 
2680
2565
static void Nlm_SetScrollTextOffset (Nlm_GraphiC t, Nlm_Int2 horiz,
2681
2566
                                     Nlm_Int2 vert, Nlm_Boolean savePort)
2682
2567
 
2722
2607
#endif
2723
2608
}
2724
2609
 
 
2610
extern void Nlm_SetScrollTextOffset4 (Nlm_GraphiC t, Nlm_Int4 horiz,
 
2611
                                      Nlm_Int4 vert, Nlm_Boolean savePort)
 
2612
 
 
2613
{
 
2614
#ifdef WIN_MAC
 
2615
  Nlm_BaR  sb;
 
2616
  
 
2617
  sb = Nlm_GetTextVScrollBar ((Nlm_TexT) t);
 
2618
  if (sb != NULL) {
 
2619
    Nlm_DoSetValue ((Nlm_GraphiC) sb, vert, savePort);
 
2620
  }
 
2621
#endif
 
2622
#ifdef WIN_MSWIN
 
2623
  Nlm_TextTool  h;
 
2624
  
 
2625
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
2626
  PostMessage (h, WM_VSCROLL, MAKEWPARAM (SB_THUMBPOSITION, vert), 0L);
 
2627
  SetScrollPos (h, SB_VERT, vert, TRUE);
 
2628
  
 
2629
#endif
 
2630
#ifdef WIN_MOTIF
 
2631
  Nlm_Int4 value, slider_size, increment, page_increment;
 
2632
  Nlm_TextTool  h;
 
2633
  Widget        scrolled_window;
 
2634
  Widget        vscroll;
 
2635
  
 
2636
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
 
2637
  value = 0;
 
2638
  slider_size = 0;
 
2639
  increment = 0;
 
2640
  page_increment = 0;
 
2641
  vscroll = NULL;
 
2642
  
 
2643
  scrolled_window = XtParent (h);
 
2644
  if (scrolled_window == NULL) return;
 
2645
  
 
2646
  XtVaGetValues (scrolled_window, XmNverticalScrollBar, &vscroll, NULL);
 
2647
  if (vscroll == NULL) return;
 
2648
  
 
2649
  XmScrollBarGetValues (vscroll, &value, &slider_size, &increment, &page_increment);
 
2650
  XmScrollBarSetValues (vscroll, vert, slider_size, increment, page_increment, TRUE);
 
2651
  
 
2652
#endif
 
2653
}
 
2654
 
2725
2655
static void Nlm_GetScrollTextOffset (Nlm_GraphiC t, Nlm_Int2Ptr horiz, Nlm_Int2Ptr vert)
2726
2656
 
2727
2657
{
2823
2753
}
2824
2754
 
2825
2755
static void Nlm_SetScrollTextPosition (Nlm_GraphiC t, Nlm_RectPtr r,
2826
 
                                       Nlm_Boolean savePort, Nlm_Boolean force)
 
2756
                Nlm_Boolean savePort, Nlm_Boolean force)
2827
2757
{
2828
2758
  Nlm_TextTool  h;
2829
2759
  Nlm_RecT      oldRect;
2834
2764
  Nlm_Int2      deltax;
2835
2765
  Nlm_Int2      deltay;
2836
2766
  Nlm_RectTool  dtool;
 
2767
#ifndef WIN_MAC_QUARTZ
2837
2768
  TEPtr         hp;
 
2769
#endif
2838
2770
  Nlm_RectTool  rtool;
2839
2771
  Nlm_BaR       sb;
 
2772
  Rect          textViewRect;
 
2773
  Rect          textDestRect;
2840
2774
#endif
2841
2775
  Nlm_Boolean   is_realized;
2842
2776
 
2859
2793
#endif
2860
2794
#ifdef WIN_MSWIN
2861
2795
      MoveWindow (h,  tr.left,  tr.top,
2862
 
                  tr.right - tr.left,  tr.bottom - tr.top,  TRUE);
 
2796
          tr.right - tr.left,  tr.bottom - tr.top,  TRUE);
2863
2797
#endif
2864
2798
#ifdef WIN_MOTIF
2865
2799
      allowTextCallback = FALSE;
2866
2800
      XtVaSetValues (XtParent (h),
2867
 
                     XmNx, (Position) tr.left,
2868
 
                     XmNy, (Position) tr.top,
2869
 
                     XmNwidth,  (Dimension)(tr.right - tr.left),
2870
 
                     XmNheight, (Dimension)(tr.bottom - tr.top),
2871
 
                     NULL);
 
2801
             XmNx, (Position) tr.left,
 
2802
             XmNy, (Position) tr.top,
 
2803
             XmNwidth,  (Dimension)(tr.right - tr.left),
 
2804
             XmNheight, (Dimension)(tr.bottom - tr.top),
 
2805
             NULL);
2872
2806
#endif
2873
2807
    }
2874
2808
 
2883
2817
      Nlm_ResetVisLines ((Nlm_TexT) t);
2884
2818
      Nlm_InsetRect (&tr, 4, 2);
2885
2819
      tr.bottom = tr.top + Nlm_GetVisLines ((Nlm_TexT) t) * Nlm_GetFontHeight ((Nlm_TexT) t);
 
2820
#ifdef WIN_MAC_QUARTZ
 
2821
      TXNGetViewRect (h, &textViewRect);
 
2822
      CGRect cgr;
 
2823
      TXNGetHIRect (h, kTXNDestinationRectKey, &cgr);
 
2824
      textDestRect = Nlm_RectCGToQD (cgr);
 
2825
#else
2886
2826
      HLock ((Handle) h);
2887
2827
      hp = (TEPtr) *((Handle) h);
2888
 
      deltax = hp->destRect.left - hp->viewRect.left;
2889
 
      deltay = hp->destRect.top - hp->viewRect.top;
 
2828
      textViewRect = hp->viewRect;
 
2829
      textDestRect = hp->destRect;
 
2830
#endif
 
2831
      deltax = textDestRect.left - textViewRect.left;
 
2832
      deltay = textDestRect.top - textViewRect.top;
2890
2833
      Nlm_RecTToRectTool (&tr, &rtool);
2891
2834
      Nlm_OffsetRect (&tr, deltax, deltay);
2892
2835
      Nlm_RecTToRectTool (&tr, &dtool);
2893
2836
      if (! wrap) {
2894
 
        dtool.right += HSCROLL_POSITIONS * Nlm_stdCharWidth;
 
2837
    dtool.right += HSCROLL_POSITIONS * Nlm_stdCharWidth;
2895
2838
      }
 
2839
#ifdef WIN_MAC_QUARTZ
 
2840
      CGRect viewCG = Nlm_RectQDToCG (textViewRect);
 
2841
      CGRect destCG = Nlm_RectQDToCG (textDestRect);
 
2842
      TXNSetHIRectBounds (h, &viewCG, &destCG, 1);
 
2843
#else
2896
2844
      hp->destRect = dtool;
2897
2845
      hp->viewRect = rtool;
2898
2846
      HUnlock ((Handle) h);
 
2847
#endif
2899
2848
      Nlm_InvalScrollText (t);
2900
2849
    }
2901
2850
 
2963
2912
  Nlm_RecT      r;
2964
2913
 
2965
2914
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
2966
 
  height = Nlm_GetLineHeight ((Nlm_TexT) t);
2967
2915
  delta = oldval - newval;
2968
2916
  if (oldval != newval) {
2969
2917
    Nlm_SelectFont (Nlm_systemFont);
 
2918
#ifdef WIN_MAC_QUARTZ
 
2919
    {
 
2920
      SInt32 vdelta = delta, hdelta = 0;
 
2921
      TXNScroll(h, kTXNScrollUnitsInLines, kTXNScrollUnitsInLines,
 
2922
              &vdelta, &hdelta);
 
2923
    }
 
2924
#else
 
2925
    height = Nlm_GetLineHeight ((Nlm_TexT) t);
2970
2926
    TEScroll (0, delta * height, h);
 
2927
#endif
2971
2928
  } else if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
2972
2929
    Nlm_GetRect (t, &r);
2973
2930
    Nlm_InsetRect (&r, 2, 1);
2986
2943
  Nlm_RecT      r;
2987
2944
 
2988
2945
  h = Nlm_GetTextHandle ((Nlm_TexT) t);
2989
 
  width = Nlm_stdCharWidth;
2990
2946
  delta = oldval - newval;
2991
2947
  if (oldval != newval) {
2992
2948
    Nlm_SelectFont (Nlm_systemFont);
 
2949
#ifdef WIN_MAC_QUARTZ
 
2950
    {
 
2951
      SInt32 vdelta = 0, hdelta = delta;
 
2952
      TXNScroll(h, kTXNScrollUnitsInLines, kTXNScrollUnitsInLines,
 
2953
                &vdelta, &hdelta);
 
2954
    }
 
2955
#else
 
2956
    width = Nlm_stdCharWidth;
2993
2957
    TEScroll (delta * width, 0, h);
 
2958
#endif
2994
2959
  } else if (Nlm_GetVisible (t) && Nlm_GetAllParentsVisible (t)) {
2995
2960
    Nlm_GetRect (t, &r);
2996
2961
    Nlm_InsetRect (&r, 2, 1);
3186
3151
  Nlm_WindowTool  wptr;
3187
3152
#ifdef WIN_MAC
3188
3153
  Nlm_RectTool    rtool;
 
3154
#ifdef WIN_MAC_QUARTZ
 
3155
  CGRect          cgr;
 
3156
#endif
3189
3157
#endif
3190
3158
#ifdef WIN_MSWIN
3191
3159
  Nlm_Uint4       style;
3207
3175
#ifdef WIN_MAC
3208
3176
  Nlm_InsetRect (&r, 2, 2);
3209
3177
  Nlm_RecTToRectTool (&r, &rtool);
 
3178
#ifdef WIN_MAC_QUARTZ
 
3179
  cgr = Nlm_RecTToCGRect(r);
 
3180
  TXNCreateObject( &cgr, kTXNSingleLineOnlyMask, &h);
 
3181
  TXNAttachObjectToWindowRef(h, wptr);
 
3182
#else
3210
3183
  h = TENew (&rtool, &rtool);
 
3184
#endif
3211
3185
  Nlm_LoadTextData (t, h, NULL, NULL, FALSE, NULL, 0, FALSE,
3212
3186
                    FALSE, FALSE, FALSE, 1, NULL, NULL, NULL, NULL, TRUE);
3213
3187
  Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
 
3188
#ifndef WIN_MAC_QUARTZ
3214
3189
  if (h != NULL) {
3215
3190
    TEAutoView (TRUE, h);
3216
3191
  }
3217
3192
#endif
 
3193
#endif
3218
3194
 
3219
3195
#ifdef WIN_MSWIN
3220
3196
  allowTextCallback = FALSE;
3294
3270
  Nlm_WindowTool  wptr;
3295
3271
#ifdef WIN_MAC
3296
3272
  Nlm_RectTool    rtool;
 
3273
#ifdef WIN_MAC_QUARTZ
 
3274
  CGRect          cgr;
 
3275
#endif
3297
3276
#endif
3298
3277
#ifdef WIN_MSWIN
3299
3278
  Nlm_Uint4       style;
3314
3293
#ifdef WIN_MAC
3315
3294
  Nlm_InsetRect (&r, 2, 2);
3316
3295
  Nlm_RecTToRectTool (&r, &rtool);
 
3296
#ifdef WIN_MAC_QUARTZ
 
3297
  cgr = Nlm_RecTToCGRect(r);
 
3298
  TXNCreateObject( &cgr, kTXNSingleLineOnlyMask, &h);
 
3299
  TXNAttachObjectToWindowRef(h, wptr);
 
3300
#else
3317
3301
  h = TENew (&rtool, &rtool);
 
3302
#endif
3318
3303
  Nlm_LoadTextData (t, h, NULL, NULL, FALSE, NULL, 0, FALSE,
3319
3304
                    FALSE, FALSE, FALSE, 1, NULL, NULL, NULL, NULL, TRUE);
3320
3305
  Nlm_SetPasswordText ((Nlm_GraphiC) t, 0, local, FALSE);
3396
3381
  Nlm_WindowTool  wptr;
3397
3382
#ifdef WIN_MAC
3398
3383
  Nlm_RectTool    rtool;
 
3384
#ifdef WIN_MAC_QUARTZ
 
3385
  CGRect          cgr;
 
3386
#endif
3399
3387
#endif
3400
3388
#ifdef WIN_MSWIN
3401
3389
  Nlm_Uint4       style;
3416
3404
 
3417
3405
#ifdef WIN_MAC
3418
3406
  Nlm_RecTToRectTool (&r, &rtool);
 
3407
#ifdef WIN_MAC_QUARTZ
 
3408
  cgr = Nlm_RecTToCGRect(r);
 
3409
  TXNCreateObject( &cgr, kTXNSingleLineOnlyMask, &h);
 
3410
  TXNAttachObjectToWindowRef(h, wptr);
 
3411
#else
3419
3412
  h = TENew (&rtool, &rtool);
 
3413
#endif
3420
3414
  Nlm_LoadTextData (t, h, NULL, NULL, FALSE, NULL, 0, FALSE,
3421
3415
                    FALSE, TRUE, FALSE, 1, NULL, NULL, tabProc, rtnProc, TRUE);
3422
3416
  Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
 
3417
#ifndef WIN_MAC_QUARTZ
3423
3418
  if (h != NULL) {
3424
3419
    TEAutoView (TRUE, h);
3425
3420
  }
3426
3421
#endif
 
3422
#endif
3427
3423
 
3428
3424
#ifdef WIN_MSWIN
3429
3425
  style = WS_CHILD | ES_MULTILINE | ES_AUTOVSCROLL | ES_LEFT;
3505
3501
  Nlm_WindowTool  wptr;
3506
3502
#ifdef WIN_MAC
3507
3503
  Nlm_RectTool    rtool;
 
3504
#ifdef WIN_MAC_QUARTZ
 
3505
  CGRect          cgr;
 
3506
#endif
3508
3507
#endif
3509
3508
#ifdef WIN_MSWIN
3510
3509
  Nlm_Uint4       style;
3529
3528
#ifdef WIN_MAC
3530
3529
  Nlm_InsetRect (&r, 2, 2);
3531
3530
  Nlm_RecTToRectTool (&r, &rtool);
 
3531
#ifdef WIN_MAC_QUARTZ
 
3532
  cgr = Nlm_RecTToCGRect(r);
 
3533
  TXNCreateObject( &cgr, kTXNSingleLineOnlyMask, &h);
 
3534
  TXNAttachObjectToWindowRef(h, wptr);
 
3535
#else
3532
3536
  h = TENew (&rtool, &rtool);
 
3537
#endif
3533
3538
  Nlm_LoadTextData (t, h, NULL, NULL, FALSE, NULL, 0, FALSE,
3534
3539
                    FALSE, FALSE, TRUE, 1, NULL, NULL, tabProc, rtnProc, TRUE);
3535
3540
  Nlm_SetDialogText ((Nlm_GraphiC) t, 0, local, FALSE);
 
3541
#ifndef WIN_MAC_QUARTZ
3536
3542
  if (h != NULL) {
3537
3543
    TEAutoView (TRUE, h);
3538
3544
  }
3539
3545
#endif
 
3546
#endif
3540
3547
 
3541
3548
#ifdef WIN_MSWIN
3542
3549
  allowTextCallback = FALSE;
3624
3631
  Nlm_RectTool    dtool;
3625
3632
  Nlm_RectTool    rtool;
3626
3633
  Nlm_Int2        width;
 
3634
#ifdef WIN_MAC_QUARTZ
 
3635
  CGRect          cgr;
 
3636
#endif
3627
3637
#endif
3628
3638
#ifdef WIN_MSWIN
3629
3639
  Nlm_FntPtr      fntptr;
3669
3679
    r.right += HSCROLL_POSITIONS * Nlm_stdCharWidth;
3670
3680
  }
3671
3681
  Nlm_RecTToRectTool (&r, &dtool);
3672
 
  h = TENew (&dtool, &rtool);
 
3682
#ifdef WIN_MAC_QUARTZ
 
3683
  cgr = Nlm_RecTToCGRect(r);
 
3684
  TXNCreateObject( &cgr, 0, &h);
 
3685
  TXNAttachObjectToWindowRef(h, wptr);
 
3686
#else
 
3687
  h = TENew (&rtool, &rtool);
 
3688
#endif
3673
3689
  Nlm_LoadTextData (t, h, vsb, hsb, wrap, font, fnthgt, FALSE,
3674
3690
                    FALSE, FALSE, FALSE, height, NULL, NULL, NULL, NULL, TRUE);
3675
3691
#endif
4186
4202
 
4187
4203
  dialogTextProcs = &(gphprcsptr [0]);
4188
4204
#ifdef WIN_MAC
 
4205
#ifndef WIN_MAC_QUARTZ
 
4206
#endif
4189
4207
  dialogTextProcs->click = Nlm_DialogTextClick;
 
4208
  dialogTextProcs->draw = Nlm_DrawDialogText;
4190
4209
  dialogTextProcs->key = Nlm_DialogKey;
4191
 
  dialogTextProcs->draw = Nlm_DrawDialogText;
4192
4210
  dialogTextProcs->idle = Nlm_IdleText;
4193
4211
#endif
4194
4212
#ifdef WIN_MSWIN
4198
4216
#endif
4199
4217
  dialogTextProcs->show = Nlm_ShowText;
4200
4218
  dialogTextProcs->hide = Nlm_HideText;
 
4219
#ifndef WIN_MAC_QUARTZ
4201
4220
  dialogTextProcs->enable = Nlm_EnableText;
4202
4221
  dialogTextProcs->disable = Nlm_DisableText;
4203
4222
  dialogTextProcs->activate = Nlm_ActivateText;
4204
4223
  dialogTextProcs->deactivate = Nlm_DeactivateText;
 
4224
#endif
4205
4225
  dialogTextProcs->remove = Nlm_RemoveText;
4206
4226
  dialogTextProcs->reset = Nlm_ResetText;
4207
4227
  dialogTextProcs->select = Nlm_TextSelectProc;
4214
4234
 
4215
4235
  hiddenTextProcs = &(gphprcsptr [1]);
4216
4236
#ifdef WIN_MAC
 
4237
#ifndef WIN_MAC_QUARTZ
4217
4238
  hiddenTextProcs->click = Nlm_DialogTextClick;
 
4239
#endif
 
4240
  hiddenTextProcs->draw = Nlm_DrawHiddenText;
4218
4241
  hiddenTextProcs->key = Nlm_DialogKey;
4219
 
  hiddenTextProcs->draw = Nlm_DrawHiddenText;
4220
4242
  hiddenTextProcs->idle = Nlm_IdleText;
4221
4243
#endif
4222
4244
#ifdef WIN_MSWIN
4226
4248
#endif
4227
4249
  hiddenTextProcs->show = Nlm_ShowText;
4228
4250
  hiddenTextProcs->hide = Nlm_HideText;
 
4251
#ifndef WIN_MAC_QUARTZ
4229
4252
  hiddenTextProcs->enable = Nlm_EnableText;
4230
4253
  hiddenTextProcs->disable = Nlm_DisableText;
4231
4254
  hiddenTextProcs->activate = Nlm_ActivateHiddenText;
4232
4255
  hiddenTextProcs->deactivate = Nlm_DeactivateText;
 
4256
#endif
4233
4257
  hiddenTextProcs->remove = Nlm_RemoveText;
4234
4258
  hiddenTextProcs->reset = Nlm_ResetText;
4235
4259
  hiddenTextProcs->select = Nlm_TextSelectProc;
4242
4266
 
4243
4267
  specialTextProcs = &(gphprcsptr [2]);
4244
4268
#ifdef WIN_MAC
 
4269
#ifndef WIN_MAC_QUARTZ
4245
4270
  specialTextProcs->click = Nlm_DialogTextClick;
 
4271
#endif
 
4272
  specialTextProcs->draw = Nlm_DrawDialogText;
4246
4273
  specialTextProcs->key = Nlm_DialogKey;
4247
 
  specialTextProcs->draw = Nlm_DrawDialogText;
4248
4274
  specialTextProcs->idle = Nlm_IdleText;
4249
4275
#endif
4250
4276
#ifdef WIN_MSWIN
4254
4280
#endif
4255
4281
  specialTextProcs->show = Nlm_ShowText;
4256
4282
  specialTextProcs->hide = Nlm_HideText;
 
4283
#ifndef WIN_MAC_QUARTZ
4257
4284
  specialTextProcs->enable = Nlm_EnableText;
4258
4285
  specialTextProcs->disable = Nlm_DisableText;
4259
4286
  specialTextProcs->activate = Nlm_ActivateHiddenText;
4260
4287
  specialTextProcs->deactivate = Nlm_DeactivateText;
 
4288
#endif
4261
4289
  specialTextProcs->remove = Nlm_RemoveText;
4262
4290
  specialTextProcs->reset = Nlm_ResetText;
4263
4291
  specialTextProcs->select = Nlm_TextSelectProc;
4270
4298
 
4271
4299
  passwordTextProcs = &(gphprcsptr [3]);
4272
4300
#ifdef WIN_MAC
 
4301
#ifdef WIN_MAC_QUARTZ
 
4302
  passwordTextProcs->key = Nlm_DialogKey;
 
4303
#else
4273
4304
  passwordTextProcs->click = Nlm_DialogTextClick;
 
4305
  passwordTextProcs->draw = Nlm_DrawDialogText;
4274
4306
  passwordTextProcs->key = Nlm_PasswordKey;
4275
 
  passwordTextProcs->draw = Nlm_DrawDialogText;
 
4307
#endif
4276
4308
  passwordTextProcs->idle = Nlm_IdleText;
4277
4309
#endif
4278
4310
#ifdef WIN_MSWIN
4282
4314
#endif
4283
4315
  passwordTextProcs->show = Nlm_ShowText;
4284
4316
  passwordTextProcs->hide = Nlm_HideText;
 
4317
#ifndef WIN_MAC_QUARTZ
4285
4318
  passwordTextProcs->enable = Nlm_EnableText;
4286
4319
  passwordTextProcs->disable = Nlm_DisableText;
4287
4320
  passwordTextProcs->activate = Nlm_ActivateText;
4288
4321
  passwordTextProcs->deactivate = Nlm_DeactivateText;
 
4322
#endif
4289
4323
  passwordTextProcs->remove = Nlm_RemoveText;
4290
4324
  passwordTextProcs->reset = Nlm_ResetText;
4291
4325
  passwordTextProcs->select = Nlm_TextSelectProc;
4298
4332
 
4299
4333
  scrollTextProcs = &(gphprcsptr [4]);
4300
4334
#ifdef WIN_MAC
 
4335
#ifndef WIN_MAC_QUARTZ
4301
4336
  scrollTextProcs->click = Nlm_ScrollTextClick;
 
4337
#endif
 
4338
  scrollTextProcs->draw = Nlm_DrawScrollText;
4302
4339
  scrollTextProcs->key = Nlm_TextKey;
4303
 
  scrollTextProcs->draw = Nlm_DrawScrollText;
4304
4340
  scrollTextProcs->idle = Nlm_IdleText;
4305
4341
#endif
4306
4342
#ifdef WIN_MSWIN
4310
4346
#endif
4311
4347
  scrollTextProcs->show = Nlm_ShowScrollText;
4312
4348
  scrollTextProcs->hide = Nlm_HideScrollText;
 
4349
#ifndef WIN_MAC_QUARTZ
4313
4350
  scrollTextProcs->enable = Nlm_EnableText;
4314
4351
  scrollTextProcs->disable = Nlm_DisableText;
4315
4352
  scrollTextProcs->activate = Nlm_ActivateScrollText;
4316
4353
  scrollTextProcs->deactivate = Nlm_DeactivateScrollText;
 
4354
#endif
4317
4355
  scrollTextProcs->remove = Nlm_RemoveText;
4318
4356
  scrollTextProcs->reset = Nlm_ResetText;
4319
4357
  scrollTextProcs->select = Nlm_TextSelectProc;