Planeshift

pawsframedrawable.h

Go to the documentation of this file.
00001 /*
00002 * pawsframedrawable.h
00003 *
00004 * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005 *
00006 *
00007 * This program is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU General Public License
00009 * as published by the Free Software Foundation (version 2 of the License)
00010 * This program is distributed in the hope that it will be useful,
00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 * GNU General Public License for more details.
00014 * You should have received a copy of the GNU General Public License
00015 * along with this program; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 *
00018 */
00019 
00020 #ifndef PAWS_FRAME_DRAWABLE
00021 #define PAWS_FRAME_DRAWABLE
00022 
00023 #include "pawstexturemanager.h"
00024 
00029 class pawsFrameDrawable  : public scfImplementation1<pawsFrameDrawable, iPawsImage>
00030 {
00031 private:
00032     enum FRAME_DRAWABLE_PIECE
00033     {
00034         FDP_TOP_LEFT=0,
00035         FDP_TOP,
00036         FDP_TOP_RIGHT,
00037         FDP_LEFT,
00038         FDP_MIDDLE,
00039         FDP_RIGHT,
00040         FDP_BOTTOM_LEFT,
00041         FDP_BOTTOM,
00042         FDP_BOTTOM_RIGHT,
00043 
00044         FDP_COUNT
00045     };
00046 
00047     struct pawsFrameDrawablePiece
00048     {
00049         csRef<iPawsImage> drawable;
00050         int                  offsetx;
00051         int                  offsety;
00052     };
00053     pawsFrameDrawablePiece pieces[FDP_COUNT];
00054 
00055     enum FRAME_DRAWABLE_TYPE
00056     {
00057         FDT_HORIZONTAL=0,
00058         FDT_VERTICAL,
00059         FDT_FULL,
00060 
00061         FDT_COUNT
00062     };
00063     FRAME_DRAWABLE_TYPE type;
00064 
00066     csString imageFileLocation;
00067 
00069     csString resourceName;
00070 
00072     int      defaultAlphaValue;
00073 
00075     int      defaultTransparentColourRed;
00076     int      defaultTransparentColourGreen;
00077     int      defaultTransparentColourBlue;
00078 
00079     void LoadPiece(iDocumentNode* node, FRAME_DRAWABLE_PIECE piece);
00080     void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int w, int h, int alpha, bool scaleX=false, bool scaleY=false);
00081     void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int alpha);
00082 
00083 public:
00084     pawsFrameDrawable(iDocumentNode* node);
00085 
00086     virtual ~pawsFrameDrawable();
00087 
00088     const char* GetName() const;
00089 
00090     void Draw(int x, int y, int alpha=-1);
00091     void Draw(csRect rect, int alpha=-1);
00092     void Draw(int x, int y, int newWidth, int newHeight, int alpha=-1);
00093 
00094     int GetWidth() const;
00095     int GetHeight() const;
00096 
00097     bool IsLoaded() const
00098     {
00099         return true;
00100     }
00101 
00102     void ExpandClipRect(csRect &clipRect);
00103 
00104     int GetDefaultAlpha() const;
00105 };
00106 
00109 #endif // PAWS_FRAME_DRAWABLE