window_manager.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
- /*
- * ===========================================================================
- * PRODUCTION $Log: window_manager.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:53:43 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_WIDGETS_WORKSPACE___WINDOW_MANAGER_HPP
- #define GUI_WIDGETS_WORKSPACE___WINDOW_MANAGER_HPP
- /* $Id: window_manager.hpp,v 1000.1 2004/06/01 19:53:43 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Andrey Yazhuk
- *
- * File Description:
- *
- */
- #include <corelib/ncbistl.hpp>
- #include <corelib/ncbistd.hpp>
- #include <gui/widgets/workspace/wm_container.hpp>
- #include <gui/widgets/workspace/wm_tab_control.hpp>
- #include <gui/widgets/workspace/wm_splitter.hpp>
- #include <gui/widgets/workspace/frame_window.hpp>
- BEGIN_NCBI_SCOPE
- /// CWindowManger commands
- enum EWindowManagerCmds {
- eCmdInsHorzSplitter = 5100,
- eCmdInsVertSplitter,
- eCmdIns2x2Splitter,
- eCmdInsTabControl,
- eCmdDelTabPane,
- eCmdDelContainer,
- eCmdMoveToFrame,
- eCmdMoveFromFrame,
- eCmdMoveToPos,
- eCmdMoveToContainer,
- eCmdClientXXXX = 5200, /// initial value for programmatically generated pseudo-commands
- eCmdClientLast = 5399,
- /// last available value for programmatically generated pseudo-commands
- };
- ///////////////////////////////////////////////////////////////////////////////
- /// IWindowManagerObserver
- class IWindowManagerObserver
- {
- public:
- virtual void OnClientChanged(IWMClient* client) = 0;
- virtual ~IWindowManagerObserver() {};
- };
- class CWMRootContainer;
- ///////////////////////////////////////////////////////////////////////////////
- /// CWindowManager - component controlling windowing of client windows.
- ///
- /// CWindowManager provides centralized control other multiple clients (views)
- /// associated with an application. Window Manager provides two major ways to
- /// place clients - in independent top-level frame windows (floating) or in
- /// containers emdedded into manager's main window (docked). CWindowManager
- /// allows for dynamic creation of hierarchical layouts consisting of containers
- /// such as CSplitter and CTabControl and clients.
- /// IWMClient interface represents an abstract client window that can be
- /// managed by CWindowManager. IWMContainer interface represents an abstract
- /// container that can be embedded into CWindowManager. IWMCPosition represents
- /// abstract notion of position in IWMContainer.
- class NCBI_GUIWIDGETS_WORKSPACE_EXPORT CWindowManager : public Fl_Group,
- public CCommandTarget,
- public IWindowManager,
- public IFrameWindowClient
- {
- public:
- enum EClientState {
- eInvalid = -1,
- eFloating,
- eDocked,
- eHidden
- };
- enum EFrameCmd {
- eActivate,
- eMaximize,
- eMinimize,
- eRestore
- };
- CWindowManager();
- virtual ~CWindowManager();
- void SetObserver(IWindowManagerObserver* observer);
-
- Fl_Group* GetRootWMContainer();
- bool AddClientInFrame(IWMClient* client);
- bool AddClientInTab(IWMClient* client);
-
- bool MoveClientToFrame(IWMClient* client);
- bool MoveClientToTab(IWMClient* client);
-
- bool RemoveClient(IWMClient* client);
- void RemoveAllClients();
- IWMClient* GetActiveClient();
-
- EClientState GetClientState(IWMClient* client);
- bool FrameCommand(IWMClient* client, EFrameCmd cmd);
-
- void OnMoveToFrame(IWMContainer* container, const IWMPosition& pos);
- /// @name IWindowManager implementation
- /// @{
- virtual void GetPopupItems(IWMContainer* container, const IWMPosition& pos,
- vector<CMenuItem*>& items);
- virtual bool OnContainerCommand(IWMContainer* container,
- const IWMPosition& pos, TCmdID cmd);
- /// @}
- /// @name IFrameWindowClient implementation
- /// @{
- virtual void SetFrameWindow(CFrameWindow* frame);
- virtual const CMenuItem* GetMenu() const;
- /// @}
- /// @name Command handling
- /// @{
- DECLARE_CMD_MAP();
- void OnInsertSplitter(TCmdID cmd);
- /// @}
- protected:
- typedef vector<IWMClient*> TClients;
- struct SClientRec
- {
- IWMClient* m_pClient;
- IWMContainer* m_pContainer;
- bool m_bFrame;
- SClientRec();
- };
-
- bool x_RegisterClient(IWMClient* client);
- bool x_UnRegisterClient(IWMClient* client);
-
- SClientRec* x_GetClientRec(IWMClient* client);
- int x_GeneratePseudoCommand(IWMClient* client, int cmd);
- CMenuItem* x_GetMoveFromFrameMenu(IWMContainer* container,
- const IWMPosition& pos);
- CMenuItem* x_GetMoveHereMenu(IWMContainer* container, const IWMPosition& pos);
- bool x_OnPseudoCommand(IWMContainer* container, const IWMPosition& pos,
- TCmdID cmd);
-
- void x_PutClientInFrame(IWMClient* client);
- void x_PutClientInTab(IWMClient* client);
- void x_GetFramedClients(TClients& clients);
- void x_InsertClient(IWMClient* client, IWMContainer* container,
- const IWMPosition& pos);
-
- bool x_AddClient(IWMClient* client, bool b_frame);
- void x_Remove(IWMContainer* container, const IWMPosition& pos);
- void x_RemoveContainer(IWMContainer* container);
- void x_RemoveClient(IWMClient* client);
- void x_RemoveClient(SClientRec* rec);
- void x_CascadeRemove(IWMContainer* container, Fl_Widget* child);
- void x_ResetMenu();
- void x_InsertSplitter(IWMContainer* container, const IWMPosition& pos,
- CSplitter::EMode mode);
- void x_UpdateObserver(IWMClient* client);
-
- /// overrdining CCommandTarget behavior
- virtual bool x_ChildrenHandleCommand(const TCmdID cmd);
- virtual bool x_ChildrenUpdateCommand(const TCmdID cmd, ICmdUI* pCmdUI);
- protected:
- typedef map<IWMClient*, SClientRec*> TClientToRecMap;
- typedef map<int, pair<IWMClient*, int> > TPseudoCmdMap;
- /// maps generated commands to pair IWMClient, Command
- CMenuItem* m_MenuRoot; // root CMenuItem representing merged menus for clients
- CWMTabControl* m_pRootCont; // root IWMContainer
- TClientToRecMap m_ClientToRec;
- IWindowManagerObserver* m_pObserver;
-
- TPseudoCmdMap m_PseudoCmdMap;
- int m_PseudoCmdCount; /// number generated commands (for current popup)
- int m_DefFrameW;
- int m_DefFrameH;
- int m_PosIncr;
- int m_FrameX, m_FrameY;
- CFrameWindow* m_FrameWindow; // the frame manger belongs to
- Fl_Widget* m_PrevFocus; /// widget that previously focused
- IWMClient* m_ActiveClient;
-
- };
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: window_manager.hpp,v $
- * Revision 1000.1 2004/06/01 19:53:43 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- *
- * Revision 1.3 2004/05/20 12:24:55 dicuccio
- * Added export specifiers
- *
- * Revision 1.2 2004/05/07 14:26:49 yazhuk
- * Inherited CWindowManager from Fl_Group, CCommandTarget; implemented IFrameWindowClient
- *
- * Revision 1.1 2004/02/04 19:40:20 yazhuk
- * Initial revision
- *
- * ===========================================================================
- */
- #endif // GUI_WIDGETS_WORKSPACE___WINDOW_MANAGER_HPP