File indexing completed on 2025-07-06 12:40:08

0001 /**
0002   This file belong to the KMPlayer project, a movie player plugin for Konqueror
0003   Copyright (C) 2008  Koos Vriezen <koos.vriezen@gmail.com>
0004 
0005   This library is free software; you can redistribute it and/or
0006   modify it under the terms of the GNU Lesser General Public
0007   License as published by the Free Software Foundation; either
0008   version 2 of the License, or (at your option) any later version.
0009 
0010   This library is distributed in the hope that it will be useful,
0011   but WITHOUT ANY WARRANTY; without even the implied warranty of
0012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013   Lesser General Public License for more details.
0014 
0015   You should have received a copy of the GNU Lesser General Public
0016   License along with this library; if not, write to the Free Software
0017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018 **/
0019 
0020 #ifndef _KMPLAYER_SURFACE_H_
0021 #define _KMPLAYER_SURFACE_H_
0022 
0023 #include <config-kmplayer.h>
0024 
0025 #include "kmplayer_def.h"
0026 #include "kmplayerplaylist.h"
0027 
0028 #ifdef KMPLAYER_WITH_CAIRO
0029 typedef struct _cairo_surface cairo_surface_t;
0030 #endif
0031 
0032 namespace KMPlayer {
0033 
0034 class ViewArea;
0035 
0036 class KMPLAYER_NO_EXPORT Surface : public TreeNode <Surface> {
0037 public:
0038     Surface (ViewArea *widget);
0039     ~Surface();
0040 
0041     void clear ();
0042     Surface *createSurface (NodePtr owner, const SRect & rect);
0043     IRect toScreen (const SSize &size);
0044     void resize (const SRect & rect, bool parent_resized=false);
0045     void repaint ();
0046     void repaint (const SRect &rect);
0047     void remove ();                // remove from parent, mark ancestors dirty
0048     void markDirty ();             // mark this and ancestors dirty
0049     void updateChildren (bool parent_resized=false);
0050     void setBackgroundColor (unsigned int argb);
0051 
0052     NodePtrW node;
0053     SRect bounds;                  // bounds in parent coord.
0054     SSize virtual_size;            // virtual size in screen coord.
0055     float xscale, yscale;          // internal scaling
0056     unsigned int background_color; // rgba background color
0057     unsigned short x_scroll;       // top of horizontal knob
0058     unsigned short y_scroll;       // top of vertical knob
0059 #ifdef KMPLAYER_WITH_CAIRO
0060     cairo_surface_t *surface;
0061 #endif
0062     bool dirty;                    // a decendant is removed
0063     bool scroll;
0064     bool has_mouse;
0065 
0066 private:
0067     NodePtrW current_video;
0068     ViewArea *view_widget;
0069 };
0070 
0071 typedef Item<Surface>::SharedType SurfacePtr;
0072 typedef Item<Surface>::WeakType SurfacePtrW;
0073 ITEM_AS_POINTER(KMPlayer::Surface)
0074 
0075 template <> void TreeNode<Surface>::appendChild (Surface *c);
0076 template <> void TreeNode<Surface>::insertBefore (Surface *c, Surface *b);
0077 template <> void TreeNode<Surface>::removeChild (SurfacePtr c);
0078 
0079 } // namespace
0080 
0081 #endif