⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardimgs.h

📁 一个扑克牌游戏集合的源码,包含了很多基本c-c++语言应用
💻 H
字号:
#ifndef CARDIMGS_H#define CARDIMGS_H//$Id: CardImgs.h,v 1.16 2006/06/05 21:38:14 markus Rel $// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#include <string>#include <vector>#include <gdkmm/pixbuf.h>#include <YGP/Exception.h>/**Class to load & store the images of the used cards*/class CardImages { public:   CardImages () : cards_ (52) { }   ~CardImages ();   unsigned int addImage (const char* const* data) {      cards_.push_back (Gdk::Pixbuf::create_from_xpm_data (data));      return cards_.size () - 1; }   void delImage (unsigned int pos) {      cards_.erase (cards_.begin () + pos); }   const Glib::RefPtr<Gdk::Pixbuf> getCardImage (unsigned int nr) const;   const Glib::RefPtr<Gdk::Pixbuf> getCardBackground () const { return back_; }   void setCardBackground (const Glib::RefPtr<Gdk::Pixbuf> back) { back_ = back; }   void loadDecks (const std::string& path) throw (YGP::FileError);   void loadBack (const std::string& file) throw (YGP::FileError);   /// Loads the cards (faces and background)   /// \param path: Path to files   /// \param back: File containing background picture   /// \throw YGP::FileError: An describing text in case of error   void load (const std::string& path, const std::string& back) throw (YGP::FileError) {      loadDecks (path);      loadBack (back);   }   /// Loads the cards (faces and background)   /// \param cards: Number of cards expected   /// \param path: Path to files   /// \param back: File containing background picture   /// \throw YGP::FileError: An describing text in case of error   void load (unsigned int cards, const std::string& path, const std::string& back) throw (YGP::FileError) {      cards_.reserve (cards);      load (path, back); }   unsigned int size () const { return cards_.size (); }   bool hasBack () const { return back_; } private:   std::vector<Glib::RefPtr<Gdk::Pixbuf> > cards_;   Glib::RefPtr<Gdk::Pixbuf> back_;   void unload ();};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -