Resource_Font.cpp
Go to the documentation of this file.00001 //*** Resource_Font.cpp *** 00002 00003 #include "Resource_Font.h" 00004 #include "ResourceManager.h" 00005 #include "Filename.h" 00006 #include "Font.h" 00007 00008 00009 //*** Constructor *** 00010 00011 Resource_Font::Resource_Font(): 00012 font_(0) 00013 { 00014 } 00015 00016 00017 //*** Constructor *** 00018 00019 Resource_Font::Resource_Font(const Filename& filename) 00020 { 00021 font_=siResourceManager->GetFont(filename.GetStringId()); 00022 siResourceManager->IncreaseReferenceCount(font_); 00023 } 00024 00025 00026 //*** Constructor *** 00027 00028 Resource_Font::Resource_Font(const char* filenameStr) 00029 { 00030 Filename filename(filenameStr); 00031 font_=siResourceManager->GetFont(filename.GetStringId()); 00032 siResourceManager->IncreaseReferenceCount(font_); 00033 } 00034 00035 00036 //*** Constructor *** 00037 00038 Resource_Font::Resource_Font(StringId filenameId) 00039 { 00040 Filename filename(filenameId); 00041 font_=siResourceManager->GetFont(filename.GetStringId()); 00042 siResourceManager->IncreaseReferenceCount(font_); 00043 } 00044 00045 00046 //*** Destructor *** 00047 00048 Resource_Font::~Resource_Font() 00049 { 00050 if (font_) 00051 { 00052 siResourceManager->DecreaseReferenceCount(font_); 00053 } 00054 } 00055 00056 00058 00059 Resource_Font::Resource_Font(const Resource_Font& resource): 00060 font_(resource.font_) 00061 { 00062 siResourceManager->IncreaseReferenceCount(font_); 00063 } 00064 00065 00066 //*** Assignment operator *** 00067 00068 const Resource_Font& Resource_Font::operator =(const Resource_Font& resource) 00069 { 00070 font_=resource.font_; 00071 siResourceManager->IncreaseReferenceCount(font_); 00072 return *this; 00073 } 00074 00075 00076 //*** GetFont *** 00077 00078 const Font& Resource_Font::GetFont() const 00079 { 00080 if (font_) 00081 { 00082 return *font_; 00083 } 00084 00085 static Font defaultValue; 00086 return defaultValue; 00087 } 00088 00089 00090 //*** operator const Font& *** 00091 00092 Resource_Font::operator const Font&() const 00093 { 00094 return GetFont(); 00095 } 00096 00097 00098 void Resource_Font::Blit(Bitmap& bitmap, int x, int y, const char* text, int spacing, unsigned short modulate, unsigned char alpha) const 00099 { 00100 if (!font_) 00101 { 00102 return; 00103 } 00104 00105 font_->Blit(bitmap,x,y,text,spacing,modulate,alpha); 00106 } 00107 00108 void Resource_Font::BlitWrap(Bitmap& bitmap, int x, int y, const char* text, int width, int hspacing, int vspacing, unsigned short modulate, unsigned char alpha) const 00109 { 00110 if (!font_) 00111 { 00112 return; 00113 } 00114 00115 font_->BlitWrap(bitmap,x,y,text,width,hspacing,vspacing,modulate,alpha); 00116 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
