fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

fl_color_mac.cxx

Go to the documentation of this file.
00001 //
00002 // "$Id: fl_color_mac.cxx 8129 2010-12-28 15:33:36Z manolo $"
00003 //
00004 // MacOS color functions for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 // The fltk "colormap".  This allows ui colors to be stored in 8-bit
00029 // locations, and provides a level of indirection so that global color
00030 // changes can be made.  Not to be confused with the X colormap, which
00031 // I try to hide completely.
00032 
00033 // matt: Neither Quartz nor Quickdraw support colormaps in this implementation
00034 // matt: Quartz support done
00035 
00036 #include <config.h>
00037 #include <FL/Fl.H>
00038 #include <FL/x.H>
00039 #include <FL/fl_draw.H>
00040 
00041 static unsigned fl_cmap[256] = {
00042 #include "fl_cmap.h" // this is a file produced by "cmap.cxx":
00043 };
00044 
00045 // Translations to mac data structures:
00046 Fl_XMap fl_xmap[256];
00047 
00048 Fl_XMap* fl_current_xmap;
00049 
00050 Fl_Color fl_color_;
00051 
00052 void Fl_Quartz_Graphics_Driver::color(Fl_Color i) {
00053   fl_color_ = i;
00054   int index;
00055   uchar r, g, b;
00056   if (i & 0xFFFFFF00) {
00057     // translate rgb colors into color index
00058     r = i>>24;
00059     g = i>>16;
00060     b = i>> 8;
00061   } else {
00062     // translate index into rgb:
00063     index = i;
00064     unsigned c = fl_cmap[i];
00065     r = c>>24;
00066     g = c>>16;
00067     b = c>> 8;
00068   }
00069   if (!fl_gc) return; // no context yet? We will assign the color later.
00070   float fr = r/255.0f;
00071   float fg = g/255.0f;
00072   float fb = b/255.0f;
00073   CGContextSetRGBFillColor(fl_gc, fr, fg, fb, 1.0f);
00074   CGContextSetRGBStrokeColor(fl_gc, fr, fg, fb, 1.0f);
00075 }
00076 
00077 void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) {
00078   fl_color_ = fl_rgb_color(r, g, b);
00079   float fr = r/255.0f;
00080   float fg = g/255.0f;
00081   float fb = b/255.0f;
00082   CGContextSetRGBFillColor(fl_gc, fr, fg, fb, 1.0f);
00083   CGContextSetRGBStrokeColor(fl_gc, fr, fg, fb, 1.0f);
00084 }
00085 
00086 void Fl::set_color(Fl_Color i, unsigned c) {
00087   if (fl_cmap[i] != c) {
00088     fl_cmap[i] = c;
00089   }
00090 }
00091 
00092 //
00093 // End of "$Id: fl_color_mac.cxx 8129 2010-12-28 15:33:36Z manolo $".
00094 //