Planeshift
pawsframedrawable.h
Go to the documentation of this file.
1 /*
2 * pawsframedrawable.h
3 *
4 * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation (version 2 of the License)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19 
20 #ifndef PAWS_FRAME_DRAWABLE
21 #define PAWS_FRAME_DRAWABLE
22 
23 #include "pawstexturemanager.h"
24 
29 class pawsFrameDrawable : public scfImplementation1<pawsFrameDrawable, iPawsImage>
30 {
31 private:
32  enum FRAME_DRAWABLE_PIECE
33  {
34  FDP_TOP_LEFT=0,
35  FDP_TOP,
36  FDP_TOP_RIGHT,
37  FDP_LEFT,
38  FDP_MIDDLE,
39  FDP_RIGHT,
40  FDP_BOTTOM_LEFT,
41  FDP_BOTTOM,
42  FDP_BOTTOM_RIGHT,
43 
44  FDP_COUNT
45  };
46 
47  struct pawsFrameDrawablePiece
48  {
49  csRef<iPawsImage> drawable;
50  int offsetx;
51  int offsety;
52  };
53  pawsFrameDrawablePiece pieces[FDP_COUNT];
54 
55  enum FRAME_DRAWABLE_TYPE
56  {
57  FDT_HORIZONTAL=0,
58  FDT_VERTICAL,
59  FDT_FULL,
60 
61  FDT_COUNT
62  };
63  FRAME_DRAWABLE_TYPE type;
64 
66  csString imageFileLocation;
67 
69  csString resourceName;
70 
72  int defaultAlphaValue;
73 
75  int defaultTransparentColourRed;
76  int defaultTransparentColourGreen;
77  int defaultTransparentColourBlue;
78 
79  void LoadPiece(iDocumentNode* node, FRAME_DRAWABLE_PIECE piece);
80  void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int w, int h, int alpha, bool scaleX=false, bool scaleY=false);
81  void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int alpha);
82 
83 public:
84  pawsFrameDrawable(iDocumentNode* node);
85 
86  virtual ~pawsFrameDrawable();
87 
88  const char* GetName() const;
89 
90  void Draw(int x, int y, int alpha=-1);
91  void Draw(csRect rect, int alpha=-1);
92  void Draw(int x, int y, int newWidth, int newHeight, int alpha=-1);
93 
94  int GetWidth() const;
95  int GetHeight() const;
96 
97  bool IsLoaded() const
98  {
99  return true;
100  }
101 
102  void ExpandClipRect(csRect &clipRect);
103 
104  int GetDefaultAlpha() const;
105 };
106 
109 #endif // PAWS_FRAME_DRAWABLE
void ExpandClipRect(csRect &clipRect)
bool IsLoaded() const
void Draw(int x, int y, int alpha=-1)
int GetHeight() const
const char * GetName() const
pawsFrameDrawable(iDocumentNode *node)
virtual ~pawsFrameDrawable()
int GetDefaultAlpha() const
int GetWidth() const