generic_layout.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * generic_layout.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: a730d19961662f8baa4ece7571251ea9b5d30dbf $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef GENERIC_LAYOUT_HPP
00026 #define GENERIC_LAYOUT_HPP
00027 
00028 #include "skin_common.hpp"
00029 #include "top_window.hpp"
00030 #include "../utils/pointer.hpp"
00031 #include "../utils/position.hpp"
00032 
00033 #include <list>
00034 
00035 class Anchor;
00036 class OSGraphics;
00037 class CtrlGeneric;
00038 class CtrlVideo;
00039 class VarBoolImpl;
00040 
00041 
00042 /// Control and its associated layer
00043 struct LayeredControl
00044 {
00045     LayeredControl( CtrlGeneric *pControl, int layer ):
00046         m_pControl( pControl ), m_layer( layer ) { }
00047 
00048     /// Pointer on the control
00049     CtrlGeneric *m_pControl;
00050     /// Layer number
00051     int m_layer;
00052 };
00053 
00054 
00055 /// Base class for layouts
00056 class GenericLayout: public SkinObject
00057 {
00058 public:
00059     GenericLayout( intf_thread_t *pIntf, int width, int height,
00060                    int minWidth, int maxWidth, int minHeight, int maxHeight );
00061 
00062     virtual ~GenericLayout();
00063 
00064     /// Attach the layout to a window
00065     virtual void setWindow( TopWindow *pWindow );
00066 
00067     /// Get the associated window, if any
00068     virtual TopWindow *getWindow() const { return m_pWindow; }
00069 
00070     /// Called by a control which wants to capture the mouse
00071     virtual void onControlCapture( const CtrlGeneric &rCtrl );
00072 
00073     /// Called by a control which wants to release the mouse
00074     virtual void onControlRelease( const CtrlGeneric &rCtrl );
00075 
00076     /// Refresh the window
00077     virtual void refreshAll();
00078 
00079     /// Refresh a rectangular portion of the window
00080     virtual void refreshRect( int x, int y, int width, int height );
00081 
00082     /// Get the image of the layout
00083     virtual OSGraphics *getImage() const { return m_pImage; }
00084 
00085     /// Get the position of the layout (relative to the screen)
00086     /**
00087      * Note: These values are different from the m_rect.getLeft() and
00088      * m_rect.getTop(), which always return 0.
00089      * The latter methods are there as a "root rect" for the panels and
00090      * controls, since each control knows its parent rect, but returns
00091      * coordinates relative to the root rect.
00092      */
00093     virtual int getLeft() const { return m_pWindow->getLeft(); }
00094     virtual int getTop() const { return m_pWindow->getTop(); }
00095 
00096     /// Get the size of the layout
00097     virtual int getWidth() const { return m_rect.getWidth(); }
00098     virtual int getHeight() const { return m_rect.getHeight(); }
00099     virtual const GenericRect &getRect() const { return m_rect; }
00100 
00101     /// Get the minimum and maximum size of the layout
00102     virtual int getMinWidth() const { return m_minWidth; }
00103     virtual int getMaxWidth() const { return m_maxWidth; }
00104     virtual int getMinHeight() const { return m_minHeight; }
00105     virtual int getMaxHeight() const { return m_maxHeight; }
00106 
00107     /// Resize the layout
00108     virtual void resize( int width, int height );
00109 
00110     /**
00111      * Add a control in the layout at the given position, and
00112      * the optional given layer
00113      */
00114     virtual void addControl( CtrlGeneric *pControl,
00115                              const Position &rPosition,
00116                              int layer );
00117 
00118     /// Get the list of the controls in this layout, by layer order
00119     virtual const list<LayeredControl> &getControlList() const;
00120 
00121     /// Called by a control when its image has changed
00122     /**
00123      * The arguments indicate the size of the rectangle to refresh,
00124      * and the offset (from the control position) of this rectangle.
00125      * Use a negative width or height to refresh the layout completely
00126      */
00127     virtual void onControlUpdate( const CtrlGeneric &rCtrl,
00128                                   int width, int height,
00129                                   int xOffSet, int yOffSet );
00130 
00131     /// Get the list of the anchors of this layout
00132     virtual const list<Anchor*>& getAnchorList() const;
00133 
00134     /// Add an anchor to this layout
00135     virtual void addAnchor( Anchor *pAnchor );
00136 
00137     /// Called when the layout is shown
00138     virtual void onShow();
00139 
00140     /// Called when the layout is hidden
00141     virtual void onHide();
00142 
00143     /// Give access to the "active layout" variable
00144     // FIXME: we give read/write access
00145     VarBoolImpl &getActiveVar() { return *m_pVarActive; }
00146 
00147 private:
00148     /// Parent window of the layout
00149     TopWindow *m_pWindow;
00150     /// Layout size
00151     SkinsRect m_rect;
00152     int m_minWidth, m_maxWidth;
00153     int m_minHeight, m_maxHeight;
00154     /// Image of the layout
00155     OSGraphics *m_pImage;
00156     /// List of the controls in the layout
00157     list<LayeredControl> m_controlList;
00158     /// Video control(s)
00159     set<CtrlVideo *> m_pVideoCtrlSet;
00160     /// List of the anchors in the layout
00161     list<Anchor*> m_anchorList;
00162     /// Flag to know if the layout is visible
00163     bool m_visible;
00164     /// Variable for the "active state" of the layout
00165     /**
00166      * Note: the layout is not an observer on this variable, because it
00167      * cannot be changed externally (i.e. without an explicit change of
00168      * layout). This way, we avoid using a setActiveLayoutInner method.
00169      */
00170     mutable VarBoolImpl *m_pVarActive;
00171 };
00172 
00173 
00174 typedef CountedPtr<GenericLayout> GenericLayoutPtr;
00175 
00176 
00177 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6