generic_layout.hpp 4.69 KB
Newer Older
1 2 3 4
/*****************************************************************************
 * generic_layout.hpp
 *****************************************************************************
 * Copyright (C) 2003 VideoLAN
5
 * $Id$
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
 *          Olivier Teulière <ipkiss@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#ifndef GENERIC_LAYOUT_HPP
#define GENERIC_LAYOUT_HPP

#include "skin_common.hpp"
29
#include "top_window.hpp"
30 31 32 33 34
#include "../utils/pointer.hpp"
#include "../utils/position.hpp"

#include <list>

35
class Anchor;
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
class OSGraphics;
class CtrlGeneric;


/// Control and its associated layer
struct LayeredControl
{
    LayeredControl( CtrlGeneric *pControl, int layer ):
        m_pControl( pControl ), m_layer( layer ) {}

    /// Pointer on the control
    CtrlGeneric *m_pControl;
    /// Layer number
    int m_layer;
};


/// Base class for layouts
class GenericLayout: public SkinObject, public Box
{
    public:
        GenericLayout( intf_thread_t *pIntf, int width, int height,
                       int minWidth, int maxWidth, int minHeight,
                       int maxHeight );

        virtual ~GenericLayout();

        /// Attach the layout to a window
64
        virtual void setWindow( TopWindow *pWindow );
65 66

        /// Get the associated window, if any
67
        virtual TopWindow *getWindow() const { return m_pWindow; }
68 69 70 71 72 73 74 75 76 77 78 79 80

        /// Called by a control which wants to capture the mouse
        virtual void onControlCapture( const CtrlGeneric &rCtrl );

        /// Called by a control which wants to release the mouse
        virtual void onControlRelease( const CtrlGeneric &rCtrl );

        /// Refresh the window
        virtual void refreshAll();

        /// Get the image of the layout
        virtual OSGraphics *getImage() const { return m_pImage; }

81 82 83 84
        /// Get the position of the layout (relative to the screen)
        virtual int getLeft() const { return m_pWindow->getLeft(); }
        virtual int getTop() const { return m_pWindow->getTop(); }

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
        /// Get the size of the layout
        virtual int getWidth() const { return m_width; }
        virtual int getHeight() const { return m_height; }

        /// Get the minimum and maximum size of the layout
        virtual int getMinWidth() const { return m_minWidth; }
        virtual int getMaxWidth() const { return m_maxWidth; }
        virtual int getMinHeight() const { return m_minHeight; }
        virtual int getMaxHeight() const { return m_maxHeight; }

        /// Resize the layout
        virtual void resize( int width, int height );

        /// Add a control in the layout at the given position, and
        /// the optional given layer
        virtual void addControl( CtrlGeneric *pControl,
                                 const Position &rPosition,
                                 int layer );

        /// Get the list of the controls in this layout, by layer order
        virtual const list<LayeredControl> &getControlList() const;

        /// Called by a control when its image has changed
108 109
        virtual void onControlUpdate( const CtrlGeneric &rCtrl,
                                      int width, int height );
110

111 112 113 114 115 116
        /// Get the list of the anchors of this layout
        virtual const list<Anchor*>& getAnchorList() const;

        /// Add an anchor to this layout
        virtual void addAnchor( Anchor *pAnchor );

117
    private:
118 119 120
        /// Refresh a rectangular portion of the window
        void GenericLayout::refreshRect( int x, int y, int width, int height );

121
        /// Parent window of the layout
122
        TopWindow *m_pWindow;
123 124 125 126 127 128 129 130
        /// Layout size
        int m_width, m_height;
        int m_minWidth, m_maxWidth;
        int m_minHeight, m_maxHeight;
        /// Image of the layout
        OSGraphics *m_pImage;
        /// List of the controls in the layout
        list<LayeredControl> m_controlList;
131 132
        /// List of the anchors in the layout
        list<Anchor*> m_anchorList;
133 134 135 136 137 138 139
};


typedef CountedPtr<GenericLayout> GenericLayoutPtr;


#endif