00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 namespace cmlabs { 00023 00024 Color::~Color() { 00025 if (pen != NULL) 00026 DeleteObject(pen); 00027 if (brush == NULL) 00028 DeleteObject(brush); 00029 } 00030 00031 Color& Color::operator =(COLORREF ref) { 00032 r = GetRValue(ref); 00033 g = GetGValue(ref); 00034 b = GetBValue(ref); 00035 return *this; 00036 } 00037 00038 Color::operator HPEN() { 00039 if (pen == NULL) 00040 pen = CreatePen(PS_SOLID, size, *this); 00041 return pen; 00042 } 00043 00044 Color::operator HBRUSH() { 00045 if (brush == NULL) 00046 brush = CreateSolidBrush(*this); 00047 return brush; 00048 } 00049 00050 Color::operator COLORREF() { 00051 return RGB(r, g, b); 00052 } 00053 00054 } // namespace cmlabs