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

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.47    ! misha      11: static const char * const IDENT_VIMAGE_H="$Date: 2007/02/03 18:08:38 $";
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.47    ! misha      70:        /// VImage: true         
        !            71:        override Value& as_expr_result(bool /*return_string_as_is=false*/);
        !            72: 
1.1       paf        73:        /// VImage: method,field
1.35      paf        74:        override Value* get_element(const String& aname, Value& aself, bool looking_up);
1.15      parser     75: 
                     76:        /// VImage: field
1.44      paf        77:        override const VJunction* put_element(Value& self, const String& name, Value* value, bool replace);
1.1       paf        78: 
                     79: public: // usage
                     80: 
1.35      paf        81:        void set(const String* src, int width, int height,
                     82:                gdImage* aimage,
                     83:                Value* aexif=0);
1.1       paf        84: 
1.35      paf        85:        HashStringValue& fields() { return ffields; }
1.3       paf        86: 
                     87: public:
                     88: 
1.40      paf        89:        gdImage& image() { 
                     90:                if(!fimage)
                     91:                        throw Exception("parser.runtime",
                     92:                                0,
                     93:                                "using unitialized image object");
                     94: 
                     95:                return *fimage;
                     96:        }
                     97: 
                     98:        void set_font(Font* afont) { ffont=afont; }
                     99:        Font& font() {
                    100:                if(!ffont)
                    101:                        throw Exception("parser.runtime",
                    102:                                0,
                    103:                                "set the font first");
                    104:                return *ffont;
                    105:        }
1.1       paf       106: 
                    107: private:
                    108: 
1.40      paf       109:        gdImage* fimage; 
                    110:        Font* ffont;
1.35      paf       111:        HashStringValue ffields;
                    112:        Value* fexif;
1.1       paf       113: 
                    114: };
                    115: 
                    116: #endif

E-mail: