Back to index

plt-scheme  4.2.1
Pen+Brush.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: pen and brush classes needed for drawing
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef PenBrush_h
00028 #define PenBrush_h
00029 
00030 #ifdef __GNUG__
00031 #pragma interface
00032 #endif
00033 
00034 class wxBitmap;
00035 
00036 typedef unsigned char wxDash;
00037 
00038 class wxBrush : public wxObject { // brush representation
00039 public:
00040     wxBrush(void);
00041     wxBrush(wxColour* col, int style);
00042     wxBrush(const char *col, int style);
00043     ~wxBrush(void);
00044 
00045     wxColour*  GetColour(void)       { return colour; }
00046     wxBitmap   *GetStipple(void)     { return stipple; }
00047     int        GetStyle(void)        { return style; }
00048 
00049     void SetColour(wxColour* col)          { colour->CopyFrom(col); }
00050     void SetColour(const char *col)        { colour->CopyFrom(col); }
00051     void SetColour(char r, char g, char b) { colour->Set(r, g, b); }
00052     void SetStipple(wxBitmap *s);
00053     void SetStyle(int s)                   { style = s; }
00054 
00055     inline Bool  IsMutable(void)          { return !locked; }
00056     inline void  Lock(int d)              { locked += d; colour->Lock(d); }
00057 
00058 private:
00059     wxColour  *colour;
00060     short     locked;
00061     short     style;
00062     wxBitmap  *stipple;
00063 };
00064 
00065 class wxPen : public wxObject { // pen representation
00066 public:
00067     wxPen(void);
00068     wxPen(wxColour* col, double width, int style);
00069     wxPen(const char *col, double width, int style);
00070     ~wxPen(void);
00071 
00072     int       GetCap(void)          { return cap; }
00073     wxColour* GetColour(void)       { return colour; }
00074     int       GetDashes(wxDash **p) { *p = dash; return nb_dash; }
00075     int       GetJoin(void)         { return join; }
00076     wxBitmap  *GetStipple(void)     { return stipple; }
00077     int       GetStyle(void)        { return style; }
00078     int       GetWidth(void)        { return (int)width; }
00079     double     GetWidthF(void)       { return width; }
00080 
00081     void SetCap(int c)                     { cap = c; }
00082     void SetColour(wxColour* col)          { colour->CopyFrom(col); }
00083     void SetColour(const char *col)        { colour->CopyFrom(col); }
00084     void SetColour(char r, char g, char b) { colour->Set(r, g, b); }
00085     void SetDashes(int n, wxDash *d)       { nb_dash = n; dash = d; }
00086     void SetJoin(int j)                    { join = j; }
00087     void SetStipple(wxBitmap *s);
00088     void SetStyle(int s)                   { style = s; }
00089     void SetWidth(double w)                 { width = w; }
00090 
00091     inline Bool  IsMutable(void)          { return !locked; }
00092     inline void  Lock(int d)              { locked += d; colour->Lock(d); }
00093 
00094 private:
00095     int       nb_dash;
00096     wxDash    *dash;
00097     wxColour  *colour;
00098     double     width;
00099     int       locked;
00100     short      style;
00101     int       join;
00102     int       cap;
00103     wxBitmap  *stipple;
00104 };
00105 
00106 class wxBrushList : public wxObject {
00107     wxChildList *list;
00108 public:
00109     wxBrushList(void);
00110     ~wxBrushList(void);
00111 
00112     void  AddBrush(wxBrush *Brush);
00113     wxBrush *FindOrCreateBrush(wxColour *colour, int style);
00114     wxBrush *FindOrCreateBrush(char *colour, int style);
00115 };
00116 
00117 class wxPenList : public wxObject {
00118     wxChildList *list;
00119 public:
00120     wxPenList(void);
00121     ~wxPenList(void);
00122 
00123     void  AddPen(wxPen *pen);
00124     wxPen *FindOrCreatePen(wxColour *colour, double width, int style);
00125     wxPen *FindOrCreatePen(char *colour, double width, int style);
00126 };
00127 
00128 #endif // PenBrush_h