generic_layout.hpp 3.99 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
29
30
31
32
33
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
 *          Olivier Teulire <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"
#include "../utils/pointer.hpp"
#include "../utils/position.hpp"

#include <list>

34
class TopWindow;
35
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
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
63
        virtual void setWindow( TopWindow *pWindow );
64
65

        /// Get the associated window, if any
66
        virtual TopWindow *getWindow() const { return m_pWindow; }
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

        /// 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; }

        /// 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
        virtual void onControlUpdate( const CtrlGeneric &rCtrl );

    private:
        /// Parent window of the layout
107
        TopWindow *m_pWindow;
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
        /// 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;
};


typedef CountedPtr<GenericLayout> GenericLayoutPtr;


#endif