uima.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uima.hpp
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _uima_hpp_
00021 #define _uima_hpp_
00022 //pragma ident  "@(#)uima.hpp   ubit:05.05.00"
00023 #include <ubit/umode.hpp>
00024 #include <ubit/udata.hpp>
00025 namespace ubit {
00026 
00027 /* ==================================================== ===== ======= */
00036 class UIma: public UData {
00037 public:
00038   UBIT_DATA_ELEMENT_CLASS(UIma, UData)
00039 
00040   UIma(const UStr& filename, bool load_now = false);
00041   UIma(const char* filename = null, bool load_now = false);
00056   UIma(const char** xpm_data, bool load_now = false);
00064   UIma(int width, int height);
00068   virtual ~UIma();
00069 
00070   friend UIma& uima(const UStr& filename)  {return *new UIma(filename);}
00071   friend UIma& uima(const char* filename)  {return *new UIma(filename);}
00072   friend UIma& uima(const char** xpm_data) {return *new UIma(xpm_data);}
00074 
00075   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00076 
00077   UIma& operator=(const UIma& ima2) {copy(ima2); return *this;}
00078   bool copy(const UIma& ima2);
00083   bool setSize(int width, int height);
00084   bool setSize(int width, int height, bool preserve_ratio, bool preserve_smaller);
00090   bool rescale(float xyscale);
00091   bool rescale(float xscale, float yscale);
00097   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00098 
00099   virtual void set(const UStr& filename);
00100   virtual void set(const char* filename);
00101   virtual void set(const char** xpm_data);
00107   virtual int read(const UStr& filename, int max_w = 0, int max_h =0);
00108   virtual int read(const char* filename, int max_w = 0, int max_h =0);
00114   virtual int load();
00119   virtual int load(const char** xpm_data);
00125   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00126 
00127   bool isLoaded() const;
00133   bool isRealized() const;
00135 
00136   int getAlpha() const;
00138 
00139   int getBpp() const {return getDepth() + getAlpha();}
00141 
00142   int getDepth() const;
00144   
00145   int getHeight() const;
00146   int getWidth()  const;
00148 
00149   int getStatus() const;
00151   
00152   unsigned long getPixel(int x, int y);
00154 
00155   void setPixel(unsigned long, int x, int y);
00157 
00158   //const char* getNameChars() const;
00159   // impl (to be removed).
00160 
00161   virtual void update(); 
00163 
00164   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00165   // implementation
00166 
00167   int realize(int max_w = 0, int max_h = 0,
00168               UDisp* disp = null, bool force_reload = true) const;
00181   std::list<UNatIma*>& getNatImas() const {return natimas;}
00183 
00184   static void getFullPath(UStr& fullpath, const char* filename);
00190 #ifndef NO_DOC
00191   friend class UBox;
00192   friend class UNatIma;
00193   friend class UPix;
00194 
00195   virtual void setImpl(const char* fname);
00196   virtual void setImpl(const char** xpm_data);
00197   virtual void setImpl(int width, int height);
00198   virtual void cleanCache();
00199   virtual void getSize(UContext&, int& w, int& h) const;
00200   virtual void paint(UGraph&, UContext&, const URegion&) const;
00201 
00202   virtual class UNatIma* getOrCreateIma(class UNatDisp*, float xyscale) const;
00203   virtual class UNatIma* findImaInCache(class UNatDisp*, float xyscale) const;
00204   virtual class UNatIma* addImaInCache(class UNatDisp*, float xyscale) const;
00205   virtual class UNatPix* getOrCreatePix(class UNatDisp*, float xyscale) const
00206   {return null;}
00207 
00208 protected:
00209   UIma(const char** xpm_data, UMask);
00210   mutable std::list<class UNatIma*> natimas;
00211   char *name;
00212   const char **data;
00213   mutable signed char stat;  // can have negative values
00214   enum Mode {EMPTY, CREATE, READ_FROM_FILE, READ_FROM_DATA};
00215   mutable char mode;
00216   bool show_unknown_ima;
00217 #endif
00218 };
00219 
00220 }
00221 /* ==================================================== [TheEnd] ======= */
00222 /* ==================================================== [(c)Elc] ======= */
00223 #endif

Generated on Mon Jan 29 00:20:39 2007 for Ubit by  doxygen 1.4.7