"Fossies" - the Fresh Open Source Software Archive

Member "google-gadgets-for-linux-0.11.2/ggadget/img_element.h" (15 Mar 2009, 3204 Bytes) of package /linux/misc/old/google-gadgets-for-linux-0.11.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2   Copyright 2008 Google Inc.
    3 
    4   Licensed under the Apache License, Version 2.0 (the "License");
    5   you may not use this file except in compliance with the License.
    6   You may obtain a copy of the License at
    7 
    8        http://www.apache.org/licenses/LICENSE-2.0
    9 
   10   Unless required by applicable law or agreed to in writing, software
   11   distributed under the License is distributed on an "AS IS" BASIS,
   12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13   See the License for the specific language governing permissions and
   14   limitations under the License.
   15 */
   16 
   17 #ifndef GGADGET_IMG_ELEMENT_H__
   18 #define GGADGET_IMG_ELEMENT_H__
   19 
   20 #include <stdlib.h>
   21 #include <ggadget/basic_element.h>
   22 
   23 namespace ggadget {
   24 
   25 /**
   26  * @ingroup Elements
   27  * Class of <a href=
   28  * "http://code.google.com/apis/desktop/docs/gadget_apiref.html#img">
   29  * img element</a>.
   30  */
   31 class ImgElement : public BasicElement {
   32  public:
   33   DEFINE_CLASS_ID(0x95b5791e157d4373, BasicElement);
   34 
   35   ImgElement(View *view, const char *name);
   36   virtual ~ImgElement();
   37 
   38  protected:
   39   virtual void DoClassRegister();
   40 
   41  public:
   42   virtual bool IsPointIn(double x, double y) const;
   43 
   44  public:
   45   /** Possible values of img.cropMaintainAspect property. */
   46   enum CropMaintainAspect {
   47     CROP_FALSE = 0,
   48     CROP_TRUE,
   49     CROP_PHOTO
   50   };
   51 
   52   /** Gets the source of image to display. */
   53   Variant GetSrc() const;
   54   /**
   55    * Sets the source of image to display.
   56    * @see ViewInterface::LoadImage()
   57    */
   58   void SetSrc(const Variant &src);
   59 
   60   /** Gets the original width of the image being displayed. */
   61   double GetSrcWidth() const;
   62 
   63   /** Gets the original height of the image being displayed. */
   64   double GetSrcHeight() const;
   65 
   66   /** Gets the colorMultiply property of the image. */
   67   std::string GetColorMultiply() const;
   68   /** Sets the colorMultiply property of the image. */
   69   void SetColorMultiply(const char *color);
   70 
   71   /** Gets the cropMaintainAspect property of the image. */
   72   CropMaintainAspect GetCropMaintainAspect() const;
   73   /** Sets the cropMaintainAspect property of the image. */
   74   void SetCropMaintainAspect(CropMaintainAspect crop);
   75 
   76   /**
   77    * Gets whether the image is stretched normally or stretched only
   78    * the middle area.
   79    */
   80   bool IsStretchMiddle() const;
   81   /**
   82    * Sets whether the image is stretched normally or stretched only
   83    * the middle area. This property is only applicable if cropMaintainAspect
   84    * is @c CROP_FALSE.
   85    */
   86   void SetStretchMiddle(bool stretch_middle);
   87 
   88   /**
   89    * Resizes the image to specified @a width and @a height via reduced
   90    * resolution.
   91    * If the source image is larger than the display area,
   92    * using this method to resize the image to the output size will save
   93    * memory and improve rendering performance.
   94    */
   95   void SetSrcSize(double width, double height);
   96 
   97  public:
   98   static BasicElement *CreateInstance(View *view, const char *name);
   99 
  100  protected:
  101   virtual void DoDraw(CanvasInterface *canvas);
  102   virtual void GetDefaultSize(double *width, double *height) const;
  103 
  104  public:
  105   virtual bool HasOpaqueBackground() const;
  106 
  107  private:
  108   DISALLOW_EVIL_CONSTRUCTORS(ImgElement);
  109 
  110   class Impl;
  111   Impl *impl_;
  112 };
  113 
  114 } // namespace ggadget
  115 
  116 #endif // GGADGET_IMG_ELEMENT_H__