File indexing completed on 2024-12-01 12:33:49

0001 /*
0002     Large image displaying library.
0003 
0004     Copyright (C) 2004 Maks Orlovich (maksim@kde.org)
0005 
0006     Permission is hereby granted, free of charge, to any person obtaining a copy
0007     of this software and associated documentation files (the "Software"), to deal
0008     in the Software without restriction, including without limitation the rights
0009     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0010     copies of the Software, and to permit persons to whom the Software is
0011     furnished to do so, subject to the following conditions:
0012 
0013     The above copyright notice and this permission notice shall be included in
0014     all copies or substantial portions of the Software.
0015 
0016     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0017     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0018     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0019     AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0020     AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0021     CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0022 
0023 */
0024 
0025 #ifndef ANIM_PROVIDER_H
0026 #define ANIM_PROVIDER_H
0027 
0028 #include <khtml_settings.h>
0029 
0030 class QPainter;
0031 
0032 namespace khtmlImLoad
0033 {
0034 
0035 class PixmapPlane;
0036 class Image;
0037 
0038 /**
0039  A base class for animation support. This should be implemented by decoders
0040  wishing to implement animation. When this is installed, paint events
0041  for the image are redirected here.
0042 */
0043 class AnimProvider
0044 {
0045 protected:
0046     PixmapPlane *frame0;
0047     PixmapPlane *curFrame;
0048     Image       *image;
0049     bool         shouldSwitchFrame; //Set by AnimTimer
0050     KHTMLSettings::KAnimationAdvice animationAdvice;
0051 
0052     void nextFrame(); //Helper that goes to next frame or wraps around
0053 public:
0054     AnimProvider(PixmapPlane *plane, Image *img): frame0(plane), curFrame(plane),
0055         image(img), shouldSwitchFrame(false),
0056         animationAdvice(KHTMLSettings::KAnimationEnabled)
0057     {}
0058 
0059     void switchFrame();
0060 
0061     virtual ~AnimProvider();
0062 
0063     //Must be implemented to create animation provider for the given
0064     //plane describing the same animation
0065     virtual AnimProvider *clone(PixmapPlane *newParentPlane) = 0;
0066 
0067     //Must be implemented to paint the given region. Note that clipping to the
0068     //overall canvas will be performed already
0069     virtual void paint(int dx, int dy, QPainter *p, int sx, int sy, int width, int height) = 0;
0070 
0071     /**
0072      Enables or disables animations
0073     */
0074     void setShowAnimations(KHTMLSettings::KAnimationAdvice);
0075 };
0076 
0077 }
0078 
0079 #endif