~ubuntu-branches/debian/experimental/ncbi-tools6/experimental

« back to all changes in this revision

Viewing changes to vibrant/ncbidraw.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:   1/1/91
31
31
*
32
 
* $Revision: 6.40 $
 
32
* $Revision: 6.44 $
33
33
*
34
34
* File Description: 
35
35
*       Vibrant drawing functions.
36
36
*
37
37
* Modifications:  
38
38
* --------------------------------------------------------------------------
39
 
* $Log: ncbidraw.c,v $
40
 
* Revision 6.40  2006/09/14 19:18:28  ivanov
41
 
* Rollback last changes. All missed defines added to corelib/ncbiwin.h.
42
 
*
43
 
* Revision 6.39  2006/09/14 18:05:45  ivanov
44
 
* Fixed compilation errors on MS Windows
45
 
*
46
 
* Revision 6.38  2006/09/14 14:45:38  kans
47
 
* changes for 64-bit Windows (GC) plus a few CodeWarrior complaints (JK)
48
 
*
49
 
* Revision 6.37  2004/04/14 19:15:50  sinyakov
50
 
* WIN_MSWIN: support X-Windows-like -bg color command line option
51
 
*
52
 
* Revision 6.36  2003/11/17 17:03:30  kans
53
 
* changed C++ style comments to C comments
54
 
*
55
 
* Revision 6.35  2003/03/19 21:13:22  kans
56
 
* protect UNIX version of ScrollRect
57
 
*
58
 
* Revision 6.34  2002/06/13 16:15:12  kans
59
 
* fix includes for OS_UNIX_DARWIN with WIN_MAC (EN) - still bug in vibutils.c file dialog
60
 
*
61
 
* Revision 6.33  2002/03/28 13:35:48  kans
62
 
* only include MoreCarbonAccessors.h if not OS_UNIX_DARWIN
63
 
*
64
 
* Revision 6.32  2002/03/06 20:15:14  northup
65
 
* under X11 cache colors from XAllocColor using a hash table. (EN)
66
 
*
67
 
* Revision 6.31  2002/02/04 19:04:51  kans
68
 
* pass fsp.size to LoadFontData for systemFont on Mac - now label width calculated correctly
69
 
*
70
 
* Revision 6.30  2002/02/04 18:49:15  kans
71
 
* fsp.size = GetDefFontSize () for systemFont on Mac - Mac OS X uses Lucida Grande 13
72
 
*
73
 
* Revision 6.29  2001/08/29 21:14:10  juran
74
 
* Move Carbon forward-compatibility to MoreCarbonAccessors.h.
75
 
* Call InvalRgn instead of InvalWindowRegion.
76
 
*
77
 
* Revision 6.28  2001/04/05 19:45:50  juran
78
 
* Carbon fixes.
79
 
*
80
 
* Revision 6.27  2000/02/07 20:17:35  lewisg
81
 
* minor bug fixes, use gui font for win32
82
 
*
83
 
* Revision 6.26  2000/01/24 16:11:13  lewisg
84
 
* speed up seqid comparison in color manager, make fast windows version of SetColor()
85
 
*
86
 
* Revision 6.25  2000/01/13 23:37:13  beloslyu
87
 
* changes because of port to HP-UX 11.0
88
 
*
89
 
* Revision 6.24  1999/12/21 18:04:23  kans
90
 
* removed MPW/THINKC conditional code, starting upgrade to Carbon compatibility - Churchill
91
 
*
92
 
* Revision 6.23  1999/10/20 23:08:10  vakatov
93
 
* + Nlm_SetCurrentGIF() -- to set Nlm_currentGIF directly.
94
 
* + Nlm_DestroyGIF() -- to destroy Nlm_currentGIF.
95
 
* Nlm_CreateGIF() and Nlm_SaveGIF() -- do not destroy Nlm_currentGIF.
96
 
*
97
 
* Revision 6.22  1999/10/04 18:44:02  vakatov
98
 
* [WIN_GIF] Nlm_SelectFont() -- fixed the way the font gets chosen
99
 
*
100
 
* Revision 6.21  1999/03/17 15:10:47  vakatov
101
 
* + Nlm_XLoadStandardFont() to find a "last-resort" font
102
 
*
103
 
* Revision 6.20  1998/08/12 14:52:26  vakatov
104
 
* [MSWIN] Nlm_DrawLine():  draw at least one point(fix to R6.8)
105
 
*
106
 
* Revision 6.19  1998/07/27 16:49:23  vakatov
107
 
* [WIN_X] AddNewFont():  try "-*-" in addition to "--" in font name spec.
108
 
*
109
 
* Revision 6.18  1998/07/24 21:43:14  vakatov
110
 
* [WIN_MSWIN]  It looks like the metafile driver does not support
111
 
* extended userstyle pens, so use plain pens when writing to metafile
112
 
*
113
 
* Revision 6.17  1998/07/14 16:44:24  vakatov
114
 
* Added VibrantIsGUI() and <internal> Nlm_VibrantSetGUI()
115
 
*
116
 
* Revision 6.16  1998/07/01 22:07:16  vakatov
117
 
* s_AdjustRoundRect():  one-pixel fix
118
 
*
119
 
* Revision 6.15  1998/07/01 18:27:41  vakatov
120
 
* Use "const" qualifier somewhere
121
 
*
122
 
* Revision 6.14  1998/06/26 20:00:17  vakatov
123
 
* Added s_AdjustRoundRect() to adjust the rounding sizes in Nlm_*RoundRect()
124
 
*
125
 
* Revision 6.13  1998/06/25 18:36:29  vakatov
126
 
* [WIN_MSWIN]  Minor 1-pixel adjustments to synchronize graphic primitives
127
 
*
128
 
* Revision 6.12  1998/06/12 16:40:12  kans
129
 
* fixed warnings detected by unix compiler
130
 
*
131
 
* Revision 6.11  1998/06/01 17:20:11  vakatov
132
 
* Added code to draw/fill 90-degree arc/pie (quadrants)
133
 
*
134
 
* Revision 6.10  1998/04/27 15:58:46  vakatov
135
 
* Implemented the drawing of rounded rectangles and ovals for GIF and X11
136
 
*
137
 
* Revision 6.9  1998/02/06 16:10:18  vakatov
138
 
* [WIN_X] SetUpDrawingTools(): fixed mem.leak(default font info)
139
 
*
140
 
* Revision 6.8  1998/02/05 20:07:08  vakatov
141
 
* [X11,MSWIN]  Made DrawLine() always draw the last and the first point
142
 
* (to be in-sync with GIF and MAC)
143
 
*
144
 
* Revision 6.7  1997/12/12 21:08:20  kans
145
 
* a number of symbols changed in the latest CodeWarrior release, now using headers from Apple
146
 
*
147
 
* Revision 6.6  1997/11/26 21:29:59  vakatov
148
 
* Fixed errors and warnings issued by C and C++ (GNU and Sun) compilers
149
 
*
150
 
* Revision 6.5  1997/11/04 23:32:49  vakatov
151
 
* [WIN_X] #ULTRA_SPARC_X_SERVER_BUG -- workaround to set foreground color
152
 
* when the stippling is in effect -- see Nlm_XSetForeground() for details.
153
 
*
154
 
* Revision 6.4  1997/09/16 20:34:15  vakatov
155
 
* Added Nlm_FitStringWidth();  for now, it is implemented as native
156
 
* for [WIN_X] and generic for all other platforms.
157
 
* [WIN_X]  Fixed bug in Nlm_AddNewFont() which disabled the font
158
 
* matching algorithm
159
 
*
160
 
* Revision 6.3  1997/09/11 00:00:38  vakatov
161
 
* [WIN_X] Nlm_EraseRect():  use XGetGCValues() to retrieve curr. fill style
162
 
*
163
 
* Revision 6.2  1997/09/10 18:23:35  vakatov
164
 
* [WIN_X] Nlm_EraseRect():  temp. switch fill style to FillSolid
165
 
*
166
 
* Revision 6.1  1997/09/09 23:53:36  vakatov
167
 
* [WIN_GIF]  Nlm_Solid() -- reset the drawing pattern to solid
168
 
*
169
 
* Revision 5.22  1997/08/19 19:28:01  vakatov
170
 
* [WIN_GIF]  Implemented Nlm_SelectPattern()-related features
171
 
*
172
 
* Revision 5.21  1997/07/23 19:42:17  vakatov
173
 
* Added Nlm_PaintStringEx function(text + position)
174
 
*
175
 
* Revision 5.20  1997/07/18 15:18:39  vakatov
176
 
* [!WIN_GIF] +Dummy Nlm_CreateGIF() and Nlm_SaveGIF();  /return FALSE/
177
 
*
178
 
* Revision 5.19  1997/07/10 21:49:21  vakatov
179
 
* [WIN_X]  Now able to manage windows having different depths(and
180
 
* different visuals and GC).
181
 
*
182
 
* Revision 5.18  1997/06/18 19:46:27  vakatov
183
 
* [WIN_GIF]  Do not use WIN_MAC/MSWIN/MOTIF-specific fields of the
184
 
* Nlm_FontRec struct.
185
 
*
186
 
* Revision 5.17  1997/06/09 18:54:33  vakatov
187
 
* [WIN_X]  Nlm_XAllocColor() moved to "vibwndws.c";  Nlm_SetupColor()
188
 
* removed at all;  use Nlm_VibrantDefaultColormap() and Nlm_XAllocColor()
189
 
* instead of 0 and XAllocColor() in most cases in order to use
190
 
* standard colormap rather than the default one.
191
 
* [ALL]  Renamed("Local__" - prefixed) static coordination transformation funcs
192
 
* whose name conflicts with the global ones;  +other code cleaning...
193
 
*
194
 
* Revision 5.16  1997/06/04 16:12:05  vakatov
195
 
* [WIN_MSWIN] PaintStringWin() has been removed again(see also R5.14)
196
 
*
197
 
* Revision 5.15  1997/06/04 00:05:12  kans
198
 
* support for Japanese by Tomo Koike of DDBJ
199
 
*
200
 
* Revision 5.14  1997/05/08 14:05:27  vakatov
201
 
* [WIN_MSWIN] PaintStringWin() is obsolete; replaced by MoveTo + PaintString
202
 
*
203
 
 * Revision 5.13  1997/05/06  20:03:44  vakatov
204
 
 * [WIN_GIF] Nlm_CreateGIF(): Boolean --> Nlm_Boolean (by J.Kuzio)
205
 
 *
206
 
 * Revision 5.12  1997/05/06  18:39:52  vakatov
207
 
 * [WIN32] Nlm_SetPenDash() -- added #WIN_MSWIN cpp condition
208
 
 *
209
 
 * Revision 5.11  1997/04/22  17:32:28  vakatov
210
 
 * [WIN_X] Nlm_DrawLine() -- correction of R5.6 for p1.[xy] > p2.[xy]
211
 
 *
212
 
 * Revision 5.10  1997/04/04  22:46:42  vakatov
213
 
 * [WIN_MSWIN]  Added static HFONT2Font() function;  since now,
214
 
 * "Nlm_systemFont" and "Nlm_programFont" are to be printed using
215
 
 * the matching logical fonts obtained with HFONT2Font().
216
 
 *
217
 
 * Revision 5.9  1997/01/29  16:41:22  kans
218
 
 * using StringNCpy_0
219
 
 *
220
 
 * Revision 5.8  1996/12/11  22:29:19  vakatov
221
 
 * [WIN_MSWIN]  Nlm_ResetDrawingTools():  reset prevPenHDC to ensure
222
 
 * proper brush pattern setting in some exotic cases
223
 
 *
224
 
 * Revision 5.7  1996/12/04  21:17:19  vakatov
225
 
 * [WIN_X] Nlm_InvertRect():  use GXinvert both on b/w and color displays
226
 
 *
227
 
 * Revision 5.6  1996/12/04  16:12:08  vakatov
228
 
 * [WIN_X]  Made Nlm_DrawLine() always draw the last point;  Nlm_MoveTo() now
229
 
 * implemented via a call to Nlm_DrawLine().
230
 
 *
231
 
 * Revision 5.5  1996/11/21  22:26:22  vakatov
232
 
 * [WIN_X]  Made Nlm_LineTo() and Nlm_DrawLine() draw last point
233
 
 *
234
 
 * Revision 5.4  1996/11/21  18:50:59  vakatov
235
 
 * [WIN_MOTIF]  Rectangle and Polygon drawing sync. to other platforms
236
 
 *
237
 
 * Revision 5.3  1996/10/28  19:33:04  vakatov
238
 
 * [WIN_MOTIF]  Use Nlm_VibrantDefaultColormap() instead of the display
239
 
 * default colormap everywhere in the color handling code.
240
 
 *
241
 
 * Revision 5.2  1996/10/01  18:17:37  vakatov
242
 
 * [WIN_X]  Added auxiliary static routine Nlm_XAllocColor() in order to
243
 
 * provide a uniform way of the color allocating;  on the color
244
 
 * allocation error, it now returns "Black" pixel rather than "White".
245
 
 *
246
 
 * Revision 5.1  1996/09/30  19:54:08  vakatov
247
 
 * [WIN_X, WIN_NT]  Added Nlm_SetPenDash() to allow advanced line dashing
248
 
 * [WIN_MSWIN]  Nlm_PaintRect() -- synchronize it with Nlm_FrameRect(),
249
 
 * Nlm_FrameOval(), etc. (left + 1, bottom + 1)
250
 
 *
251
 
 * Revision 5.0  1996/05/28  13:45:08  ostell
252
 
 * Set to revision 5.0
253
 
 *
254
 
 * Revision 4.13  1996/05/10  21:12:33  vakatov
255
 
 * Added UpdateColorTable() function to allow the user to read his color
256
 
 * preferencies from an external config.-file in format:
257
 
 * <index> <red> <green> <blue> [<name>];
258
 
 * <name> is optional and it is only used in the WIN_MOTIF-based
259
 
 * applications to get hardware-independent named colors, if possible.
260
 
 *
261
 
 * Revision 4.12  1996/04/15  19:31:56  tatiana
262
 
 * add Boolean transparent to Nlm_CreateGIF()
263
 
 *
264
 
 * Revision 4.11  1996/02/01  22:42:01  smirnov
265
 
 * AS: problem with symbols in clipboard is fixed
266
 
 *
267
 
 * Revision 4.10  1996/02/01  18:42:53  smirnov
268
 
 * AS: fix bug: draw a small rectangle
269
 
 *
270
 
 * Revision 4.9  1996/01/31  18:47:32  smirnov
271
 
 * fix copy&paste bug
272
 
 *
273
 
 * Revision 4.8  1995/12/22  19:42:33  smirnov
274
 
 * AS: Fixed bug in GIF version of DrawText()
275
 
 *
276
 
 * Revision 4.7  1995/11/27  15:47:55  kans
277
 
 * fixed FrameArc (VL + JK)
278
 
 *
279
 
 * Revision 4.6  1995/11/27  15:13:41  kans
280
 
 * corrections to font height, etc. functions (VL)
281
 
 *
282
 
 * Revision 4.4  1995/11/14  13:42:05  kans
283
 
 * fixes to AddNewFont (VL)
284
 
 *
285
 
 * Revision 4.3  1995/11/07  15:47:22  smirnov
286
 
 * add GIF generator (Alex Smirnov)
287
 
 *
288
 
 * Revision 4.2  1995/09/12  17:59:35  ostell
289
 
 * fixes for MS windows text to metafile
290
 
 *
291
 
 * Revision 4.1  1995/09/12  00:39:10  ostell
292
 
 * changes for text to appear in windows metafiles
293
 
 *
294
 
 * Revision 4.0  1995/07/26  13:51:04  ostell
295
 
 * force revision to 4.0
296
 
 *
297
 
 * Revision 2.41  1995/07/14  17:48:26  kans
298
 
 * new CopyPixmap (AS)
299
 
 *
300
 
 * Revision 2.40  1995/06/07  21:23:38  kans
301
 
 * RecreateBrushes problem fixed (AS)
 
39
*
302
40
* ==========================================================================
303
41
*/
304
42
 
346
84
Nlm_Boolean  Nlm_nowPrinting = FALSE;
347
85
 
348
86
#ifdef WIN_MAC
 
87
#ifdef __MWERKS__
349
88
#include "MoreCarbonAccessors.h"
 
89
#else
 
90
#define GetPortAndCall_(function, arg)           \
 
91
    do {                                          \
 
92
        GrafPtr port_;                            \
 
93
        GetPort(&port_);                          \
 
94
        function(GetWindowFromPort(port_), (arg));  \
 
95
    } while (0)
 
96
#define InvalRect(rect)  GetPortAndCall_(InvalWindowRect, (rect))
 
97
#define InvalRgn(rgn)    GetPortAndCall_(InvalWindowRgn,  (rgn ))
 
98
#define ValidRect(rect)  GetPortAndCall_(ValidWindowRect, (rect))
 
99
#define ValidRgn(rgn)    GetPortAndCall_(ValidWindowRgn,  (rgn ))
 
100
#endif
350
101
#endif
351
102
 
352
103
#ifdef WIN_MAC
 
104
#ifdef WIN_MAC_QUARTZ
 
105
CFMutableArrayRef Nlm_QContextStack = 0;
 
106
static void Nlm_PushQContext( CGContextRef ctx )
 
107
{
 
108
  if (!Nlm_QContextStack)
 
109
    Nlm_QContextStack = CFArrayCreateMutable (NULL, 0, NULL);
 
110
  CFArrayAppendValue (Nlm_QContextStack, ctx);
 
111
}
 
112
static CGContextRef Nlm_PeekQContext (void)
 
113
{
 
114
  if (!Nlm_QContextStack)
 
115
    return NULL;
 
116
  
 
117
  CFIndex count = CFArrayGetCount (Nlm_QContextStack);
 
118
  return count ? (CGContextRef)CFArrayGetValueAtIndex (Nlm_QContextStack, count - 1) : NULL;
 
119
}
 
120
static CGContextRef Nlm_PopQContext (void)
 
121
{
 
122
  if (!Nlm_QContextStack)
 
123
    return NULL;
 
124
  
 
125
  void *ret = Nlm_PeekQContext();
 
126
  CFIndex count = CFArrayGetCount (Nlm_QContextStack);
 
127
  if (count)
 
128
    CFArrayRemoveValueAtIndex (Nlm_QContextStack, count - 1);
 
129
  return ret;
 
130
}
 
131
 
 
132
WindowRef Nlm_QWindow = 0;
 
133
Nlm_QuartzColor Nlm_QuartzForeColor;
 
134
Nlm_QuartzColor Nlm_QuartzBackColor;
 
135
Nlm_Boolean  Nlm_hasColorQD = TRUE;
 
136
#else
353
137
RGBColor     Nlm_RGBforeColor;
354
138
RGBColor     Nlm_RGBbackColor;
355
139
Nlm_Boolean  Nlm_hasColorQD = FALSE;
356
140
#endif
 
141
#endif
357
142
 
358
143
#ifdef WIN_MSWIN
359
144
#define ATT_PENSTYLE  1
528
313
static Nlm_Uint1 blackPat []= {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
529
314
#endif /* WIN_X | WIN_GIF */
530
315
 
531
 
 
532
316
#ifdef WIN_MAC
 
317
#ifdef WIN_MAC_QUARTZ
 
318
extern  void  Nlm_SetPort (CGContextRef ctx)
 
319
{
 
320
  if (Nlm_PeekQContext()) {
 
321
    CGContextSynchronize(Nlm_PeekQContext());
 
322
    CGContextRelease(Nlm_PeekQContext());
 
323
    Nlm_PopQContext();
 
324
  }
 
325
  
 
326
  if (ctx)
 
327
  {
 
328
        Nlm_PushQContext(ctx);
 
329
        CGContextRetain(Nlm_PeekQContext());
 
330
  }
 
331
// QUARTZ_FIXME: some of this might be useful, somehow
 
332
//  if (grafptr != 0) {
 
333
//    CGAffineTransform textTransform;
 
334
//    
 
335
//    GetPortBounds(grafptr, &pBounds);
 
336
//    pHeight = pBounds.bottom - pBounds.top;
 
337
//    QDBeginCGContext(grafptr, &Nlm_PeekQContext());
 
338
//    CGContextTranslateCTM(Nlm_PeekQContext(), 0, pHeight);
 
339
//    CGContextScaleCTM(Nlm_PeekQContext(), 1.0f, -1.0f);
 
340
//    
 
341
//    textTransform = CGAffineTransformMakeScale(1.0f, -1.0f);
 
342
//    CGContextSetTextMatrix(Nlm_PeekQContext(), textTransform);
 
343
//  } else {
 
344
//    Nlm_PeekQContext() = 0;
 
345
//  }
 
346
}
 
347
 
 
348
void  Nlm_PushPort (CGContextRef ctx)
 
349
{
 
350
  Nlm_PushQContext (ctx);
 
351
}
 
352
 
 
353
CGContextRef Nlm_PopPort (void)
 
354
{
 
355
  return Nlm_PopQContext ();
 
356
}
 
357
 
 
358
#else
533
359
extern  void  Nlm_SetPort (GrafPtr grafptr)
534
360
{
535
361
  SetPort (grafptr);
536
362
}
537
363
#endif
538
364
 
 
365
extern void Nlm_SetPortWindowPort(Nlm_WindowTool wptr)
 
366
{
 
367
#ifdef WIN_MAC_QUARTZ
 
368
    Nlm_QWindow = wptr;
 
369
#else
 
370
    SetPortWindowPort(wptr);
 
371
#endif
 
372
}
 
373
 
 
374
#ifdef WIN_MAC_QUARTZ
 
375
WindowRef Nlm_GetQuartzCurrentWindow (void)
 
376
{
 
377
  return Nlm_QWindow;
 
378
}
 
379
 
 
380
void Nlm_SetGraphicNeedsDisplay (Nlm_GraphiC graphic)
 
381
{
 
382
  HIViewSetNeedsDisplay (HIViewGetRoot (Nlm_ParentWindowPtr (graphic)), 1);
 
383
}
 
384
#endif
 
385
 
 
386
#endif
 
387
 
539
388
#ifdef WIN_MSWIN
540
389
extern  void  Nlm_SetPort (HWND hwnd, HDC hdc)
541
390
{
542
391
  Nlm_currentHWnd = hwnd;
543
392
  Nlm_currentHDC = hdc;
544
393
}
 
394
 
545
395
#endif
546
396
 
547
397
#ifdef WIN_X
722
572
    DeleteObject( oldPen );
723
573
  }}
724
574
 
 
575
#elif defined(WIN_MAC_QUARTZ)
 
576
  {
 
577
    float dashes[2];
 
578
    dashes[0] = (float) dash;
 
579
    dashes[1] = (float) gap;
 
580
    CGContextSetLineDash(Nlm_PeekQContext(), (float) offset, dashes, 2);
 
581
  }
725
582
#else
726
583
  Nlm_Dashed();
727
584
#endif
731
588
#ifdef WIN_MAC
732
589
static void Nlm_ChooseColor (Nlm_Int4 color)
733
590
{
 
591
#ifdef WIN_MAC_QUARTZ
 
592
  ASSERT(false);
 
593
#else
734
594
  ForeColor (color);
 
595
#endif
735
596
}
736
597
#endif
737
598
 
910
771
extern HBRUSH Nlm_hbrWindowBackground;
911
772
#endif
912
773
 
 
774
#ifdef WIN_MAC_QUARTZ
 
775
static void Nlm_SelectQuartzColor (Nlm_QuartzColor c)
 
776
{
 
777
  CGContextSetRGBFillColor  (Nlm_PeekQContext(), c.r, c.g, c.b, 1.0);
 
778
  CGContextSetRGBStrokeColor(Nlm_PeekQContext(), c.r, c.g, c.b, 1.0);
 
779
}
 
780
#endif
913
781
 
914
782
extern void Nlm_ResetDrawingTools (void)
915
783
{
916
784
#ifdef WIN_MAC
 
785
#ifdef WIN_MAC_QUARTZ
 
786
  if (Nlm_PeekQContext())
 
787
  {
 
788
    CGContextSetLineWidth(Nlm_PeekQContext(), 1.0);
 
789
    CGContextSetLineDash(Nlm_PeekQContext(), 0, NULL, 0);
 
790
    CGContextSetAlpha(Nlm_PeekQContext(), 1.0);
 
791
    Nlm_SelectQuartzColor(Nlm_QuartzForeColor);
 
792
  }
 
793
#else
917
794
  PenNormal ();
918
795
  PenMode (patCopy);
919
796
  TextMode (srcOr);
925
802
    BackColor (whiteColor);
926
803
  }
927
804
#endif
 
805
#endif
928
806
#ifdef WIN_MSWIN
929
807
  if (Nlm_currentHDC != NULL) {
930
808
    SetROP2 (Nlm_currentHDC, R2_COPYPEN);
931
809
    SelectObject(Nlm_currentHDC, GetStockObject(SYSTEM_FONT));
932
810
    winTextColor = GetSysColor (COLOR_WINDOWTEXT);
933
811
    winBkColor = Nlm_hasBackColor ?
934
 
                   Nlm_crBackColor :
935
 
                   GetSysColor (COLOR_WINDOW);
 
812
           Nlm_crBackColor :
 
813
           GetSysColor (COLOR_WINDOW);
936
814
    SetTextColor (Nlm_currentHDC, winTextColor);
937
815
    SetBkColor (Nlm_currentHDC, winBkColor);
938
816
    SetBkMode (Nlm_currentHDC, TRANSPARENT);
1052
930
 
1053
931
extern void Nlm_CopyMode (void)
1054
932
{
1055
 
#ifdef WIN_MAC
 
933
#if defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ)
1056
934
  PenMode (patCopy);
1057
935
  TextMode (srcOr);
1058
936
#endif
1073
951
}
1074
952
 
1075
953
extern void Nlm_MergeMode (void)
1076
 
 
1077
954
{
1078
 
#ifdef WIN_MAC
 
955
#if defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ)
1079
956
  PenMode (patOr);
1080
957
  TextMode (srcOr);
1081
958
#endif
1100
977
}
1101
978
 
1102
979
extern void Nlm_InvertMode (void)
1103
 
 
1104
980
{
1105
 
#ifdef WIN_MAC
 
981
#if defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ)
1106
982
  PenMode (patXor);
1107
983
  TextMode (srcXor);
1108
984
#endif
1127
1003
}
1128
1004
 
1129
1005
extern void Nlm_EraseMode (void)
1130
 
 
1131
 
 
1132
1006
{
1133
 
#ifdef WIN_MAC
 
1007
#if defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ)
1134
1008
  PenMode (patBic);
1135
1009
  TextMode (srcBic);
1136
1010
#endif
1359
1233
extern void Nlm_SelectColor (Nlm_Uint1 red, Nlm_Uint1 green, Nlm_Uint1 blue)
1360
1234
{
1361
1235
#ifdef WIN_MAC
 
1236
#ifdef WIN_MAC_QUARTZ
 
1237
  Nlm_QuartzForeColor.r = red/255.0;
 
1238
  Nlm_QuartzForeColor.g = green/255.0;
 
1239
  Nlm_QuartzForeColor.b = blue/255.0;
 
1240
  Nlm_SelectQuartzColor (Nlm_QuartzForeColor);
 
1241
#else
1362
1242
  RGBColor   color;
1363
1243
  Nlm_Uint2  bl;
1364
1244
  Nlm_Uint2  gn;
1378
1258
    Nlm_ChooseColor (whiteColor);
1379
1259
  }
1380
1260
#endif
 
1261
#endif
1381
1262
#ifdef WIN_MSWIN
1382
1263
  COLORREF   color;
1383
1264
  Nlm_Uint2  bl;
1403
1284
  if (ColorHashBuckets [hash] != NULL) {
1404
1285
    for (CHBP = ColorHashBuckets [hash]; CHBP != NULL; CHBP = CHBP->next) {
1405
1286
      if (CHBP->lrgb == lrgb) {
1406
 
        xcolor = CHBP->xcolor;
1407
 
        Nlm_ChooseColor (xcolor.pixel);
1408
 
        return;
 
1287
        xcolor = CHBP->xcolor;
 
1288
        Nlm_ChooseColor (xcolor.pixel);
 
1289
        return;
1409
1290
      }
1410
1291
      tail = CHBP;
1411
1292
    }
1489
1370
extern Nlm_Uint4 Nlm_GetColor (void)
1490
1371
{
1491
1372
#ifdef WIN_MAC
1492
 
  Nlm_Uint1  colors [4];
1493
 
  RGBColor   foreColor;
 
1373
  Nlm_Uint1  colors [4] = { 0 };
1494
1374
  Nlm_Int4   fgColor;
 
1375
#ifdef WIN_MAC_QUARTZ
 
1376
  colors[0] = 0;
 
1377
  colors[1] = Nlm_QuartzForeColor.r * 255.0;
 
1378
  colors[2] = Nlm_QuartzForeColor.g * 255.0;
 
1379
  colors[3] = Nlm_QuartzForeColor.b * 255.0;
 
1380
#else
 
1381
  RGBColor   foreColor;
1495
1382
 
1496
 
  fgColor = 0;
1497
1383
  if (Nlm_hasColorQD) {
1498
1384
    GetForeColor (&foreColor);
1499
1385
    colors [0] = 0;
1501
1387
    colors [2] = (Nlm_Uint1) (foreColor.green >> 8);
1502
1388
    colors [3] = (Nlm_Uint1) (foreColor.blue >> 8);
1503
1389
    fgColor = *((Nlm_Int4Ptr) colors);
1504
 
#if !OPAQUE_TOOLBOX_STRUCTS
1505
 
  } else {
1506
 
        GrafPtr port;
 
1390
  }
 
1391
#endif
 
1392
  fgColor = (colors[0] << 24) | (colors[1] << 16) | (colors[2] << 8) | colors[3];
 
1393
#if !defined( WIN_MAC_QUARTZ ) && !defined( OPAQUE_TOOLBOX_STRUCTS )
 
1394
  if (!Nlm_hasColorQD) {
 
1395
      GrafPtr port;
1507
1396
    GetPort (&port);
1508
1397
    if (port != NULL) {
1509
1398
      fgColor = port->fgColor;
1510
1399
    }
1511
 
#endif
1512
1400
  }
 
1401
#endif
1513
1402
  return (Nlm_Uint4) fgColor;
1514
1403
#endif
1515
1404
#ifdef WIN_MSWIN
1568
1457
    rd = (Nlm_Uint2) colors [1];
1569
1458
    gn = (Nlm_Uint2) colors [2];
1570
1459
    bl = (Nlm_Uint2) colors [3];
 
1460
#ifdef WIN_MAC_QUARTZ
 
1461
    Nlm_SelectColor(rd, gn, bl);
 
1462
#else
1571
1463
    foreColor.red = rd << 8 | rd;
1572
1464
    foreColor.green = gn << 8 | gn;
1573
1465
    foreColor.blue = bl << 8 | bl;
1577
1469
    if (port != NULL) {
1578
1470
      ForeColor ((Nlm_Int4) color);
1579
1471
    }
 
1472
#endif
1580
1473
  }
1581
1474
#endif
1582
1475
#ifdef WIN_MSWIN
1599
1492
 
1600
1493
{
1601
1494
#ifdef WIN_MAC
 
1495
#ifdef WIN_MAC_QUARTZ
 
1496
  Nlm_QuartzColor temp = Nlm_QuartzForeColor;
 
1497
  Nlm_QuartzForeColor = Nlm_QuartzBackColor;
 
1498
  Nlm_QuartzBackColor = temp;
 
1499
  
 
1500
  Nlm_SelectQuartzColor (Nlm_QuartzForeColor);
 
1501
#else
1602
1502
  RGBColor  backColor;
1603
1503
  RGBColor  foreColor;
1604
1504
 
1611
1511
  } else {
1612
1512
    Nlm_Int4  bkColor;
1613
1513
    Nlm_Int4  fgColor;
1614
 
        GrafPtr port;
 
1514
      GrafPtr port;
1615
1515
    GetPort (&port);
1616
1516
    if (port != NULL) {
1617
1517
      fgColor = port->fgColor;
1618
1518
      bkColor = port->bkColor;
1619
1519
      ForeColor (bkColor);
1620
1520
      BackColor (fgColor);
1621
 
    }
1622
1521
#endif
1623
1522
  }
1624
1523
#endif
 
1524
#endif
1625
1525
#ifdef WIN_MSWIN
1626
1526
  Nlm_Int4  bkColor;
1627
1527
  Nlm_Int4  fgColor;
1740
1640
 
1741
1641
extern void Nlm_Dark (void)
1742
1642
{
1743
 
#ifdef WIN_MAC
 
1643
#ifdef WIN_MAC_QUARTZ
 
1644
  CGContextSetGrayFillColor  (Nlm_PeekQContext(), .25, 1.0);
 
1645
  CGContextSetGrayStrokeColor(Nlm_PeekQContext(), .25, 1.0);
 
1646
#elif defined(WIN_MAC)
1744
1647
  PenPat ((ConstPatternParam) dkGrayPat);
1745
1648
#endif
1746
1649
#ifdef WIN_MSWIN
1756
1659
 
1757
1660
extern void Nlm_Medium (void)
1758
1661
{
1759
 
#ifdef WIN_MAC
 
1662
#ifdef WIN_MAC_QUARTZ
 
1663
  CGContextSetGrayFillColor  (Nlm_PeekQContext(), .5, 1.0);
 
1664
  CGContextSetGrayStrokeColor(Nlm_PeekQContext(), .5, 1.0);
 
1665
#elif defined(WIN_MAC)
1760
1666
  PenPat ((ConstPatternParam) grayPat);
1761
1667
#endif
1762
1668
#ifdef WIN_MSWIN
1772
1678
 
1773
1679
extern void Nlm_Light (void)
1774
1680
{
1775
 
#ifdef WIN_MAC
 
1681
#ifdef WIN_MAC_QUARTZ
 
1682
  CGContextSetGrayFillColor  (Nlm_PeekQContext(), .75, 1.0);
 
1683
  CGContextSetGrayStrokeColor(Nlm_PeekQContext(), .75, 1.0);
 
1684
#elif defined(WIN_MAC)
1776
1685
  PenPat ((ConstPatternParam) ltGrayPat);
1777
1686
#endif
1778
1687
#ifdef WIN_MSWIN
1789
1698
extern void Nlm_Empty (void)
1790
1699
{
1791
1700
#ifdef WIN_MAC
 
1701
#ifdef WIN_MAC_QUARTZ
 
1702
  CGContextSetGrayFillColor  (Nlm_PeekQContext(), 1.0, 1.0);
 
1703
  CGContextSetGrayStrokeColor(Nlm_PeekQContext(), 1.0, 1.0);
 
1704
#else
1792
1705
  PenPat ((ConstPatternParam) whitePat);
1793
1706
#endif
 
1707
#endif
1794
1708
#ifdef WIN_MSWIN
1795
1709
  Nlm_SelectPattern (PS_SOLID, 1, whitePat, ATT_PATTERN);
1796
1710
#endif
1806
1720
{
1807
1721
#ifdef WIN_MAC
1808
1722
  Nlm_Int2      i;
 
1723
#ifdef WIN_MAC_QUARTZ
 
1724
  float         pat[8];
 
1725
#else
1809
1726
  Nlm_Byte      pat [8];
 
1727
#endif
1810
1728
  Nlm_BytePtr   ptr;
1811
1729
#endif
1812
1730
#ifdef WIN_MSWIN
1829
1747
      pat [i] = *ptr;
1830
1748
      ptr++;
1831
1749
    }
 
1750
#ifdef WIN_MAC_QUARTZ
 
1751
    CGContextSetLineDash(Nlm_PeekQContext(), 0, pat, 8);
 
1752
#else
1832
1753
    PenPat ((ConstPatternParam) pat);
1833
1754
#endif
 
1755
#endif
1834
1756
#ifdef WIN_MSWIN
1835
1757
    ptr = (Nlm_Uint1Ptr) pattern;
1836
1758
    q = (Nlm_Uint1Ptr) pat;
1861
1783
 
1862
1784
extern void Nlm_Solid (void)
1863
1785
{ /* Reset *both* line stile and drawing pattern to SOLID */
1864
 
#ifdef WIN_MAC
 
1786
#ifdef WIN_MAC_QUARTZ
 
1787
  CGContextSetGrayFillColor  (Nlm_PeekQContext(), 0.0, 1.0);
 
1788
  CGContextSetGrayStrokeColor(Nlm_PeekQContext(), 0.0, 1.0);
 
1789
  CGContextSetLineDash(Nlm_PeekQContext(), 0, NULL, 0);
 
1790
#elif defined(WIN_MAC)
1865
1791
  PenPat ((ConstPatternParam) blackPat);
1866
1792
#endif
1867
1793
#ifdef WIN_MSWIN
1883
1809
 
1884
1810
extern void Nlm_Dotted (void)
1885
1811
{
1886
 
#ifdef WIN_MAC
 
1812
#ifdef WIN_MAC_QUARTZ
 
1813
  float dashes[] = { 1.0, 1.0 };
 
1814
  CGContextSetLineDash(Nlm_PeekQContext(), 0, dashes, 2);
 
1815
#elif defined(WIN_MAC)
1887
1816
  PenPat ((ConstPatternParam) dotPat);
1888
1817
#endif
1889
1818
#ifdef WIN_MSWIN
1903
1832
 
1904
1833
extern void Nlm_Dashed (void)
1905
1834
{
1906
 
#ifdef WIN_MAC
 
1835
#ifdef WIN_MAC_QUARTZ
 
1836
  float dashes[] = { 3.0, 1.0 };
 
1837
  CGContextSetLineDash(Nlm_PeekQContext(), 0, dashes, 2);
 
1838
#elif defined(WIN_MAC)
1907
1839
  PenPat ((ConstPatternParam) dashPat);
1908
1840
#endif
1909
1841
#ifdef WIN_MSWIN
1923
1855
 
1924
1856
extern void Nlm_WidePen (Nlm_Int2 width)
1925
1857
{
1926
 
#ifdef WIN_MAC
 
1858
#ifdef WIN_MAC_QUARTZ
 
1859
  CGContextSetLineDash(Nlm_PeekQContext(), 0, NULL, 0);
 
1860
  CGContextSetLineWidth(Nlm_PeekQContext(), (float) width);
 
1861
#elif defined(WIN_MAC)
1927
1862
  PenPat ((ConstPatternParam) blackPat);
1928
1863
  PenSize (width, width);
1929
1864
#endif
1947
1882
                              Nlm_FonT next,
1948
1883
                              Nlm_Int4 refcnt,
1949
1884
                              Nlm_FontSpecPtr fsp,
1950
 
#ifdef WIN_MAC
 
1885
#if defined(WIN_MAC) && ! defined(WIN_MAC_ATSUI)
1951
1886
                              Nlm_Int2 num,
1952
1887
                              Nlm_Int2 size,
1953
1888
                              Nlm_Int2 styl,
1962
1897
  fdata.refcnt = refcnt;
1963
1898
  if (fsp != NULL) fdata.fontspec = *fsp;
1964
1899
  else Nlm_MemSet (&fdata.fontspec, 0, sizeof (Nlm_FontSpec));
1965
 
#ifdef WIN_MAC
 
1900
#if defined(WIN_MAC) && ! defined(WIN_MAC_ATSUI)
1966
1901
  fdata.number = num;
1967
1902
  fdata.size = size;
1968
1903
  fdata.style = styl;
1969
 
#elif defined(WIN_MSWIN) || defined(WIN_X)
 
1904
#elif defined(WIN_MSWIN) || defined(WIN_X) || defined(WIN_MAC_ATSUI)
1970
1905
  fdata.handle = hdl;
1971
1906
#endif
1972
1907
  fdata.print = print;
2067
2002
}
2068
2003
#endif
2069
2004
 
 
2005
#ifdef WIN_MAC_ATSUI
 
2006
 
 
2007
static Nlm_FontTool Nlm_FontToATSUStyle(Nlm_FonT f)
 
2008
{
 
2009
  Nlm_FontData  fontData;
 
2010
  Nlm_GetFontData (f, &fontData);
 
2011
  return fontData.handle;
 
2012
}
 
2013
 
 
2014
 
 
2015
static Nlm_FontTool Nlm_NewATSUStyle(Nlm_FontSpecPtr fsp)
 
2016
{
 
2017
  OSErr err;
 
2018
  Nlm_FontTool style = NULL; /* type ATSUStyle */
 
2019
  
 
2020
  err = ATSUCreateStyle(&style);
 
2021
  if (err == noErr) {
 
2022
    ATSUFontID  fontID;
 
2023
    Fixed atsuSize;
 
2024
    Boolean boldTag = FALSE;
 
2025
    Boolean italicTag = FALSE;
 
2026
    
 
2027
    ATSUAttributeTag theTags[] = {kATSUFontTag, kATSUSizeTag, kATSUQDBoldfaceTag, kATSUQDItalicTag};
 
2028
    ByteCount theSizes[] = {sizeof(ATSUFontID), sizeof(Fixed), sizeof(Boolean), sizeof(Boolean)};
 
2029
    ATSUAttributeValuePtr theValues[] = {&fontID, &atsuSize, &boldTag, &italicTag};
 
2030
 
 
2031
    /* Get Font id from the name. */
 
2032
    OSStatus err = ATSUFindFontFromName (
 
2033
       fsp->name, strlen(fsp->name), 
 
2034
       kFontFullName, // kFontFamilyName,  
 
2035
       kFontMacintoshPlatform, // kFontUnicodePlatform for Unicode support.
 
2036
       kFontNoScriptCode, kFontNoLanguageCode,
 
2037
       &fontID
 
2038
    );
 
2039
    if (err == kATSUInvalidFontErr)
 
2040
    {
 
2041
      /* or can we do something more intelligent here? */
 
2042
      return NULL;
 
2043
    }
 
2044
    
 
2045
    if ((fsp->style & STYLE_BOLD) != 0) boldTag = TRUE;
 
2046
    if ((fsp->style & STYLE_ITALIC) != 0) italicTag = TRUE;
 
2047
 
 
2048
    /* get the size ready */
 
2049
    atsuSize = Long2Fix (fsp->size);
 
2050
    
 
2051
    /* put the attributes in to the style. */
 
2052
    err = ATSUSetAttributes (
 
2053
       style, 
 
2054
       sizeof(theTags)/sizeof(ATSUAttributeTag), 
 
2055
       theTags, 
 
2056
       theSizes, 
 
2057
       theValues
 
2058
    );
 
2059
  }
 
2060
    
 
2061
  return style;
 
2062
}
 
2063
 
 
2064
 
 
2065
#endif
2070
2066
 
2071
2067
/* esl: main internal procedure to create fonts */
2072
2068
static Nlm_FonT Nlm_AddNewFont (Nlm_FontSpecPtr fsp, Nlm_Boolean residentp)
2073
2069
{
2074
2070
  Nlm_FonT rsult;
2075
 
#ifdef WIN_MAC
 
2071
#if defined(WIN_MAC) && ! defined(WIN_MAC_ATSUI)
2076
2072
  Nlm_Int2 num = 0;
2077
2073
  Nlm_Int2 styl = 0;
2078
 
#else /* WIN_MSWIN | WIN_X */
 
2074
#else /* WIN_MSWIN | WIN_X | WIN_GIF | WIN_MAC_ATSUI */
2079
2075
  Nlm_FontTool hdl = NULL;
2080
2076
#endif
2081
2077
 
2085
2081
    return NULL;
2086
2082
 
2087
2083
#ifdef WIN_MAC
 
2084
#ifdef WIN_MAC_ATSUI
 
2085
  hdl = Nlm_NewATSUStyle(fsp);
 
2086
#else
2088
2087
  {{
2089
2088
    Nlm_Char temp[256];
2090
2089
    if (fsp->name[0] != '\0') {
2118
2117
    if ((fsp->style & 32) != 0)  styl += condense;
2119
2118
    if ((fsp->style & 64) != 0)  styl += extend;
2120
2119
  }}
 
2120
#endif /* WIN_MAC_ATSUI */
2121
2121
#endif /* WIN_MAC */
2122
2122
#ifdef WIN_MSWIN
2123
2123
  {{
2185
2185
                    Nlm_fontList,
2186
2186
                    residentp ? -1 : 1,
2187
2187
                    fsp,
2188
 
#ifdef WIN_MAC
 
2188
#if defined(WIN_MAC) && ! defined(WIN_MAC_ATSUI)
2189
2189
                    num,
2190
2190
                    fsp->size,
2191
2191
                    styl,
2192
 
#else /* WIN_MSWIN | WIN_X */
 
2192
#else /* WIN_MSWIN | WIN_X | WIN_GIF | WIN_MAC_ATSUI */
2193
2193
                    hdl,
2194
2194
#endif
2195
2195
                    NULL);
2485
2485
extern Nlm_FonT Nlm_GetFontEx (Nlm_CharPtr name, Nlm_Int2 size,
2486
2486
                             Nlm_Boolean bld, Nlm_Boolean itlc,
2487
2487
                             Nlm_Boolean undrln, Nlm_CharPtr fmly,
2488
 
                                                         Nlm_CharPtr chset, Nlm_Boolean fixed)
 
2488
                             Nlm_CharPtr chset, Nlm_Boolean fixed)
2489
2489
{
2490
2490
  Nlm_Uint1 style, charset, pitch, family;
2491
2491
 
2553
2553
    bold = FALSE;
2554
2554
    ital = FALSE;
2555
2555
    undr = FALSE;
2556
 
        fixd = FALSE;
2557
 
        chst [0] = '\0';
 
2556
    fixd = FALSE;
 
2557
    chst [0] = '\0';
2558
2558
    Nlm_StringNCpy_0 (name, spec, sizeof (name) - 1);
2559
2559
    p = Nlm_StringChr (name, ',');
2560
2560
    if (p != NULL) {
2620
2620
 
2621
2621
  rsult = NULL;
2622
2622
  if (scrSpec != NULL && scrSpec [0] != '\0') {
2623
 
        q = scrSpec;
2624
 
        while (*q == ' ') {
2625
 
                q++;
2626
 
        }
2627
 
        rsult = Nlm_ParseFontSpecEx(q);
 
2623
      q = scrSpec;
 
2624
      while (*q == ' ') {
 
2625
          q++;
 
2626
      }
 
2627
      rsult = Nlm_ParseFontSpecEx(q);
2628
2628
  }
2629
2629
  prtr = NULL;
2630
2630
  if (prtSpec != NULL && prtSpec [0] != '\0') {
2631
 
        p = prtSpec;
2632
 
        while (*p == ' ') {
2633
 
                p++;
2634
 
        }
2635
 
        prtr = Nlm_ParseFontSpecEx(p);
 
2631
      p = prtSpec;
 
2632
      while (*p == ' ') {
 
2633
          p++;
 
2634
      }
 
2635
      prtr = Nlm_ParseFontSpecEx(p);
2636
2636
    Nlm_AssignPrinterFont (rsult, prtr);
2637
2637
  }
2638
2638
  return rsult;
2644
2644
static Nlm_FontSpec Nlm_commonFontSpec;
2645
2645
extern Nlm_FontSpecPtr Nlm_Helvetica (Nlm_Int2 size, Nlm_Uint1 style)
2646
2646
{
 
2647
#ifdef WIN_MAC_QUARTZ
 
2648
  strncpy(Nlm_commonFontSpec.name, "Helvetica", sizeof(Nlm_commonFontSpec.name));
 
2649
#else
2647
2650
  Nlm_commonFontSpec.name[0] = '\0';
 
2651
#endif
2648
2652
  Nlm_commonFontSpec.size = size;
2649
2653
  Nlm_commonFontSpec.style = style;
2650
2654
  Nlm_commonFontSpec.charset = CHARSET_ANSI;
2655
2659
 
2656
2660
extern Nlm_FontSpecPtr Nlm_Times (Nlm_Int2 size, Nlm_Uint1 style)
2657
2661
{
 
2662
#ifdef WIN_MAC_QUARTZ
 
2663
  strncpy(Nlm_commonFontSpec.name, "Times", sizeof(Nlm_commonFontSpec.name));
 
2664
#else
2658
2665
  Nlm_commonFontSpec.name[0] = '\0';
 
2666
#endif
2659
2667
  Nlm_commonFontSpec.size = size;
2660
2668
  Nlm_commonFontSpec.style = style;
2661
2669
  Nlm_commonFontSpec.charset = CHARSET_ANSI;
2666
2674
 
2667
2675
extern Nlm_FontSpecPtr Nlm_Courier (Nlm_Int2 size, Nlm_Uint1 style)
2668
2676
{
 
2677
#ifdef WIN_MAC_QUARTZ
 
2678
  strncpy(Nlm_commonFontSpec.name, "Courier", sizeof(Nlm_commonFontSpec.name));
 
2679
#else
2669
2680
  Nlm_commonFontSpec.name[0] = '\0';
 
2681
#endif
2670
2682
  Nlm_commonFontSpec.size = size;
2671
2683
  Nlm_commonFontSpec.style = style;
2672
2684
  Nlm_commonFontSpec.charset = CHARSET_ANSI;
2677
2689
 
2678
2690
extern Nlm_FontSpecPtr Nlm_Symbol (Nlm_Int2 size, Nlm_Uint1 style)
2679
2691
{
 
2692
#ifdef WIN_MAC_QUARTZ
 
2693
  strncpy(Nlm_commonFontSpec.name, "Symbol", sizeof(Nlm_commonFontSpec.name));
 
2694
#else
2680
2695
  Nlm_commonFontSpec.name[0] = '\0';
 
2696
#endif
2681
2697
  Nlm_commonFontSpec.size = size;
2682
2698
  Nlm_commonFontSpec.style = style;
2683
2699
  Nlm_commonFontSpec.charset = CHARSET_SYMBOL; /* should be enough */
2857
2873
      Nlm_GetFontData (f, &fdata);
2858
2874
    }
2859
2875
#ifdef WIN_MAC
 
2876
#ifdef WIN_MAC_ATSUI
 
2877
    Nlm_fontInUse = f;
 
2878
#else
2860
2879
    TextFont (fdata.number);
2861
2880
    TextSize (fdata.size);
2862
2881
    TextFace (fdata.style);
2863
2882
#endif
 
2883
#endif
2864
2884
#ifdef WIN_MSWIN
2865
2885
    if (Nlm_currentHDC != NULL) {
2866
2886
      SelectObject (Nlm_currentHDC, fdata.handle);
2905
2925
 
2906
2926
{
2907
2927
#ifdef WIN_MAC
 
2928
#ifdef WIN_MAC_QUARTZ
 
2929
  return Nlm_TextWidth (&ch, 1);
 
2930
#else
2908
2931
  return (CharWidth (ch));
2909
2932
#endif
 
2933
#endif
2910
2934
#ifdef WIN_MSWIN
2911
2935
  Nlm_Char  str [4];
2912
2936
 
2933
2957
 
2934
2958
extern Nlm_Int2 Nlm_TextWidth(const Nlm_Char* text, size_t len)
2935
2959
{
2936
 
  if (text  &&  len) {{
 
2960
  if (text  &&  len) {
2937
2961
#if defined(WIN_MAC)
 
2962
#if defined(WIN_MAC_ATSUI)
 
2963
  OSErr err;
 
2964
  Nlm_PoinT  pt;
 
2965
  CFStringRef cfString;
 
2966
  CFIndex cfsLen;
 
2967
  const UniChar * unicodeString;
 
2968
  ATSUTextLayout layout;
 
2969
  Nlm_FontTool  curStyle;
 
2970
  Rect          tr;
 
2971
  
 
2972
  /* convert the string to Unicode */
 
2973
  cfString = CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingMacRoman);
 
2974
  if (cfString == NULL)
 
2975
    return 0;
 
2976
  cfsLen = CFStringGetLength(cfString);
 
2977
  unicodeString = CFStringGetCharactersPtr(cfString);
 
2978
  if (unicodeString == NULL) {
 
2979
      CFRange range;
 
2980
      static UniChar ucbuf[1024];
 
2981
      
 
2982
      range.location = 0;
 
2983
      range.length = MIN(cfsLen, 1024);
 
2984
      CFStringGetCharacters (cfString, range, ucbuf);
 
2985
      unicodeString = ucbuf;
 
2986
  }
 
2987
 
 
2988
  /* get the current style */
 
2989
  curStyle = Nlm_FontToATSUStyle(Nlm_fontInUse);
 
2990
  
 
2991
  /* create the layout */
 
2992
  err = ATSUCreateTextLayoutWithTextPtr (
 
2993
     unicodeString,
 
2994
     0,
 
2995
     cfsLen,
 
2996
     cfsLen, 
 
2997
     1, 
 
2998
     (unsigned long *)&cfsLen, 
 
2999
     &curStyle, 
 
3000
     &layout
 
3001
  );
 
3002
  /* how big is the text. */
 
3003
  err = ATSUMeasureTextImage(layout, kATSUFromTextBeginning, kATSUToTextEnd, 
 
3004
       0,  0, &tr);
 
3005
 
 
3006
  if (err == noErr)
 
3007
    return (tr.right - tr.left) + 3;
 
3008
#else
2938
3009
    return TextWidth(text, 0, (Nlm_Int2)len);
2939
 
 
 
3010
#endif
2940
3011
#elif defined(WIN_MSWIN)
2941
3012
    SIZE tag;
2942
3013
    if ( Nlm_currentHDC )
2955
3026
#elif defined(WIN_GIF)
2956
3027
    return (Nlm_Int2)(Nlm_curGIFFont->w * len);
2957
3028
#endif
2958
 
  }}
 
3029
  }
2959
3030
 
2960
3031
 return 0;
2961
3032
}
2962
3033
 
 
3034
#if defined(WIN_MAC) && defined(WIN_MAC_ATSUI)
 
3035
static ATSFontMetrics Nlm_CurrentATSUFontMetrics(void)
 
3036
{
 
3037
  Nlm_FontTool curStyle = Nlm_FontToATSUStyle (Nlm_fontInUse);
 
3038
  ATSUFontID fontID = 0;
 
3039
  ByteCount ignoredCount;
 
3040
  
 
3041
  ATSUGetAttribute (curStyle, kATSUFontTag, sizeof (fontID), &fontID, &ignoredCount);
 
3042
  
 
3043
  ATSFontRef font = FMGetATSFontRefFromFont (fontID);
 
3044
  
 
3045
  ATSFontMetrics metrics;
 
3046
  memset (&metrics, 0, sizeof (metrics));
 
3047
  ATSFontGetHorizontalMetrics (font, kATSOptionFlagsDefault, &metrics);
 
3048
  
 
3049
  return metrics;
 
3050
}
 
3051
 
 
3052
static Fixed Nlm_CurrentATSUFontSize(void)
 
3053
{
 
3054
  Nlm_FontTool curStyle = Nlm_FontToATSUStyle (Nlm_fontInUse);
 
3055
  Fixed size = 0;
 
3056
  ByteCount ignoredCount;
 
3057
  
 
3058
  ATSUGetAttribute (curStyle, kATSUSizeTag, sizeof (size), &size, &ignoredCount);
 
3059
  
 
3060
  return size;
 
3061
}
 
3062
#endif
2963
3063
 
2964
3064
extern Nlm_Int2 Nlm_Ascent (void)
2965
3065
 
2966
3066
{
2967
3067
#ifdef WIN_MAC
 
3068
#ifdef WIN_MAC_ATSUI
 
3069
  return ceilf (Nlm_CurrentATSUFontMetrics().ascent * Nlm_CurrentATSUFontSize() / 65536.0);
 
3070
#else
2968
3071
  FontInfo  fontinfo;
2969
3072
 
2970
3073
  GetFontInfo (&fontinfo);
2971
3074
  return (fontinfo.ascent);
2972
3075
#endif
 
3076
#endif
2973
3077
#ifdef WIN_MSWIN
2974
3078
  Nlm_Int2  rsult;
2975
3079
 
2997
3101
 
2998
3102
{
2999
3103
#ifdef WIN_MAC
 
3104
#ifdef WIN_MAC_ATSUI
 
3105
  return ceilf (-Nlm_CurrentATSUFontMetrics().descent * Nlm_CurrentATSUFontSize() / 65536.0);
 
3106
#else
3000
3107
  FontInfo  fontinfo;
3001
3108
 
3002
3109
  GetFontInfo (&fontinfo);
3003
3110
  return (fontinfo.descent);
3004
3111
#endif
 
3112
#endif
3005
3113
#ifdef WIN_MSWIN
3006
3114
  Nlm_Int2  rsult;
3007
3115
 
3029
3137
 
3030
3138
{
3031
3139
#ifdef WIN_MAC
 
3140
#ifdef WIN_MAC_ATSUI
 
3141
  return ceilf (Nlm_CurrentATSUFontMetrics().leading * Nlm_CurrentATSUFontSize() / 65536.0);
 
3142
#else
3032
3143
  FontInfo  fontinfo;
3033
3144
 
3034
3145
  GetFontInfo (&fontinfo);
3035
3146
  return (fontinfo.leading);
3036
3147
#endif
 
3148
#endif
3037
3149
#ifdef WIN_MSWIN
3038
3150
  Nlm_Int2  rsult;
3039
3151
 
3055
3167
 
3056
3168
{
3057
3169
#ifdef WIN_MAC
 
3170
#ifdef WIN_MAC_ATSUI
 
3171
  return Nlm_Ascent() + Nlm_Descent();
 
3172
#else
3058
3173
  FontInfo  fontinfo;
3059
3174
 
3060
3175
  GetFontInfo (&fontinfo);
3061
3176
  return (fontinfo.ascent + fontinfo.descent);
3062
3177
#endif
 
3178
#endif
3063
3179
#ifdef WIN_MSWIN
3064
3180
  Nlm_Int2  rsult;
3065
3181
 
3088
3204
 
3089
3205
{
3090
3206
#ifdef WIN_MAC
 
3207
#ifdef WIN_MAC_ATSUI
 
3208
  return Nlm_Ascent() + Nlm_Descent() + Nlm_Leading();
 
3209
#else
3091
3210
  FontInfo  fontinfo;
3092
3211
 
3093
3212
  GetFontInfo (&fontinfo);
3094
3213
  return (fontinfo.ascent + fontinfo.descent + fontinfo.leading);
3095
3214
#endif
 
3215
#endif
3096
3216
#ifdef WIN_MSWIN
3097
3217
  Nlm_Int2  rsult;
3098
3218
 
3121
3241
 
3122
3242
{
3123
3243
#ifdef WIN_MAC
 
3244
#ifdef WIN_MAC_ATSUI
 
3245
  return ceilf (Nlm_CurrentATSUFontMetrics().maxAdvanceWidth * Nlm_CurrentATSUFontSize() / 65536.0);
 
3246
#else
3124
3247
  FontInfo  fontinfo;
3125
3248
 
3126
3249
  GetFontInfo (&fontinfo);
3127
3250
  return (fontinfo.widMax);
3128
3251
#endif
 
3252
#endif
3129
3253
#ifdef WIN_MSWIN
3130
3254
  Nlm_Int2  rsult;
3131
3255
 
3218
3342
extern void Nlm_SetPen (Nlm_PoinT pt)
3219
3343
{
3220
3344
#ifdef WIN_MAC
3221
 
  MoveTo (pt.x, pt.y);
 
3345
  Nlm_MoveTo (pt.x, pt.y);
3222
3346
#endif
3223
3347
#ifdef WIN_MSWIN
3224
3348
  if (Nlm_currentHDC != NULL) {
3236
3360
extern void Nlm_GetPen (Nlm_PointPtr pt)
3237
3361
 
3238
3362
{
3239
 
#ifdef WIN_MAC
 
3363
#ifdef WIN_MAC_QUARTZ
 
3364
  CGPoint cgp;
 
3365
  
 
3366
  if (pt != NULL) {
 
3367
    cgp = CGContextGetPathCurrentPoint(Nlm_PeekQContext());
 
3368
  }
 
3369
  pt->x = cgp.x;
 
3370
  pt->y = cgp.y;
 
3371
#elif defined(WIN_MAC)
3240
3372
  Nlm_PointTool  ptool;
3241
3373
 
3242
3374
  if (pt != NULL) {
3263
3395
#endif
3264
3396
}
3265
3397
 
 
3398
void Nlm_SetPenWidth(Nlm_Int2 width)
 
3399
{
 
3400
#ifdef WIN_MAC
 
3401
#ifdef WIN_MAC_QUARTZ
 
3402
  CGContextSetLineWidth (Nlm_PeekQContext(), width);
 
3403
#else
 
3404
  PenSize (width, width);
 
3405
#endif
 
3406
#endif
 
3407
}
 
3408
 
3266
3409
extern void Nlm_PaintChar (Nlm_Char ch)
3267
3410
 
3268
3411
{
3269
3412
#ifdef WIN_MAC
 
3413
#ifdef WIN_MAC_QUARTZ
 
3414
  Nlm_PoinT pt;
 
3415
  Nlm_GetPen (& pt);
 
3416
  CGContextShowTextAtPoint(Nlm_PeekQContext(), pt.x, pt.y, & ch, 1);
 
3417
#else
3270
3418
  DrawChar (ch);
3271
3419
#endif
 
3420
#endif
3272
3421
#ifdef WIN_MSWIN
3273
3422
  Nlm_PoinT  pt;
3274
3423
  Nlm_Char   str [2];
3322
3471
  Nlm_PaintString( text );
3323
3472
#endif
3324
3473
}
 
3474
 
 
3475
 
3325
3476
extern void Nlm_PaintString (Nlm_CharPtr text)
3326
3477
{
3327
3478
#ifdef WIN_MAC
 
3479
#ifdef WIN_MAC_ATSUI
 
3480
  OSErr err;
 
3481
  Nlm_PoinT  pt;
 
3482
  CFStringRef cfString;
 
3483
  CFIndex cfsLen;
 
3484
  const UniChar * unicodeString;
 
3485
  ATSUTextLayout layout;
 
3486
  Nlm_FontTool  curStyle;
 
3487
  
 
3488
  /* convert the string to Unicode */
 
3489
  cfString = CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingMacRoman);
 
3490
  if (cfString == NULL)
 
3491
    return;
 
3492
  cfsLen = CFStringGetLength(cfString);
 
3493
  unicodeString = CFStringGetCharactersPtr(cfString);
 
3494
  if (unicodeString == NULL) {
 
3495
      CFRange range;
 
3496
      static UniChar ucbuf[1024];
 
3497
      
 
3498
      range.location = 0;
 
3499
      range.length = MIN(cfsLen, 1024);
 
3500
      CFStringGetCharacters (cfString, range, ucbuf);
 
3501
      unicodeString = ucbuf;
 
3502
  }
 
3503
 
 
3504
  /* get the current style */
 
3505
  curStyle = Nlm_FontToATSUStyle(Nlm_fontInUse);
 
3506
  
 
3507
  /* create the layout */
 
3508
  err = ATSUCreateTextLayoutWithTextPtr (
 
3509
     unicodeString,
 
3510
     0,
 
3511
     cfsLen,
 
3512
     cfsLen, 
 
3513
     1, 
 
3514
     (unsigned long *)&cfsLen, 
 
3515
     &curStyle, 
 
3516
     &layout
 
3517
  );
 
3518
 
 
3519
  /* draw where? */
 
3520
  Nlm_GetPen (&pt);
 
3521
  /* CGContextShowTextAtPoint(Nlm_PeekQContext(), pt.x, pt.y, text, Nlm_StringLen (text)); */
 
3522
  err = ATSUDrawText(layout, kATSUFromTextBeginning, kATSUToTextEnd, 
 
3523
       Long2Fix(pt.x),  Long2Fix(pt.y));
 
3524
  
 
3525
#else
3328
3526
  Nlm_PoinT  pt;
3329
3527
  Nlm_Char   str [256];
3330
3528
 
3339
3537
    Nlm_MoveTo (pt.x, pt.y);
3340
3538
  }
3341
3539
#endif
 
3540
#endif
3342
3541
#ifdef WIN_MSWIN
3343
3542
  Nlm_PoinT pt;
3344
3543
  Nlm_GetPen( &pt );
3370
3569
#endif
3371
3570
}
3372
3571
 
 
3572
 
3373
3573
#ifdef VAR_ARGS
3374
3574
void CDECL Nlm_PaintText (format, va_alist)
3375
3575
  char *format;
3377
3577
#else
3378
3578
void CDECL Nlm_PaintText (char *format, ...)
3379
3579
#endif
3380
 
 
3381
3580
{
3382
3581
#ifdef WIN_MAC
3383
3582
  va_list    args;
3393
3592
    vsprintf(str, format, args);
3394
3593
    va_end(args);
3395
3594
    Nlm_GetPen (&pt);
 
3595
#ifdef WIN_MAC_QUARTZ
 
3596
    CGContextShowTextAtPoint(Nlm_PeekQContext(), pt.x, pt.y, str, Nlm_StringLen (str));
 
3597
#else
3396
3598
    if (Nlm_StringLen (str) > 0) {
3397
3599
      Nlm_CtoPstr (str);
3398
3600
      DrawString ((StringPtr) str);
3399
3601
    }
3400
3602
    pt.y += Nlm_LineHeight ();
3401
3603
    Nlm_MoveTo (pt.x, pt.y);
 
3604
#endif
3402
3605
  }
3403
3606
#endif
3404
3607
#ifdef WIN_MSWIN
3482
3685
 
3483
3686
{
3484
3687
#ifdef WIN_MAC
 
3688
#ifdef WIN_MAC_ATSUI
 
3689
  CFStringRef cfString;
 
3690
  CFIndex cfsLen;
 
3691
  Nlm_RectTool  rtool;
 
3692
  OSStatus    err;
 
3693
  ATSUStyle   aStyle;
 
3694
  TXNTextBoxOptionsData boxOptions;
 
3695
      
 
3696
  if (r != NULL) {
 
3697
    Nlm_EraseRect (r);
 
3698
    if (text != NULL && len > 0) {
 
3699
      cfString = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8 *)text, len, kCFStringEncodingMacRoman, false);
 
3700
      if (cfString == NULL)
 
3701
        return;
 
3702
      cfsLen = CFStringGetLength(cfString);
 
3703
 
 
3704
      Local__RecTToRectTool(r, &rtool);
 
3705
      
 
3706
      boxOptions.optionTags = kTXNSetFlushnessMask;
 
3707
      switch (jst) {
 
3708
        case 'r':
 
3709
          boxOptions.flushness = kATSUEndAlignment;
 
3710
          break;
 
3711
        case 'l':
 
3712
          boxOptions.flushness = kATSUStartAlignment;
 
3713
          break;
 
3714
        case 'c':
 
3715
          boxOptions.flushness = kATSUCenterAlignment;
 
3716
          break;
 
3717
        default:
 
3718
          boxOptions.flushness = kATSUStartAlignment;
 
3719
          break;
 
3720
      }
 
3721
      aStyle = Nlm_FontToATSUStyle(Nlm_fontInUse);  
 
3722
      
 
3723
#ifdef WIN_MAC_QUARTZ
 
3724
// QUARTZ_FIXME: is this stuff necessary?
 
3725
//      boxOptions.optionTags |= kTXNUseCGContextRefMask;
 
3726
//      boxOptions.options = Nlm_PeekQContext();
 
3727
//      CGContextSaveGState(Nlm_PeekQContext());
 
3728
//      /* need to undo the coordinate transforms, otherwise the text comes out upside down. */
 
3729
//      CGContextScaleCTM(Nlm_PeekQContext(), 1.0f, -1.0f);
 
3730
//      {  
 
3731
//        Rect      pBounds;
 
3732
//        int       pHeight;
 
3733
//        GrafPtr   grafptr;
 
3734
//
 
3735
//        GetPort(&grafptr);
 
3736
//        GetPortBounds(grafptr, &pBounds);
 
3737
//        pHeight = pBounds.bottom - pBounds.top;
 
3738
//        CGContextTranslateCTM(Nlm_PeekQContext(), 0, -pHeight);
 
3739
//      }
 
3740
#endif
 
3741
 
 
3742
      err = TXNDrawCFStringTextBox(cfString, &rtool, aStyle, &boxOptions);
 
3743
      CFRelease(cfString);
 
3744
      
 
3745
//#ifdef WIN_MAC_QUARTZ
 
3746
//      CGContextRestoreGState(Nlm_PeekQContext());
 
3747
//#endif
 
3748
    }
 
3749
  }
 
3750
 
 
3751
#else
3485
3752
  Nlm_Int2      delta;
3486
3753
  Nlm_Int2      height;
3487
3754
  Nlm_Int2      just;
3525
3792
    }
3526
3793
  }
3527
3794
#endif
 
3795
#endif
3528
3796
#ifdef WIN_MSWIN
3529
3797
  Nlm_Int2      format;
3530
3798
  Nlm_Int4      oldcolor;
3705
3973
 
3706
3974
{
3707
3975
#ifdef WIN_MAC
 
3976
#ifdef WIN_MAC_QUARTZ
 
3977
  CGContextMoveToPoint(Nlm_PeekQContext(), x, y);
 
3978
#else
3708
3979
  MoveTo (x, y);
3709
3980
#endif
 
3981
#endif
3710
3982
#ifdef WIN_MSWIN
3711
3983
  if (Nlm_currentHDC != NULL) {
3712
3984
    MoveToEx (Nlm_currentHDC, x, y, NULL);
3727
3999
 
3728
4000
{
3729
4001
#ifdef WIN_MAC
 
4002
#ifdef WIN_MAC_QUARTZ
 
4003
  CGContextAddLineToPoint(Nlm_PeekQContext(), x, y);
 
4004
  CGContextStrokePath(Nlm_PeekQContext());
 
4005
  CGContextMoveToPoint(Nlm_PeekQContext(), x, y);
 
4006
#else
3730
4007
  LineTo (x, y);
3731
4008
#endif
 
4009
#endif
3732
4010
#ifdef WIN_MSWIN
3733
4011
  if (Nlm_currentHDC != NULL) {
3734
4012
    LineTo (Nlm_currentHDC, x, y);
3757
4035
extern void Nlm_DrawLine (Nlm_PoinT pt1, Nlm_PoinT pt2)
3758
4036
{
3759
4037
#ifdef WIN_MAC
 
4038
#ifdef WIN_MAC_QUARTZ
 
4039
  CGContextMoveToPoint(Nlm_PeekQContext(), pt1.x, pt1.y);
 
4040
  CGContextAddLineToPoint(Nlm_PeekQContext(), pt2.x, pt2.y);
 
4041
  CGContextStrokePath(Nlm_PeekQContext());
 
4042
#else
3760
4043
  MoveTo (pt1.x, pt1.y);
3761
4044
  LineTo (pt2.x, pt2.y);
3762
4045
#endif
 
4046
#endif
3763
4047
#ifdef WIN_MSWIN
3764
4048
  if (Nlm_currentHDC != NULL) {
3765
4049
    if (pt1.x == pt2.x  &&  pt1.y == pt2.y) {
3865
4149
  Nlm_RgnTool    ntool;
3866
4150
  Nlm_Boolean    rsult;
3867
4151
#ifdef WIN_MAC
 
4152
#ifdef WIN_MAC_QUARTZ
 
4153
  CGPoint        ptool;
 
4154
#else
3868
4155
  Nlm_PointTool  ptool;
3869
4156
#endif
 
4157
#endif
3870
4158
#ifdef WIN_GIF
3871
4159
  Nlm_RecT r;
3872
4160
#endif
3875
4163
  if (rgn != NULL) {
3876
4164
    ntool = (Nlm_RgnTool) rgn;
3877
4165
#ifdef WIN_MAC
 
4166
#ifdef WIN_MAC_QUARTZ
 
4167
    ptool = Nlm_PoinTToCGPoint (pt);
 
4168
    rsult = HIShapeContainsPoint (ntool, &ptool);
 
4169
#else
3878
4170
    Local__PoinTToPointTool (pt, &ptool);
3879
4171
    rsult = PtInRgn (ptool, ntool);
3880
4172
#endif
 
4173
#endif
3881
4174
#ifdef WIN_MSWIN
3882
4175
    rsult = (Nlm_Boolean) PtInRegion (ntool, pt.x, pt.y);
3883
4176
#endif
3957
4250
extern Nlm_Boolean Nlm_SectRect(Nlm_RectPtr src1, Nlm_RectPtr src2,
3958
4251
                                Nlm_RectPtr dst)
3959
4252
{
3960
 
#if defined(WIN_MSWIN) || defined(WIN_MAC)
 
4253
#ifdef WIN_MAC_QUARTZ
 
4254
  CGRect r1 = Nlm_RecTToCGRect (*src1);
 
4255
  CGRect r2 = Nlm_RecTToCGRect (*src2);
 
4256
  CGRect d  = CGRectIntersection (r1, r2);
 
4257
  *dst = Nlm_CGRectToRecT (d);
 
4258
  return !CGRectIsNull (d);
 
4259
#else
 
4260
 
 
4261
#if defined(WIN_MSWIN) || (defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ))
3961
4262
  Nlm_Boolean   rsult;
3962
4263
  Nlm_RectTool  rtool1;
3963
4264
  Nlm_RectTool  rtool2;
3970
4271
  if (!src1  ||  !src2  ||  !dst)
3971
4272
    return FALSE;
3972
4273
 
3973
 
#if defined(WIN_MSWIN) || defined(WIN_MAC)
 
4274
#if defined(WIN_MSWIN) || (defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ))
3974
4275
  Local__RecTToRectTool(src1, &rtool1);
3975
4276
  Local__RecTToRectTool(src2, &rtool2);
3976
4277
#ifdef WIN_MSWIN
3995
4296
      }
3996
4297
    return TRUE;
3997
4298
#endif
 
4299
#endif
3998
4300
}
3999
4301
 
4000
4302
 
4001
4303
extern Nlm_Boolean Nlm_UnionRect(Nlm_RectPtr src1, Nlm_RectPtr src2,
4002
4304
                                 Nlm_RectPtr dst)
4003
4305
{
4004
 
#if defined(WIN_MSWIN) || defined(WIN_MAC)
 
4306
#ifdef WIN_MAC_QUARTZ
 
4307
  CGRect r1 = Nlm_RecTToCGRect (*src1);
 
4308
  CGRect r2 = Nlm_RecTToCGRect (*src2);
 
4309
  CGRect d  = CGRectUnion (r1, r2);
 
4310
  *dst = Nlm_CGRectToRecT (d);
 
4311
  return CGRectIsEmpty (d);
 
4312
#else
 
4313
 
 
4314
#if defined(WIN_MSWIN) || (defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ))
4005
4315
  Nlm_Boolean   rsult;
4006
4316
  Nlm_RectTool  rtool1;
4007
4317
  Nlm_RectTool  rtool2;
4014
4324
  if (!src1  ||  !src2  ||  !dst)
4015
4325
    return FALSE;
4016
4326
 
4017
 
#if defined(WIN_MSWIN) || defined(WIN_MAC)
 
4327
#if defined(WIN_MSWIN) || (defined(WIN_MAC) && !defined(WIN_MAC_QUARTZ))
4018
4328
  Local__RecTToRectTool(src1, &rtool1);
4019
4329
  Local__RecTToRectTool(src2, &rtool2);
4020
4330
#ifdef WIN_MSWIN
4035
4345
  dst->bottom = MAX(rect1.bottom, rect2.bottom);
4036
4346
  return TRUE;
4037
4347
#endif
 
4348
#endif
4038
4349
}
4039
4350
 
4040
4351
 
4072
4383
  Nlm_RgnTool   ntool;
4073
4384
  Nlm_Boolean   rsult;
4074
4385
  Nlm_RectTool  rtool;
 
4386
#ifdef WIN_MAC_QUARTZ
 
4387
  CGRect        rect;
 
4388
#endif
4075
4389
#ifdef WIN_GIF
4076
4390
  Nlm_RecT      rect;
4077
4391
#endif
4081
4395
    Local__RecTToRectTool (r, &rtool);
4082
4396
    ntool = (Nlm_RgnTool) rgn;
4083
4397
#ifdef WIN_MAC
 
4398
#ifdef WIN_MAC_QUARTZ
 
4399
    rect = Nlm_RecTToCGRect (*r);
 
4400
    rsult = HIShapeIntersectsRect (ntool, &rect);
 
4401
#else
4084
4402
    rsult = RectInRgn (&rtool, ntool);
4085
4403
#endif
 
4404
#endif
4086
4405
#ifdef WIN_MSWIN
4087
4406
    rsult = (Nlm_Boolean) RectInRegion (ntool, &rtool);
4088
4407
#endif
4107
4426
  Local__RecTToRectTool(r, &rtool);
4108
4427
    
4109
4428
#ifdef WIN_MAC
 
4429
#ifdef WIN_MAC_QUARTZ
 
4430
  CGRect cgr;
 
4431
  cgr = Nlm_RecTToCGRect(*r);
 
4432
  CGContextSaveGState(Nlm_PeekQContext());
 
4433
  Nlm_White();
 
4434
  CGContextFillRect(Nlm_PeekQContext(), cgr);
 
4435
  CGContextRestoreGState(Nlm_PeekQContext());
 
4436
#else
4110
4437
  EraseRect (&rtool);
4111
4438
#endif
 
4439
#endif
4112
4440
#ifdef WIN_MSWIN
4113
4441
  if (Nlm_currentHDC  &&  Nlm_currentHWnd) {
4114
4442
    Nlm_Int4 bkColor    = GetBkColor (Nlm_currentHDC);
4142
4470
 
4143
4471
{
4144
4472
#ifdef WIN_MAC
 
4473
#ifdef WIN_MAC_QUARTZ
 
4474
  CGRect rtool;
 
4475
  rtool = Nlm_RecTToCGRect(*r);
 
4476
  CGContextStrokeRect(Nlm_PeekQContext(), rtool);
 
4477
#else
4145
4478
  Nlm_RectTool  rtool;
4146
4479
 
4147
4480
  if (r != NULL) {
4155
4488
    FrameRect (&rtool);
4156
4489
  }
4157
4490
#endif
 
4491
#endif
4158
4492
#ifdef WIN_MSWIN
4159
4493
  HBRUSH        oldBrush;
4160
4494
  POINT         pos;
4210
4544
extern void Nlm_PaintRect(Nlm_RectPtr r)
4211
4545
 
4212
4546
{
 
4547
#ifndef WIN_MAC_QUARTZ
4213
4548
  Nlm_RectTool rtool;
4214
4549
  if ( !r )
4215
4550
    return;
4216
4551
  Local__RecTToRectTool(r, &rtool);
4217
 
 
4218
 
#if defined(WIN_MAC)
 
4552
#endif
 
4553
  
 
4554
#ifdef WIN_MAC_QUARTZ
 
4555
  CGRect cgr;
 
4556
  cgr = Nlm_RecTToCGRect(*r);
 
4557
  CGContextFillRect(Nlm_PeekQContext(), cgr);
 
4558
#elif defined(WIN_MAC)
4219
4559
  if (rtool.right == rtool.left) {
4220
4560
    rtool.right = rtool.left + 1;
4221
4561
  }
4257
4597
    return;
4258
4598
 
4259
4599
#ifdef WIN_MAC
 
4600
#ifdef WIN_MAC_QUARTZ
 
4601
  /* ASSERT(false); /* Can't invert rectangles in Quartz */
 
4602
#else
4260
4603
  Local__RecTToRectTool (r, &rtool);
4261
4604
  InvertRect (&rtool);
4262
4605
#endif
 
4606
#endif
4263
4607
#ifdef WIN_MSWIN
4264
4608
  if (Nlm_currentHDC == NULL)
4265
4609
    return;
4292
4636
 
4293
4637
  if (r != NULL) {
4294
4638
    Local__RecTToRectTool (r, &rtool);
 
4639
#ifdef WIN_MAC_QUARTZ
 
4640
// QUARTZ_FIXME: might want to do a little more than this
 
4641
    HIViewSetNeedsDisplay (HIViewGetRoot (Nlm_QWindow), 1);
 
4642
#else
4295
4643
    ScrollRect (&rtool, dx, dy, (Nlm_RgnTool) Nlm_scrollRgn);
4296
4644
    InvalRgn ((Nlm_RgnTool) Nlm_scrollRgn);
 
4645
#endif
4297
4646
  }
4298
4647
#endif
4299
4648
#ifdef WIN_MSWIN
4407
4756
#endif
4408
4757
}
4409
4758
 
 
4759
#ifdef WIN_MAC_QUARTZ
 
4760
 
 
4761
static void Nlm_addOvalToPath(CGContextRef context, CGRect r) 
 
4762
{     
 
4763
  CGAffineTransform matrix;    
 
4764
  CGContextSaveGState(context);   
 
4765
  matrix = CGAffineTransformMake((r.size.width)/2, 0,                                     
 
4766
    0, (r.size.height)/2,                                    
 
4767
    r.origin.x + (r.size.width)/2,                                    
 
4768
    r.origin.y + (r.size.height)/2);
 
4769
  CGContextConcatCTM(context, matrix);  
 
4770
  CGContextBeginPath(context);
 
4771
  CGContextAddArc(context, 0, 0, 1, 0, 2*pi, true);
 
4772
  CGContextRestoreGState(context);
 
4773
}
 
4774
#endif
 
4775
 
4410
4776
extern void Nlm_EraseOval (Nlm_RectPtr r)
4411
4777
{
4412
4778
  Nlm_RectTool rtool;
4415
4781
  Local__RecTToRectTool(r, &rtool);
4416
4782
 
4417
4783
#if   defined(WIN_MAC)
 
4784
#if defined(WIN_MAC_QUARTZ)
 
4785
  {
 
4786
  CGRect cgr;
 
4787
  cgr = Nlm_RecTToCGRect(*r);
 
4788
  Nlm_addOvalToPath(Nlm_PeekQContext(), cgr);
 
4789
  }
 
4790
  CGContextSaveGState(Nlm_PeekQContext());
 
4791
  Nlm_White();
 
4792
  CGContextFillPath(Nlm_PeekQContext());
 
4793
  CGContextRestoreGState(Nlm_PeekQContext());
 
4794
#else
4418
4795
  EraseOval(&rtool);
4419
 
 
 
4796
#endif
4420
4797
#elif defined(WIN_MSWIN)
4421
4798
  if (Nlm_currentHDC  &&  Nlm_currentHWnd) {
4422
4799
    HPEN   xPen   = SelectObject(Nlm_currentHDC, GetStockObject(NULL_PEN));
4459
4836
  Local__RecTToRectTool(r, &rtool);
4460
4837
 
4461
4838
#if   defined(WIN_MAC)
 
4839
#if defined(WIN_MAC_QUARTZ)
 
4840
  {
 
4841
  CGRect cgr;
 
4842
  cgr = Nlm_RecTToCGRect(*r);
 
4843
  Nlm_addOvalToPath(Nlm_PeekQContext(), cgr);
 
4844
  }
 
4845
  CGContextStrokePath(Nlm_PeekQContext());
 
4846
#else
4462
4847
  FrameOval(&rtool);
4463
 
 
 
4848
#endif
4464
4849
#elif defined(WIN_MSWIN)
4465
4850
  if ( Nlm_currentHDC ) {
4466
4851
    HBRUSH xBrush = SelectObject(Nlm_currentHDC, GetStockObject(NULL_BRUSH));
4492
4877
  Local__RecTToRectTool(r, &rtool);
4493
4878
 
4494
4879
#if   defined(WIN_MAC)
 
4880
#if defined(WIN_MAC_QUARTZ) 
 
4881
  {
 
4882
  CGRect cgr;
 
4883
  cgr = Nlm_RecTToCGRect(*r);
 
4884
  Nlm_addOvalToPath(Nlm_PeekQContext(), cgr);
 
4885
  }
 
4886
  CGContextFillPath(Nlm_PeekQContext());
 
4887
#else
4495
4888
  PaintOval(&rtool);
4496
4889
 
 
4890
#endif
4497
4891
#elif defined(WIN_MSWIN)
4498
4892
  if ( Nlm_currentHDC ) {
4499
4893
    HPEN xPen = SelectObject(Nlm_currentHDC, GetStockObject(NULL_PEN));
4527
4921
  Local__RecTToRectTool(r, &rtool);
4528
4922
 
4529
4923
#if   defined(WIN_MAC)
 
4924
#ifdef WIN_MAC_QUARTZ
 
4925
/* QUART_FIXME: can't invert, what to do? */
 
4926
  Nlm_PaintOval (r);
 
4927
#else
4530
4928
  InvertOval (&rtool);
 
4929
#endif
4531
4930
 
4532
4931
#elif defined(WIN_MSWIN)
4533
4932
  if ( Nlm_currentHDC ) {
4573
4972
}
4574
4973
 
4575
4974
 
 
4975
#ifdef WIN_MAC_QUARTZ
 
4976
static void addRoundedRectToPath(CGContextRef context, CGRect rect, 
 
4977
  float ovalWidth,float ovalHeight) 
 
4978
{     
 
4979
  float fw, fh;    
 
4980
  if (ovalWidth == 0 || ovalHeight == 0) {          
 
4981
    CGContextAddRect(context, rect);         
 
4982
    return;     
 
4983
  }    
 
4984
  CGContextSaveGState(context);     
 
4985
  CGContextTranslateCTM (context, CGRectGetMinX(rect),                           
 
4986
  CGRectGetMinY(rect));    
 
4987
  CGContextScaleCTM (context, ovalWidth, ovalHeight);     
 
4988
  fw = CGRectGetWidth (rect) / ovalWidth;     
 
4989
  fh = CGRectGetHeight (rect) / ovalHeight;     
 
4990
  CGContextMoveToPoint(context, fw, fh/2);      
 
4991
  CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);     
 
4992
  CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);
 
4993
  CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);    
 
4994
  CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1);      
 
4995
  CGContextClosePath(context);     
 
4996
  CGContextRestoreGState(context);  
 
4997
 
4998
#endif
 
4999
 
4576
5000
extern void Nlm_EraseRoundRect(Nlm_RectPtr r, Nlm_Int2 ovlWid, Nlm_Int2 ovlHgt)
4577
5001
{
4578
5002
  Nlm_RectTool rtool;
4582
5006
  s_AdjustRoundRect(r, &ovlWid, &ovlHgt);
4583
5007
 
4584
5008
#if defined(WIN_MAC)
 
5009
#if defined(WIN_MAC_QUARTZ)
 
5010
  {
 
5011
  CGRect cgr;
 
5012
  cgr = Nlm_RecTToCGRect(*r);
 
5013
  addRoundedRectToPath(Nlm_PeekQContext(), cgr, ovlWid, ovlHgt);
 
5014
  }
 
5015
  CGContextSaveGState(Nlm_PeekQContext());
 
5016
  Nlm_White();
 
5017
  CGContextFillPath(Nlm_PeekQContext());
 
5018
  CGContextRestoreGState(Nlm_PeekQContext());
 
5019
#else
4585
5020
  EraseRoundRect(&rtool, ovlWid, ovlHgt);
4586
 
 
 
5021
#endif
4587
5022
#elif defined(WIN_MSWIN)
4588
5023
  if (Nlm_currentHDC  &&  Nlm_currentHWnd) {
4589
5024
    HPEN   xPen   = SelectObject(Nlm_currentHDC, GetStockObject(NULL_PEN));
4630
5065
  s_AdjustRoundRect(r, &ovlWid, &ovlHgt);
4631
5066
 
4632
5067
#if   defined(WIN_MAC)
 
5068
#if defined(WIN_MAC_QUARTZ)
 
5069
  {
 
5070
  CGRect cgr;
 
5071
  cgr = Nlm_RecTToCGRect(*r);
 
5072
  addRoundedRectToPath(Nlm_PeekQContext(), cgr, ovlWid, ovlHgt);
 
5073
  }
 
5074
  CGContextStrokePath(Nlm_PeekQContext());
 
5075
#else
4633
5076
  FrameRoundRect(&rtool, ovlWid, ovlHgt);
4634
 
 
 
5077
#endif
4635
5078
#elif defined(WIN_MSWIN)
4636
5079
  if ( Nlm_currentHDC ) {
4637
5080
    HBRUSH xBrush = SelectObject(Nlm_currentHDC, GetStockObject(NULL_BRUSH));
4668
5111
  s_AdjustRoundRect(r, &ovlWid, &ovlHgt);
4669
5112
 
4670
5113
#if   defined(WIN_MAC)
 
5114
#if defined(WIN_MAC_QUARTZ)
 
5115
  {
 
5116
  CGRect cgr;
 
5117
  cgr = Nlm_RecTToCGRect(*r);
 
5118
  addRoundedRectToPath(Nlm_PeekQContext(), cgr, ovlWid, ovlHgt);
 
5119
  }
 
5120
  CGContextFillPath(Nlm_PeekQContext());
 
5121
#else
4671
5122
  PaintRoundRect(&rtool, ovlWid, ovlHgt);
4672
 
 
 
5123
#endif
4673
5124
#elif defined(WIN_MSWIN)
4674
5125
  if ( Nlm_currentHDC ) {
4675
5126
    HPEN xPen = SelectObject(Nlm_currentHDC, GetStockObject(NULL_PEN));
4707
5158
  s_AdjustRoundRect(r, &ovlWid, &ovlHgt);
4708
5159
 
4709
5160
#if   defined(WIN_MAC)
 
5161
#ifdef WIN_MAC_QUARTZ
 
5162
/* QUARTZ_FIXME: can't invert, what to do? */
 
5163
  Nlm_PaintRoundRect (r, ovlWid, ovlHgt);
 
5164
#else
4710
5165
  InvertRoundRect (&rtool, ovlWid, ovlHgt);
 
5166
#endif
4711
5167
 
4712
5168
#elif defined(WIN_MSWIN)
4713
5169
  if ( Nlm_currentHDC ) {
4773
5229
#endif
4774
5230
 
4775
5231
 
 
5232
#ifdef WIN_MAC_QUARTZ
 
5233
/*
 
5234
static void pathForArc (CGContextRef context, CGRect r,                      
 
5235
                int startAngle, int arcAngle) 
 
5236
{
 
5237
  float start, end;     
 
5238
  CGAffineTransform matrix;
 
5239
  CGContextSaveGState(context);
 
5240
  matrix = CGAffineTransformMake(r.size.width/2, 0,                                     
 
5241
                                0, r.size.height/2,                                    
 
5242
                                r.origin.x + r.size.width/2,                                   
 
5243
                                r.origin.y + r.size.height/2);
 
5244
  CGContextConcatCTM(context, matrix);
 
5245
  if (arcAngle > 0) {          
 
5246
    start = (90 - startAngle - arcAngle) * M_PI / 180;         
 
5247
    end = (90 - startAngle) * M_PI / 180;     
 
5248
  } else {         
 
5249
    start = (90 - startAngle) * M_PI / 180;         
 
5250
    end = (90 - startAngle - arcAngle) * M_PI / 180;     
 
5251
  } 
 
5252
  CGContextAddArc (context, 0, 0, 1, start, end, false);   
 
5253
  CGContextRestoreGState(context);  
 
5254
}
 
5255
*/
 
5256
 
 
5257
static void pathForArc (CGContextRef context, CGRect r,   
 
5258
CGPoint startPt, CGPoint endPt) 
 
5259
{
 
5260
  float start, end;     
 
5261
  CGAffineTransform matrix, invMatrix;
 
5262
  CGContextSaveGState(context);
 
5263
  matrix = CGAffineTransformMake(r.size.width/2, 0,                                     
 
5264
                                0, r.size.height/2,                                    
 
5265
                                r.origin.x + r.size.width/2,                                   
 
5266
                                r.origin.y + r.size.height/2);
 
5267
  CGContextConcatCTM(context, matrix);
 
5268
                                
 
5269
  invMatrix = CGAffineTransformInvert(matrix);
 
5270
  startPt = CGPointApplyAffineTransform(startPt, invMatrix);
 
5271
  endPt = CGPointApplyAffineTransform(endPt, invMatrix);
 
5272
  start = atan2(startPt.y, startPt.x);
 
5273
  end   = atan2(  endPt.y,   endPt.x);
 
5274
    
 
5275
  
 
5276
  CGContextAddArc (context, 0, 0, 1, start, end, 0);   
 
5277
  CGContextRestoreGState(context);  
 
5278
}
 
5279
 
 
5280
#endif
 
5281
 
 
5282
 
4776
5283
extern void Nlm_EraseArc(Nlm_RectPtr r, Nlm_PoinT start, Nlm_PoinT end)
4777
5284
{
4778
5285
  Nlm_RectTool rtool;
4782
5289
 
4783
5290
#if   defined(WIN_MAC)
4784
5291
  {{
 
5292
#if   defined(WIN_MAC_QUARTZ)
 
5293
    CGRect  cgr;
 
5294
    CGPoint startPt;
 
5295
    CGPoint endPt;
 
5296
    
 
5297
    cgr = Nlm_RecTToCGRect(*r);
 
5298
    startPt = Nlm_PoinTToCGPoint(start);
 
5299
    endPt = Nlm_PoinTToCGPoint(end);
 
5300
    Nlm_MoveTo((r->right + r->left)/2, (r->top + r->bottom)/2);
 
5301
    pathForArc (Nlm_PeekQContext(), cgr, startPt, endPt);
 
5302
    
 
5303
    CGContextSaveGState(Nlm_PeekQContext());
 
5304
    Nlm_White();
 
5305
    CGContextFillPath(Nlm_PeekQContext());
 
5306
    CGContextRestoreGState(Nlm_PeekQContext());
 
5307
#else
4785
5308
    Nlm_Int2      angle1;
4786
5309
    Nlm_Int2      angle2;
4787
5310
    Nlm_Int2      arcAngle;
4800
5323
      arcAngle = 360 - angle1 + angle2;
4801
5324
 
4802
5325
    EraseArc(&rtool, angle1, arcAngle);
 
5326
#endif
4803
5327
  }}
4804
5328
 
4805
5329
#elif defined(WIN_MSWIN)
4850
5374
 
4851
5375
#if   defined(WIN_MAC)
4852
5376
  {{
 
5377
#if   defined(WIN_MAC_QUARTZ)
 
5378
    CGRect  cgr;
 
5379
    CGPoint startPt;
 
5380
    CGPoint endPt;
 
5381
    
 
5382
    cgr = Nlm_RecTToCGRect(*r);
 
5383
    startPt = Nlm_PoinTToCGPoint(start);
 
5384
    endPt = Nlm_PoinTToCGPoint(end);
 
5385
    pathForArc (Nlm_PeekQContext(), cgr, startPt, endPt);
 
5386
    CGContextStrokePath(Nlm_PeekQContext());
 
5387
#else
4853
5388
    Nlm_Int2      angle1;
4854
5389
    Nlm_Int2      angle2;
4855
5390
    Nlm_Int2      arcAngle;
4866
5401
      arcAngle = 360 - angle1 + angle2;
4867
5402
    }
4868
5403
    FrameArc (&rtool, angle1, arcAngle);
 
5404
#endif
4869
5405
  }}
4870
5406
 
4871
5407
#elif defined(WIN_MSWIN)
4909
5445
 
4910
5446
#if   defined(WIN_MAC)
4911
5447
  {{
 
5448
#if   defined(WIN_MAC_QUARTZ)
 
5449
    CGRect  cgr;
 
5450
    CGPoint startPt;
 
5451
    CGPoint endPt;
 
5452
    
 
5453
    cgr = Nlm_RecTToCGRect(*r);
 
5454
    startPt = Nlm_PoinTToCGPoint(start);
 
5455
    endPt = Nlm_PoinTToCGPoint(end);
 
5456
    Nlm_MoveTo((r->right + r->left)/2, (r->top + r->bottom)/2);
 
5457
    pathForArc (Nlm_PeekQContext(), cgr, startPt, endPt);
 
5458
    CGContextFillPath(Nlm_PeekQContext());
 
5459
#else
4912
5460
    Nlm_Int2       angle1;
4913
5461
    Nlm_Int2       angle2;
4914
5462
    Nlm_Int2       arcAngle;
4925
5473
      arcAngle = 360 - angle1 + angle2;
4926
5474
 
4927
5475
    PaintArc(&rtool, angle1, arcAngle);
 
5476
#endif
4928
5477
  }}
4929
5478
 
4930
5479
#elif defined(WIN_MSWIN)
4974
5523
  Local__RecTToRectTool(r, &rtool);
4975
5524
 
4976
5525
#if   defined(WIN_MAC)
 
5526
#ifdef WIN_MAC_QUARTZ
 
5527
/* QUARTZ_FIXME: can't invert, what to do? */
 
5528
  Nlm_PaintArc (r, start, end);
 
5529
#else
4977
5530
  {{
4978
5531
    Nlm_Int2      angle1;
4979
5532
    Nlm_Int2      angle2;
4994
5547
 
4995
5548
    InvertArc(&rtool, angle1, arcAngle);
4996
5549
  }}
 
5550
#endif
4997
5551
 
4998
5552
#elif defined(WIN_MSWIN)
4999
5553
  if ( Nlm_currentHDC ) {
5134
5688
 */
5135
5689
 
5136
5690
#ifdef WIN_MAC
 
5691
#ifdef WIN_MAC_QUARTZ
 
5692
static void Nlm_CreatePoly (Nlm_Int2 num, Nlm_PointPtr pts)
 
5693
{
 
5694
  Nlm_PoinT   firstPt;
 
5695
  Nlm_Int2    i;
 
5696
  Nlm_PoinT   pt;
 
5697
 
 
5698
  if (pts != NULL && num > 0) {
 
5699
    firstPt = pts [0];
 
5700
    CGContextMoveToPoint(Nlm_PeekQContext(), (float) firstPt.x, (float) firstPt.y);
 
5701
    for (i = 1; i < num; i++) {
 
5702
      pt = pts [i];
 
5703
      CGContextAddLineToPoint(Nlm_PeekQContext(), (float) pt.x, (float) pt.y);
 
5704
    }
 
5705
    if (! Nlm_EqualPt (pt, firstPt)) {
 
5706
      CGContextClosePath(Nlm_PeekQContext());
 
5707
    }
 
5708
  }  
 
5709
}
 
5710
 
 
5711
#else
5137
5712
static PolyHandle Nlm_CreatePoly (Nlm_Int2 num, Nlm_PointPtr pts)
5138
5713
 
5139
5714
{
5167
5742
  }
5168
5743
}
5169
5744
#endif
 
5745
#endif
5170
5746
 
5171
5747
#ifdef WIN_MSWIN
5172
5748
static LPPOINT Nlm_CreatePoly (Nlm_Int2 num, Nlm_PointPtr pts)
5253
5829
{
5254
5830
  if (pts != NULL && num > 1) {
5255
5831
#ifdef WIN_MAC
 
5832
#ifdef WIN_MAC_QUARTZ
 
5833
  Nlm_CreatePoly (num, pts);
 
5834
  CGContextSaveGState(Nlm_PeekQContext());
 
5835
  Nlm_White();
 
5836
  CGContextEOFillPath(Nlm_PeekQContext());
 
5837
  CGContextRestoreGState(Nlm_PeekQContext());
 
5838
#else
5256
5839
  PolyHandle   ply;
5257
5840
 
5258
5841
  ply = Nlm_CreatePoly (num, pts);
5261
5844
  }
5262
5845
  Nlm_DestroyPoly (ply);
5263
5846
#endif
 
5847
#endif
5264
5848
#ifdef WIN_MSWIN
5265
5849
#endif
5266
5850
#ifdef WIN_X
5275
5859
{
5276
5860
  if (pts != NULL && num > 1) {
5277
5861
#ifdef WIN_MAC
 
5862
#ifdef WIN_MAC_QUARTZ
 
5863
  Nlm_CreatePoly (num, pts);
 
5864
  CGContextStrokePath(Nlm_PeekQContext());
 
5865
#else
5278
5866
  PolyHandle   ply;
5279
5867
 
5280
5868
  ply = Nlm_CreatePoly (num, pts);
5283
5871
  }
5284
5872
  Nlm_DestroyPoly (ply);
5285
5873
#endif
 
5874
#endif
5286
5875
#ifdef WIN_MSWIN
5287
5876
  LPPOINT  ply;
5288
5877
 
5331
5920
{
5332
5921
  if (pts != NULL && num > 1) {
5333
5922
#ifdef WIN_MAC
 
5923
#ifdef WIN_MAC_QUARTZ
 
5924
  Nlm_CreatePoly (num, pts);
 
5925
  CGContextEOFillPath(Nlm_PeekQContext());
 
5926
#else
5334
5927
  PolyHandle   ply;
5335
5928
 
5336
5929
  ply = Nlm_CreatePoly (num, pts);
5339
5932
  }
5340
5933
  Nlm_DestroyPoly (ply);
5341
5934
#endif
 
5935
#endif
5342
5936
#ifdef WIN_MSWIN
5343
5937
  LPPOINT  ply;
5344
5938
 
5402
5996
{
5403
5997
  if (pts != NULL && num > 1) {
5404
5998
#ifdef WIN_MAC
 
5999
#ifdef WIN_MAC_QUARTZ
 
6000
#else
5405
6001
  PolyHandle   ply;
5406
6002
 
5407
6003
  ply = Nlm_CreatePoly (num, pts);
5410
6006
  }
5411
6007
  Nlm_DestroyPoly (ply);
5412
6008
#endif
 
6009
#endif
5413
6010
#ifdef WIN_MSWIN
5414
6011
#endif
5415
6012
#ifdef WIN_X
5425
6022
  Nlm_RgnTool  ntool;
5426
6023
 
5427
6024
#ifdef WIN_MAC
 
6025
#ifdef WIN_MAC_QUARTZ
 
6026
  ntool = HIShapeCreateMutable();
 
6027
#else
5428
6028
  ntool = NewRgn ();
5429
6029
#endif
 
6030
#endif
5430
6031
#ifdef WIN_MSWIN
5431
6032
  ntool = CreateRectRgn (0, 0, 0, 0);
5432
6033
#endif
5447
6048
  if (rgn != NULL) {
5448
6049
    ntool = (Nlm_RgnTool) rgn;
5449
6050
#ifdef WIN_MAC
 
6051
#ifdef WIN_MAC_QUARTZ
 
6052
    CFRelease (ntool);
 
6053
#else
5450
6054
    DisposeRgn (ntool);
5451
6055
#endif
 
6056
#endif
5452
6057
#ifdef WIN_MSWIN
5453
6058
    DeleteObject (ntool);
5454
6059
#endif
5473
6078
  if (rgn != NULL) {
5474
6079
    ntool = (Nlm_RgnTool) rgn;
5475
6080
#ifdef WIN_MAC
 
6081
#ifdef WIN_MAC_QUARTZ
 
6082
    HIShapeSetEmpty (ntool);
 
6083
#else
5476
6084
    SetEmptyRgn (ntool);
5477
6085
#endif
 
6086
#endif
5478
6087
#ifdef WIN_MSWIN
5479
6088
    temp = CreateRectRgn (0, 0, 0, 0);
5480
6089
    CombineRgn (ntool, temp, temp, RGN_COPY);
5503
6112
  if (rgn != NULL) {
5504
6113
    ntool = (Nlm_RgnTool) rgn;
5505
6114
#ifdef WIN_MAC
 
6115
#ifdef WIN_MAC_QUARTZ
 
6116
    HIShapeSetEmpty (ntool);
 
6117
    
 
6118
    CGRect r = CGRectMake (lf, tp, rt - lf, bt - tp);
 
6119
    HIShapeRef tempShape = HIShapeCreateWithRect (&r);
 
6120
    HIShapeUnion (tempShape, ntool, ntool);
 
6121
    CFRelease (tempShape);
 
6122
#else
5506
6123
    SetRectRgn (ntool, lf, tp, rt, bt);
5507
6124
#endif
 
6125
#endif
5508
6126
#ifdef WIN_MSWIN
5509
6127
    SetRectRgn (ntool, lf, tp, rt, bt);
5510
6128
#endif
5531
6149
  if (rgn != NULL) {
5532
6150
    ntool = (Nlm_RgnTool) rgn;
5533
6151
#ifdef WIN_MAC
 
6152
#ifdef WIN_MAC_QUARTZ
 
6153
    HIShapeOffset (ntool, dx, dy);
 
6154
#else
5534
6155
    OffsetRgn (ntool, dx, dy);
5535
6156
#endif
 
6157
#endif
5536
6158
#ifdef WIN_MSWIN
5537
6159
    OffsetRgn (ntool, dx, dy);
5538
6160
#endif
5567
6189
    ntool2 = (Nlm_RgnTool) src2;
5568
6190
    ntool3 = (Nlm_RgnTool) dst;
5569
6191
#ifdef WIN_MAC
 
6192
#ifdef WIN_MAC_QUARTZ
 
6193
    HIShapeIntersect (ntool1, ntool2, ntool3);
 
6194
#else
5570
6195
    SectRgn (ntool1, ntool2, ntool3);
5571
6196
#endif
 
6197
#endif
5572
6198
#ifdef WIN_MSWIN
5573
6199
    CombineRgn (ntool3, ntool1, ntool2, RGN_AND);
5574
6200
#endif
5607
6233
    ntool2 = (Nlm_RgnTool) src2;
5608
6234
    ntool3 = (Nlm_RgnTool) dst;
5609
6235
#ifdef WIN_MAC
 
6236
#ifdef WIN_MAC_QUARTZ
 
6237
    HIShapeUnion( ntool1, ntool2, ntool3);
 
6238
#else
5610
6239
    UnionRgn (ntool1, ntool2, ntool3);
5611
6240
#endif
 
6241
#endif
5612
6242
#ifdef WIN_MSWIN
5613
6243
    CombineRgn (ntool3, ntool1, ntool2, RGN_OR);
5614
6244
#endif
5642
6272
    ntool2 = (Nlm_RgnTool) src2;
5643
6273
    ntool3 = (Nlm_RgnTool) dst;
5644
6274
#ifdef WIN_MAC
 
6275
#ifdef WIN_MAC_QUARTZ
 
6276
    HIShapeDifference (ntool1, ntool2, ntool3);
 
6277
#else
5645
6278
    DiffRgn (ntool1, ntool2, ntool3);
5646
6279
#endif
 
6280
#endif
5647
6281
#ifdef WIN_MSWIN
5648
6282
    CombineRgn (ntool3, ntool1, ntool2, RGN_DIFF);
5649
6283
#endif
5659
6293
extern void Nlm_XorRgn (Nlm_RegioN src1, Nlm_RegioN src2, Nlm_RegioN dst)
5660
6294
 
5661
6295
{
 
6296
#ifdef WIN_MAC_QUARTZ
 
6297
/* this is actually a general solution, but less efficient
 
6298
   Quartz has no choice but to use it since HIShape does not support
 
6299
   the xor operation natively
 
6300
   
 
6301
   xor is equivalent to the union minus the intersection, so we do that */
 
6302
 
 
6303
  Nlm_RegioN   sum = Nlm_CreateRgn();
 
6304
  Nlm_RegioN   intersection = Nlm_CreateRgn();
 
6305
  
 
6306
  Nlm_UnionRgn (src1, src2, sum);
 
6307
  Nlm_SectRgn (src1, src2, intersection);
 
6308
  Nlm_DiffRgn (sum, intersection, dst);
 
6309
  
 
6310
  Nlm_DestroyRgn (sum);
 
6311
  Nlm_DestroyRgn (intersection);
 
6312
#else
 
6313
  
5662
6314
  Nlm_RgnTool  ntool1;
5663
6315
  Nlm_RgnTool  ntool2;
5664
6316
  Nlm_RgnTool  ntool3;
5683
6335
    XDestroyRegion (temp);
5684
6336
#endif
5685
6337
  }
 
6338
#endif
5686
6339
}
5687
6340
 
5688
6341
extern Nlm_Boolean Nlm_EqualRgn (Nlm_RegioN rgn1, Nlm_RegioN rgn2)
5697
6350
    ntool1 = (Nlm_RgnTool) rgn1;
5698
6351
    ntool2 = (Nlm_RgnTool) rgn2;
5699
6352
#ifdef WIN_MAC
 
6353
#ifdef WIN_MAC_QUARTZ
 
6354
    /* HIShapeRefs are CFTypeRefs so we can use CFEqual */
 
6355
    rsult = CFEqual (ntool1, ntool2);
 
6356
#else
5700
6357
    rsult = EqualRgn (ntool1, ntool2);
5701
6358
#endif
 
6359
#endif
5702
6360
#ifdef WIN_MSWIN
5703
6361
    rsult = (Nlm_Boolean) EqualRgn (ntool1, ntool2);
5704
6362
#endif
5722
6380
  if (rgn != NULL) {
5723
6381
    ntool = (Nlm_RgnTool) rgn;
5724
6382
#ifdef WIN_MAC
 
6383
#ifdef WIN_MAC_QUARTZ
 
6384
    rsult = HIShapeIsEmpty (ntool);
 
6385
#else
5725
6386
    rsult = EmptyRgn (ntool);
5726
6387
#endif
 
6388
#endif
5727
6389
#ifdef WIN_MSWIN
5728
6390
    rsult = (Nlm_Boolean) (GetRgnBox (ntool, &rtool) == NULLREGION);
5729
6391
#endif
5742
6404
 
5743
6405
  if (rgn != NULL) {
5744
6406
    ntool = (Nlm_RgnTool) rgn;
 
6407
#ifdef WIN_MAC_QUARTZ
 
6408
    HIShapeReplacePathInCGContext (ntool, Nlm_PeekQContext());
 
6409
    
 
6410
    Nlm_SelectQuartzColor (Nlm_QuartzBackColor);
 
6411
    CGContextFillPath (Nlm_PeekQContext());
 
6412
    Nlm_SelectQuartzColor (Nlm_QuartzForeColor);
 
6413
#else
5745
6414
    EraseRgn (ntool);
 
6415
#endif
5746
6416
  }
5747
6417
#endif
5748
6418
#ifdef WIN_MSWIN
5765
6435
 
5766
6436
  if (rgn != NULL) {
5767
6437
    ntool = (Nlm_RgnTool) rgn;
 
6438
#ifdef WIN_MAC_QUARTZ
 
6439
    HIShapeReplacePathInCGContext (ntool, Nlm_PeekQContext());
 
6440
    CGContextStrokePath (Nlm_PeekQContext());
 
6441
#else
5768
6442
    FrameRgn (ntool);
 
6443
#endif
5769
6444
  }
5770
6445
#endif
5771
6446
#ifdef WIN_MSWIN
5788
6463
 
5789
6464
  if (rgn != NULL) {
5790
6465
    ntool = (Nlm_RgnTool) rgn;
 
6466
#ifdef WIN_MAC_QUARTZ
 
6467
    HIShapeReplacePathInCGContext (ntool, Nlm_PeekQContext());
 
6468
    CGContextFillPath (Nlm_PeekQContext());
 
6469
#else
5791
6470
    PaintRgn (ntool);
 
6471
#endif
5792
6472
  }
5793
6473
#endif
5794
6474
#ifdef WIN_MSWIN
5816
6496
 
5817
6497
  if (rgn != NULL) {
5818
6498
    ntool = (Nlm_RgnTool) rgn;
 
6499
#ifdef WIN_MAC_QUARTZ
 
6500
// QUARTZ_FIXME: this operation does not make sense in quartz, what to do?
 
6501
#else
5819
6502
    InvertRgn (ntool);
 
6503
#endif
5820
6504
  }
5821
6505
#endif
5822
6506
#ifdef WIN_MSWIN
5839
6523
 
5840
6524
  if (r != NULL) {
5841
6525
    Local__RecTToRectTool (r, &rtool);
 
6526
#ifdef WIN_MAC_QUARTZ
 
6527
    if (Nlm_PeekQContext())
 
6528
    {
 
6529
      CGRect cgr = Nlm_RecTToCGRect (*r);
 
6530
      
 
6531
      CGContextClipToRect (Nlm_PeekQContext(), cgr);
 
6532
    }
 
6533
#else
5842
6534
    ClipRect (&rtool);
 
6535
#endif
5843
6536
  }
5844
6537
#endif
5845
6538
#ifdef WIN_MSWIN
5878
6571
 
5879
6572
  if (rgn != NULL) {
5880
6573
    ntool = (Nlm_RgnTool) rgn;
 
6574
#ifdef WIN_MAC_QUARTZ
 
6575
    HIShapeReplacePathInCGContext (ntool, Nlm_PeekQContext());
 
6576
    CGContextClip (Nlm_PeekQContext());
 
6577
#else
5881
6578
    SetClip (ntool);
 
6579
#endif
5882
6580
  }
5883
6581
#endif
5884
6582
#ifdef WIN_MSWIN
5916
6614
 
5917
6615
{
5918
6616
#ifdef WIN_MAC
 
6617
#ifdef WIN_MAC_QUARTZ
 
6618
// QUARTZ_FIXME: CGContext clips can only contract, not expand, needs to be handled by popping the context, but callers don't know about that... maybe have the global context always be inherently pushed, and this can pop and immediately re-push?
 
6619
#else
5919
6620
  Nlm_RecT      r;
5920
6621
  Nlm_RectTool  rtool;
5921
6622
 
5923
6624
  Local__RecTToRectTool (&r, &rtool);
5924
6625
  ClipRect (&rtool);
5925
6626
#endif
 
6627
#endif
5926
6628
#ifdef WIN_MSWIN
5927
6629
  if (Nlm_currentHDC != NULL) {
5928
6630
    SelectClipRgn (Nlm_currentHDC, NULL);
5943
6645
 
5944
6646
{
5945
6647
#ifdef WIN_MAC
 
6648
#ifdef WIN_MAC_QUARTZ
 
6649
// QUARTZ_FIXME: do we care? just let it redraw
 
6650
#else
5946
6651
  Nlm_RectTool  rtool;
5947
6652
 
5948
6653
  if (r != NULL) {
5950
6655
    ValidRect (&rtool);
5951
6656
  }
5952
6657
#endif
 
6658
#endif
5953
6659
#ifdef WIN_MSWIN
5954
6660
  Nlm_RectTool  rtool;
5955
6661
 
5966
6672
 
5967
6673
{
5968
6674
#ifdef WIN_MAC
 
6675
#ifdef WIN_MAC_QUARTZ
 
6676
// QUARTZ_FIXME: this could stand to be a little more fine-grained
 
6677
  HIViewRef view = HIViewGetRoot (Nlm_QWindow);
 
6678
  HIViewSetNeedsDisplay (view, 1);
 
6679
#else
5969
6680
  Nlm_RectTool  rtool;
5970
6681
 
5971
6682
  if (r != NULL) {
5973
6684
    InvalRect (&rtool);
5974
6685
  }
5975
6686
#endif
 
6687
#endif
5976
6688
#ifdef WIN_MSWIN
5977
6689
  Nlm_RectTool  rtool;
5978
6690
 
5998
6710
{
5999
6711
#ifdef WIN_MAC
6000
6712
  if (rgn != NULL) {
 
6713
#ifdef WIN_MAC_QUARTZ
 
6714
// QUARTZ_FIXME: do we care? just let it redraw
 
6715
#else
6001
6716
    ValidRgn ((Nlm_RgnTool) rgn);
 
6717
#endif
6002
6718
  }
6003
6719
#endif
6004
6720
#ifdef WIN_MSWIN
6015
6731
{
6016
6732
#ifdef WIN_MAC
6017
6733
  if (rgn != NULL) {
 
6734
#ifdef WIN_MAC_QUARTZ
 
6735
// QUARTZ_FIXME: this could stand to be a little more fine-grained
 
6736
  HIViewRef view = HIViewGetRoot (Nlm_QWindow);
 
6737
  HIViewSetNeedsDisplay (view, 1);
 
6738
#else
6018
6739
    InvalRgn ((Nlm_RgnTool) rgn);
 
6740
#endif
6019
6741
  }
6020
6742
#endif
6021
6743
#ifdef WIN_MSWIN
6059
6781
 
6060
6782
{
6061
6783
#ifdef WIN_MAC
 
6784
#ifdef WIN_MAC_QUARTZ
 
6785
  CGRect rect = Nlm_RecTToCGRect (*r);
 
6786
  
 
6787
  int width = r->left - r->right;
 
6788
  int height = r->bottom - r->top;
 
6789
  int bytesPerRow = (width - 1) / 8 + 1;
 
6790
  
 
6791
  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
 
6792
  CGDataProviderRef dataProvider = CGDataProviderCreateWithData (NULL, source, bytesPerRow * height, NULL);
 
6793
  
 
6794
  CGImageRef image = CGImageCreate (
 
6795
    width,
 
6796
    height,
 
6797
    1, /* bits per component */
 
6798
    1, /* bits per pixel */
 
6799
    bytesPerRow,
 
6800
    colorSpace,
 
6801
    0, /* bitmap info */
 
6802
    dataProvider,
 
6803
    NULL,
 
6804
    1, /* should interpolate */
 
6805
    kCGRenderingIntentDefault);
 
6806
  
 
6807
  CGContextDrawImage (Nlm_PeekQContext(), rect, image);
 
6808
  
 
6809
  CFRelease (image);
 
6810
  CFRelease (dataProvider);
 
6811
  CFRelease (colorSpace);
 
6812
  
 
6813
#else
6062
6814
  const BitMap *dstBitsPtr;
6063
6815
  Nlm_Int2  mode;
6064
6816
  PenState  pnState;
6101
6853
    CopyBits (&srcBits, dstBitsPtr, &srcRect, &rect, mode, NULL);
6102
6854
  }
6103
6855
#endif
 
6856
#endif
6104
6857
#ifdef WIN_MSWIN
6105
6858
  Nlm_Int2      cols;
6106
6859
  HBITMAP       hBitmap;
6329
7082
  MemFree(bInfoPtr);
6330
7083
#endif
6331
7084
#ifdef WIN_MAC
 
7085
#ifdef WIN_MAC_QUARTZ
 
7086
  CGRect rect = Nlm_RecTToCGRect (*r);
 
7087
  
 
7088
  width = r->left - r->right;
 
7089
  height = r->bottom - r->top;
 
7090
  
 
7091
  CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB ();
 
7092
  
 
7093
  /* we're going to pass the color table directly; it's an array of
 
7094
     structs containing r, g, b, and the function wants an array
 
7095
     of unsigned char containing r, g, b, so they all line up */
 
7096
  CGColorSpaceRef colorSpace = CGColorSpaceCreateIndexed (baseSpace, totalColors - 1, (const unsigned char *)colorTable);
 
7097
  
 
7098
  CGDataProviderRef dataProvider = CGDataProviderCreateWithData (NULL, source, width * height, NULL);
 
7099
  
 
7100
  CGImageRef image = CGImageCreate (
 
7101
    width,
 
7102
    height,
 
7103
    8, /* bits per component */
 
7104
    8, /* bits per pixel */
 
7105
    width * height,
 
7106
    colorSpace,
 
7107
    0, /* bitmap info */
 
7108
    dataProvider,
 
7109
    NULL,
 
7110
    1, /* should interpolate */
 
7111
    kCGRenderingIntentDefault);
 
7112
  
 
7113
  CGContextDrawImage (Nlm_PeekQContext(), rect, image);
 
7114
  
 
7115
  CFRelease (image);
 
7116
  CFRelease (dataProvider);
 
7117
  CFRelease (colorSpace);
 
7118
  CFRelease (baseSpace);
 
7119
#else
6332
7120
  pixelMap = (PixMap*)MemNew(sizeof(PixMap));
6333
7121
  pixelMap->hRes = 72;
6334
7122
  pixelMap->vRes = 72;
6381
7169
  }
6382
7170
  MemFree(pixelMap);
6383
7171
#endif
 
7172
#endif
6384
7173
 
6385
7174
#ifdef WIN_MOTIF
6386
7175
  {{
6435
7224
  char       tmpFontName[256];
6436
7225
 
6437
7226
 
 
7227
#ifdef WIN_MAC_QUARTZ
 
7228
  CGRect r = CGRectMake (-32768, -32768, 65535, 65535);
 
7229
  HIShapeRef rectShape = HIShapeCreateWithRect (&r);
 
7230
  Nlm_scrollRgn = HIShapeCreateMutableCopy (rectShape);
 
7231
  Nlm_updateRgn = HIShapeCreateMutableCopy (rectShape);
 
7232
  CFRelease (rectShape);
 
7233
  
 
7234
  /* can't use QuickDraw functions to get the system font,
 
7235
     no replacemet available, so just hardcode it */
 
7236
  memset ( &fsp, 0, sizeof(Nlm_FontSpec));
 
7237
  Nlm_StrCpy (fsp.name, "Lucida Grande");
 
7238
  fsp.size = 13;
 
7239
#else
6438
7240
  Nlm_scrollRgn = (Nlm_RegioN) (NewRgn ());
6439
7241
 
6440
7242
  Nlm_updateRgn = (Nlm_RegioN) (NewRgn ());
6444
7246
  Local__RectToolToRecT (&bounds, &Nlm_updateRect);
6445
7247
  /* HUnlock ((Handle) Nlm_updateRgn); */
6446
7248
 
6447
 
  Nlm_fontList = NULL;
6448
 
  Nlm_fontInUse = NULL;
6449
 
  Nlm_systemFont = (Nlm_FonT) Nlm_HandNew (sizeof (Nlm_FontRec));
6450
7249
  /* esl: LoadFontData changed to work with new FontData format */
6451
7250
  /* alexs get font name */
6452
7251
  memset ( &fsp, 0, sizeof(Nlm_FontSpec));
6455
7254
  Nlm_StringNCpy_0 (fsp.name, tmpFontName, FONT_NAME_SIZE - 1);
6456
7255
  fsp.name[FONT_NAME_SIZE - 1] = 0;
6457
7256
  fsp.size = GetDefFontSize ();
 
7257
#endif
 
7258
 
 
7259
  Nlm_fontList = NULL;
 
7260
  Nlm_fontInUse = NULL;
 
7261
  Nlm_systemFont = (Nlm_FonT) Nlm_HandNew (sizeof (Nlm_FontRec));
 
7262
  
 
7263
#ifdef WIN_MAC_ATSUI
 
7264
  Nlm_LoadFontData (Nlm_systemFont, NULL, -1, &fsp, Nlm_NewATSUStyle(&fsp), NULL);
 
7265
#else
6458
7266
  Nlm_LoadFontData (Nlm_systemFont, NULL, -1, &fsp, 0, fsp.size, 0, NULL);
 
7267
#endif
6459
7268
  Nlm_programFont = (Nlm_FonT) Nlm_HandNew (sizeof (Nlm_FontRec));
6460
7269
  /* esl: LoadFontData changed to work with new FontData format */
6461
7270
  Nlm_StrCpy (fsp.name, "Monaco");
6462
7271
  fsp.size = 9;
 
7272
#ifdef WIN_MAC_ATSUI
 
7273
  Nlm_LoadFontData (Nlm_programFont, NULL, -1, &fsp, Nlm_NewATSUStyle(&fsp), NULL);
 
7274
#else
6463
7275
  Nlm_LoadFontData (Nlm_programFont, NULL, -1, &fsp, 4, 9, 0, NULL);
 
7276
#endif
6464
7277
  Nlm_fontList = NULL;
6465
7278
  Nlm_fontInUse = Nlm_systemFont;
6466
7279
 
6477
7290
      Nlm_hasColorQD = (gval && (1 << gestaltHasColor));
6478
7291
  }
6479
7292
  if (Nlm_hasColorQD) {
 
7293
#ifdef WIN_MAC_QUARTZ
 
7294
    Nlm_QuartzForeColor.r = 0;
 
7295
    Nlm_QuartzForeColor.g = 0;
 
7296
    Nlm_QuartzForeColor.b = 0;
 
7297
    Nlm_QuartzBackColor.r = 1.0;
 
7298
    Nlm_QuartzBackColor.g = 1.0;
 
7299
    Nlm_QuartzBackColor.b = 1.0;
 
7300
#else
6480
7301
    Nlm_RGBforeColor.red = 0;
6481
7302
    Nlm_RGBforeColor.green = 0;
6482
7303
    Nlm_RGBforeColor.blue = 0;
6483
7304
    Nlm_RGBbackColor.red = 65535;
6484
7305
    Nlm_RGBbackColor.green = 65535;
6485
7306
    Nlm_RGBbackColor.blue = 65535;
 
7307
#endif
6486
7308
  }
6487
7309
#endif
6488
7310
#ifdef WIN_MSWIN
6702
7524
  Nlm_FonT      f;
6703
7525
  Nlm_FontData  fdata;
6704
7526
 
 
7527
#ifndef WIN_MAC_QUARTZ
6705
7528
  Nlm_ResetDrawingTools ();
 
7529
#endif
6706
7530
#ifdef WIN_MOTIF
6707
7531
  Nlm_GetFontData (Nlm_systemFont, &fdata);
6708
7532
  if (fdata.handle != NULL) {