2 // "$Id: fl_color_mac.cxx 8384 2011-02-06 12:32:23Z manolo $"
4 // MacOS color functions for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // The fltk "colormap". This allows ui colors to be stored in 8-bit
29 // locations, and provides a level of indirection so that global color
30 // changes can be made. Not to be confused with the X colormap, which
31 // I try to hide completely.
33 // matt: Neither Quartz nor Quickdraw support colormaps in this implementation
34 // matt: Quartz support done
39 #include <FL/fl_draw.H>
41 static unsigned fl_cmap
[256] = {
42 #include "fl_cmap.h" // this is a file produced by "cmap.cxx":
45 // Translations to mac data structures:
48 Fl_XMap
* fl_current_xmap
;
50 void Fl_Quartz_Graphics_Driver::color(Fl_Color i
) {
51 Fl_Graphics_Driver::color(i
);
55 // translate rgb colors into color index
60 // translate index into rgb:
62 unsigned c
= fl_cmap
[i
];
67 if (!fl_gc
) return; // no context yet? We will assign the color later.
71 CGContextSetRGBFillColor(fl_gc
, fr
, fg
, fb
, 1.0f
);
72 CGContextSetRGBStrokeColor(fl_gc
, fr
, fg
, fb
, 1.0f
);
75 void Fl_Quartz_Graphics_Driver::color(uchar r
, uchar g
, uchar b
) {
76 Fl_Graphics_Driver::color( fl_rgb_color(r
, g
, b
) );
80 CGContextSetRGBFillColor(fl_gc
, fr
, fg
, fb
, 1.0f
);
81 CGContextSetRGBStrokeColor(fl_gc
, fr
, fg
, fb
, 1.0f
);
84 void Fl::set_color(Fl_Color i
, unsigned c
) {
85 if (fl_cmap
[i
] != c
) {
91 // End of "$Id: fl_color_mac.cxx 8384 2011-02-06 12:32:23Z manolo $".