Annotation of parser3/src/types/pa_vimage.h, revision 1.46

1.9       paf         1: /** @file
1.1       paf         2:        Parser: @b image parser type decl.
                      3: 
1.45      paf         4:        Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
1.24      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_VIMAGE_H
                      9: #define PA_VIMAGE_H
1.26      paf        10: 
1.46    ! misha      11: static const char * const IDENT_VIMAGE_H="$Date: 2005/08/09 08:14:54 $";
1.1       paf        12: 
1.12      paf        13: #include "classes.h"
1.1       paf        14: #include "pa_common.h"
                     15: #include "pa_vstateless_object.h"
                     16: 
1.20      parser     17: // defines
                     18: 
                     19: #define VIMAGE_TYPE "image"
1.33      paf        20: #define EXIF_ELEMENT_NAME "exif"
1.20      parser     21: 
                     22: // forwards
                     23: 
1.35      paf        24: class gdImage;
                     25: 
                     26: /// simple gdImage-based font storage & text output 
                     27: class Font: public PA_Object {
                     28: public:
                     29:        
1.38      paf        30:        static const int letter_spacing;
1.35      paf        31:        int height;         ///< Font heigth
                     32:        int monospace;      ///< Default char width
                     33:        int spacebarspace; ///< spacebar width
                     34:        gdImage* ifont;
                     35:        const String& alphabet;
                     36:        
1.38      paf        37:        Font(
1.35      paf        38:                const String& aalphabet, 
                     39:                gdImage* aifont, int aheight, int amonospace, int aspacebarspace);
                     40: 
                     41:        //@{******************************** char **********************************    
                     42:        size_t index_of(char ch);
                     43:        int index_width(size_t index);
1.40      paf        44:        void index_display(gdImage& image, int x, int y, size_t index);
1.35      paf        45:        //@}
                     46:        //@{******************************* string *********************************
                     47:        int step_width(int index);
                     48:        //@}
                     49:        /// counts trailing letter_spacing, consider this OK. useful for contiuations
                     50:        int string_width(const String& s);
1.40      paf        51:        void string_display(gdImage& image, int x, int y, const String& s);     
1.35      paf        52: };
1.10      paf        53: 
1.20      parser     54: // externs
                     55: 
1.35      paf        56: extern Methoded* image_class;
1.7       paf        57: 
1.8       paf        58: /** holds img attributes 
1.1       paf        59:        and [image itself]
                     60: */
1.35      paf        61: class VImage: public VStateless_object {
1.1       paf        62: public: // Value
                     63:        
1.35      paf        64:        override const char* type() const { return VIMAGE_TYPE; }
                     65:        override VStateless_class *get_class() { return image_class; }
1.1       paf        66: 
                     67:        /// VImage: true
1.35      paf        68:        override bool as_bool() const { return true; }
1.19      parser     69: 
1.1       paf        70:        /// VImage: method,field
1.35      paf        71:        override Value* get_element(const String& aname, Value& aself, bool looking_up);
1.15      parser     72: 
                     73:        /// VImage: field
1.44      paf        74:        override const VJunction* put_element(Value& self, const String& name, Value* value, bool replace);
1.1       paf        75: 
                     76: public: // usage
                     77: 
1.35      paf        78:        void set(const String* src, int width, int height,
                     79:                gdImage* aimage,
                     80:                Value* aexif=0);
1.1       paf        81: 
1.35      paf        82:        HashStringValue& fields() { return ffields; }
1.3       paf        83: 
                     84: public:
                     85: 
1.40      paf        86:        gdImage& image() { 
                     87:                if(!fimage)
                     88:                        throw Exception("parser.runtime",
                     89:                                0,
                     90:                                "using unitialized image object");
                     91: 
                     92:                return *fimage;
                     93:        }
                     94: 
                     95:        void set_font(Font* afont) { ffont=afont; }
                     96:        Font& font() {
                     97:                if(!ffont)
                     98:                        throw Exception("parser.runtime",
                     99:                                0,
                    100:                                "set the font first");
                    101:                return *ffont;
                    102:        }
1.1       paf       103: 
                    104: private:
                    105: 
1.40      paf       106:        gdImage* fimage; 
                    107:        Font* ffont;
1.35      paf       108:        HashStringValue ffields;
                    109:        Value* fexif;
1.1       paf       110: 
                    111: };
                    112: 
                    113: #endif

E-mail: