Annotation of parser3/src/types/pa_vimage.C, revision 1.9

1.7       paf         1: /** @file
1.1       paf         2:        Parser: @b image parser type.
                      3: 
                      4:        Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
                      5: 
                      6:        Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
                      7: */
1.9     ! parser      8: static const char *RCSId="$Id: date.C,v 1.6 2001/09/04 10:50:19 parser Exp $"; 
1.1       paf         9: 
                     10: #include "pa_vimage.h"
                     11: #include "pa_vint.h"
                     12: #include "pa_vstring.h"
1.8       parser     13: #include "gif.h"
1.1       paf        14: 
1.3       paf        15: void VImage::set(const String *src, int width, int height,
1.6       paf        16:                                 gdImage* aimage) {
1.5       paf        17:        image=aimage;
1.3       paf        18: 
1.1       paf        19:        // $src
1.3       paf        20:        if(src)
                     21:                ffields.put(String(pool(), "src"), NEW VString(*src));
1.1       paf        22:        // $width
                     23:        if(width)
                     24:                ffields.put(String(pool(), "width"), NEW VInt(pool(), width));
                     25:        // $height
                     26:        if(height)
                     27:                ffields.put(String(pool(), "height"), NEW VInt(pool(), height));
1.2       paf        28: 
                     29:        // defaults
1.8       parser     30:        // $border(0)
1.2       paf        31:        ffields.put(String(pool(), "border"), NEW VInt(pool(), 0));
1.8       parser     32:        // $line-width(1) 
                     33:        ffields.put(String(pool(), "line-width"), NEW VInt(pool(), 1));
                     34: }
                     35: 
                     36: 
                     37: void VImage::put_element(const String& aname, Value *avalue) {
                     38:        ffields.put(aname, avalue);
                     39: 
                     40:        if(image)
                     41:                if(aname=="line-width") {
                     42:                        image->SetLineWidth(min(max(avalue->as_int(), 1), 10));
                     43:                } else if(aname=="line-style") {
                     44:                        const String sline_style=avalue->as_string();
                     45:                        image->SetLineStyle(sline_style.size()?sline_style.cstr(String::UL_AS_IS):0);
                     46:                }
1.1       paf        47: }

E-mail: