window_manager.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * window_manager.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 8f1ba64bbfd309ca0ce361d1d02b9c85e787234c $
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 WINDOW_MANAGER_HPP
00026 #define WINDOW_MANAGER_HPP
00027 
00028 #include "skin_common.hpp"
00029 #include "top_window.hpp"
00030 #include "../utils/position.hpp"
00031 #include <list>
00032 #include <map>
00033 #include <set>
00034 #include <utility>
00035 
00036 
00037 class GenericFont;
00038 class GenericLayout;
00039 class Anchor;
00040 class Tooltip;
00041 class Popup;
00042 
00043 
00044 /// Window manager for skin windows
00045 class WindowManager: public SkinObject
00046 {
00047 public:
00048     /// Direction of the resizing
00049     enum Direction_t
00050     {
00051         kResizeE,   // East
00052         kResizeSE,  // South-East
00053         kResizeS,   // South
00054         kNone       // Reserved for internal use
00055     };
00056     WindowManager( intf_thread_t *pIntf );
00057     virtual ~WindowManager();
00058 
00059     /**
00060      * Add a window to the list of known windows. Necessary if you want
00061      * your window to be movable...
00062      */
00063     void registerWindow( TopWindow &rWindow );
00064 
00065     /// Remove a previously registered window
00066     void unregisterWindow( TopWindow &rWindow );
00067 
00068     /// Tell the window manager that a move is initiated for rWindow
00069     void startMove( TopWindow &rWindow );
00070 
00071     /// Tell the window manager that the current move ended
00072     void stopMove();
00073 
00074     /**
00075      * Move the rWindow window to (left, top), and move all its
00076      * anchored windows.
00077      * If a new anchoring is detected, the windows will move accordingly.
00078      */
00079     void move( TopWindow &rWindow, int left, int top ) const;
00080 
00081     /// Tell the window manager that a resize is initiated for rLayout
00082     void startResize( GenericLayout &rLayout, Direction_t direction );
00083 
00084     /// Tell the window manager that the current resizing ended
00085     void stopResize();
00086 
00087     /**
00088      * Resize the rLayout layout to (width, height), and move all its
00089      * anchored windows, if some anchors are moved during the resizing.
00090      * If a new anchoring is detected, the windows will move (or resize)
00091      * accordingly.
00092      */
00093     void resize( GenericLayout &rLayout, int width, int height ) const;
00094 
00095     /// Maximize the given window
00096     void maximize( TopWindow &rWindow );
00097 
00098     /// Unmaximize the given window
00099     void unmaximize( TopWindow &rWindow );
00100 
00101     /// Raise all the registered windows
00102     void raiseAll() const;
00103 
00104     /// Show all the registered windows
00105     void showAll( bool firstTime = false ) const;
00106 
00107     /// Hide all the registered windows
00108     void hideAll() const;
00109 
00110     /// Synchronize the windows with their visibility variable
00111     void synchVisibility() const;
00112 
00113     /// Save the current visibility of the windows
00114     void saveVisibility();
00115 
00116     /// Restore the saved visibility of the windows
00117     void restoreVisibility() const;
00118 
00119     /// Raise the given window
00120     void raise( TopWindow &rWindow ) const { rWindow.raise(); }
00121 
00122     /// Show the given window
00123     void show( TopWindow &rWindow ) const
00124         { rWindow.show(); rWindow.setOpacity( m_alpha); }
00125 
00126     /// Hide the given window
00127     void hide( TopWindow &rWindow ) const { rWindow.hide(); }
00128 
00129     /// Set/unset all the windows on top
00130     void setOnTop( bool b_ontop );
00131 
00132     /// Toggle all the windows on top
00133     void toggleOnTop();
00134 
00135     /// Set the magnetism of screen edges
00136     void setMagnetValue( int magnet ) { m_magnet = magnet; }
00137 
00138     /// Set the alpha value of the static windows
00139     void setAlphaValue( int alpha ) { m_alpha = alpha; }
00140 
00141     /// Set the alpha value of the moving windows
00142     void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
00143 
00144     /// Create the tooltip window
00145     void createTooltip( const GenericFont &rTipFont );
00146 
00147     /// Show the tooltip window
00148     void showTooltip();
00149 
00150     /// Hide the tooltip window
00151     void hideTooltip();
00152 
00153     /// Add a layout of the given window. This new layout will be the
00154     /// active one.
00155     void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
00156 
00157     /// Change the active layout of the given window
00158     void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
00159 
00160     /// Mark the given popup as active
00161     void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
00162 
00163     /// Return the active popup, or NULL if none is active
00164     Popup * getActivePopup() const { return m_pPopup; }
00165 
00166 private:
00167     /// Some useful typedefs for lazy people like me
00168     typedef set<TopWindow*> WinSet_t;
00169     typedef list<Anchor*> AncList_t;
00170 
00171     /// Dependencies map
00172     /**
00173      * This map represents the graph of anchored windows: it associates
00174      * to a given window all the windows that are directly anchored by it.
00175      * This is not transitive, i.e. if a is in m_dep[b] and if b is in
00176      * m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
00177      * would be extremely rare...)
00178      */
00179     map<TopWindow*, WinSet_t> m_dependencies;
00180     /// Store all the windows
00181     WinSet_t m_allWindows;
00182     /**
00183      * Store the windows that were visible when saveVisibility() was
00184      * last called.
00185      */
00186     WinSet_t m_savedWindows;
00187     /// Store the moving windows
00188     /**
00189      * This set is updated at every start of move.
00190      */
00191     WinSet_t m_movingWindows;
00192     /**
00193      * Store the moving windows in the context of resizing
00194      * These sets are updated at every start of move
00195      */
00196     //@{
00197     WinSet_t m_resizeMovingE;
00198     WinSet_t m_resizeMovingS;
00199     WinSet_t m_resizeMovingSE;
00200     //@}
00201     /// Indicate whether the windows are currently on top
00202     VariablePtr m_cVarOnTop;
00203     /// Magnetism of the screen edges (= scope of action)
00204     int m_magnet;
00205     /// Alpha value of the static windows
00206     int m_alpha;
00207     /// Alpha value of the moving windows
00208     int m_moveAlpha;
00209     /// Direction of the current resizing
00210     Direction_t m_direction;
00211     /// Rect of the last maximized window
00212     SkinsRect m_maximizeRect;
00213     /// Tooltip
00214     Tooltip *m_pTooltip;
00215     /// Active popup, if any
00216     Popup *m_pPopup;
00217 
00218     /// Recursively build a set of windows anchored to the one given.
00219     void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
00220 
00221     /// Check anchoring
00222     /**
00223      * This function updates xOffset and yOffset, to take care of a new
00224      * anchoring (if any)
00225      */
00226     void checkAnchors( TopWindow *pWindow, int &xOffset, int &yOffset ) const;
00227 };
00228 
00229 
00230 #endif

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