aswang  1.0
Brush.cpp
Go to the documentation of this file.
00001 /*
00002         Copyright 2003 Joseph Alvis
00003 
00004     This file is part of Aswang.
00005 
00006     Aswang is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU Lesser General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     Aswang 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
00014     GNU Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public License
00017     along with Aswang.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 #include "brush.h"
00021 
00022 using namespace aswang;
00023 
00024 void Brush::Delete() {
00025         if(hbr != NULL) {
00026                 DeleteObject(hbr);
00027                 hbr=NULL;
00028         }
00029 }
00030 
00031 void Brush::SetCRef(COLORREF r) {
00032         cref = r;
00033         Delete();
00034         hbr=CreateSolidBrush(cref);
00035 }
00036 
00037 void Brush::SetBrush(HBRUSH b) {
00038         Delete();
00039         if(b!=NULL) {
00040                 LOGBRUSH lbr;
00041                 if((GetObject(b,sizeof(lbr),&lbr))!=0) {
00042                         cref=lbr.lbColor;
00043                         hbr=CreateSolidBrush(cref);
00044                 }
00045         }
00046 }
00047 
00048 Brush &Brush::operator = (const Brush &b) {
00049         Delete();
00050         if(b.hbr!=NULL)
00051                 SetCRef(b.cref);
00052         return *this;
00053 }
00054 
00055 Brush &Brush::operator = (const COLORREF r) {
00056         SetCRef(r);
00057         return *this;
00058 }
00059 
00060 Brush &Brush::operator = (const HBRUSH b) {
00061         SetBrush(b);
00062         return *this;
00063 }
00064 
00065 LOGBRUSH Brush::GetObjectInfo() const {
00066         LOGBRUSH lbrush;
00067         memset(&lbrush,0,sizeof(lbrush));
00068         if(hbr!=NULL)
00069                 GetObject(hbr,sizeof(lbrush),&lbrush);
00070         return lbrush;
00071 }
00072 
00073 unsigned int Brush::GetStyle() const {
00074         LOGBRUSH lbrush = GetObjectInfo();
00075         return lbrush.lbStyle;
00076 }
00077 
00078 COLORREF Brush::GetColor() const {
00079         LOGBRUSH lbrush = GetObjectInfo();
00080         return lbrush.lbColor;
00081 }
00082 
00083 long Brush::GetHatch() const {
00084         LOGBRUSH lbrush = GetObjectInfo();
00085         return (long)lbrush.lbHatch;
00086 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines