Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

painter.h

00001 /* 00002 libwftk - Worldforge Toolkit - a widget library 00003 Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org> 00004 Based on code copyright (C) 1999-2002 Karsten Laux 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 00018 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, SA. 00020 */ 00021 // written by Karsten Laux, June 1999 00022 00023 #ifndef _PAINTER_H_ 00024 #define _PAINTER_H_ 00025 00026 #include <wftk/surface.h> 00027 00028 namespace wftk { 00029 00031 class Painter 00032 { 00033 public: 00035 Painter(Surface* surf = 0); 00036 00037 bool empty() const {return !surface_ || surface_->empty();} 00038 00040 enum Mode {OP_REPLACE , OP_AND , OP_OR , OP_XOR }; 00041 00043 void setColor(const Color& col) { color_ = col; }; 00045 void setFilling(bool flag) { fill_ = flag;}; 00047 void setMode(Mode mode) { mode_ = mode;}; 00048 00050 void setSurface(Surface* surf) {surface_ = surf;} 00051 00057 void setPixel(const Point& pt, const Color& col) 00058 {if(surface_) surface_->setPixel(pt, col);} 00059 00064 Color getPixel (const Point& pt) 00065 {return surface_ ? surface_->getPixel(pt) : Color();} 00066 00072 void hLine(const Point& p1, const Point& p2); 00073 00079 void vLine(const Point& p1, const Point& p2); 00080 00089 void line(const Point& p1, const Point& p2); 00090 00097 void hLine(const Point& p1, const Point& p2, const Color& col); 00098 00105 void vLine(const Point& p1, const Point& p2, const Color& col); 00106 00116 void line(const Point& p1, const Point& p2, const Color& col); 00117 00124 void circle(const Point& c, unsigned int r, unsigned int t=1); 00125 00133 void ellipse(const Point& c, unsigned int rx, 00134 unsigned int ry, unsigned int t=1); 00135 00141 void box(const Point& p1, const Point& p2); 00142 00149 void trigon(const Point& p1, const Point& p2, const Point& p3); 00150 00158 void trigon(const Point& p1, const Point& p2, const Point& p3, const Color& c); 00159 00171 void shadedTrigon(const Point& d1, const Point& d2, const Point& d3, 00172 const Color& c1, const Color& c2, const Color& c3); 00173 00184 void texturedTrigon(const Point& d1, const Point& d2, const Point& d3, 00185 const Point& s1, const Point& s2, const Point& s3, Surface* texture); 00186 00187 private: 00189 void ellipseFill(const Point& c, unsigned int rx, unsigned int ry); 00191 void writePixel(Uint32, Uint32); 00192 00194 Surface* surface_; 00196 Color color_; 00198 bool fill_; 00200 Mode mode_; 00201 00202 }; 00203 00204 00205 } 00206 00207 00208 00209 #endif

Generated Wed Jul 28 17:28:43 2004.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.