status_bar.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: status_bar.hpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 19:52:25 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_WIDGETS_FL___STATUS_BAR__HPP
- #define GUI_WIDGETS_FL___STATUS_BAR__HPP
- /* $Id: status_bar.hpp,v 1000.2 2004/06/01 19:52:25 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: Mike DiCuccio, Andrey Yazhuk
- *
- * File Description:
- *
- */
- #include <corelib/ncbistd.hpp>
- #include <corelib/ncbimtx.hpp>
- #include <gui/gui.hpp>
- #include <gui/utils/reporter.hpp>
- #include <gui/widgets/fl/resource_manager.hpp>
- #include <FL/Fl_Group.H>
- /** @addtogroup GUI_FltkWidgets
- *
- * @{
- */
- BEGIN_NCBI_SCOPE
- class NCBI_GUIWIDGETS_FL_EXPORT ISBSlot
- {
- public:
- enum EStyles {
- fCenterText = 0x1,
- fUpBox = 0x2,
- fDownBox = 0x4,
- fResizable = 0x8,
- };
- virtual ~ISBSlot() {};
- virtual void SetStyles(int styles) = 0; /// combination of EStyles
- virtual int GetStyles() const = 0;
- virtual void SetText(const string& text) = 0;
- virtual string GetText() const = 0;
- virtual void SetImage(CFLTKImageHandle image) = 0;
- virtual CFLTKImageHandle GetImage() = 0;
- };
- ////////////////////////////////////////////////////////////////////////////////
- /// CStatusBar1
- /// Slots have fixed size
- class NCBI_GUIWIDGETS_FL_EXPORT CStatusBar1 : public Fl_Group
- {
- public:
- typedef int TSlotHandle;
-
- CStatusBar1(int x, int y, int w, int h);
- virtual ~CStatusBar1();
- virtual TSlotHandle CreateSlot(int width = 0); /// creates standard slot
- virtual TSlotHandle CreateSlot(ISBSlot* slot, int width = 0); /// installs given slot
- virtual bool RemoveSlot(TSlotHandle handle); /// removes and destroys slot
-
- virtual void SetSlotStyles(TSlotHandle handle, int styles);
- virtual int GetSlotStyles(TSlotHandle handle);
-
- virtual ISBSlot* GetSlot(TSlotHandle handle);
- virtual const ISBSlot* GetSlot(TSlotHandle handle) const;
- virtual void SetSlotText(TSlotHandle handle, const string& text);
- virtual string GetSlotText(TSlotHandle handle) const;
- virtual void SetSlotTooltip(TSlotHandle handle, const string& tooltip);
- virtual string GetSlotTooltip(TSlotHandle handle) const;
- virtual void SetSlotImage(TSlotHandle handle, CFLTKImageHandle image);
- virtual CFLTKImageHandle GetSlotImage(TSlotHandle handle);
-
- virtual void SetSlotWidth(TSlotHandle handle,int width);
- virtual int GetSlotWidth(TSlotHandle handle) const;
- virtual void ReLayout();
- /// @name FLTK overridables
- /// @{
- virtual void draw();
- virtual void resize(int x, int y, int w, int h);
- /// @}
- protected:
- virtual void x_Layout();
-
- protected:
- typedef map<TSlotHandle, ISBSlot*> THandleToSlotMap;
- typedef map<TSlotHandle, int> THandleToWidthMap;
- THandleToSlotMap m_HandleToSlot;
- THandleToWidthMap m_HandleToWidth;
- TSlotHandle m_LastHandle;
- };
- ////////////////////////////////////////////////////////////////////////////////
- /// CSBSlot
- class NCBI_GUIWIDGETS_FL_EXPORT CSBSlot : public Fl_Group,
- public ISBSlot
- {
- public:
- CSBSlot();
- /// @name ISBSlot implementation
- /// @{
- virtual void SetStyles(int styles);
- virtual int GetStyles() const;
- virtual void SetText(const string& text);
- virtual string GetText() const;
- virtual void SetImage(CFLTKImageHandle image);
- virtual CFLTKImageHandle GetImage();
- /// @}
- virtual void draw();
- //virtual int handle(int);
- protected:
- virtual void x_Draw();
- virtual void x_DrawBackground();
- virtual void x_DrawContent();
-
- protected:
- int m_Styles;
- string m_Text;
- CFLTKImageHandle m_Image;
- };
- ////////////////////////////////////////////////////////////////////////////////
- /// CStatusBar
- class NCBI_GUIWIDGETS_FL_EXPORT CStatusBar
- : public Fl_Group, public IReporter
- {
- public:
- CStatusBar(int x, int y, int w, int h, const char* label = NULL);
- const char* label(void) const;
- void label(const char* label);
- // set the current message in the status bar
- void SetMessage(const string& msg);
- // requirement of the reporter interface - null operation
- void SetPctCompleted(int pct) { }
- // requirement of the reporter interface - clear message stack
- void Clear(void);
- // push a message onto the status stack
- void PushMessage(const string& msg);
- // pop a message from the stack
- string PopMessage(void);
- protected:
- CFastMutex m_Mutex;
- // our message stack
- vector<string> m_MsgStack;
- };
- class NCBI_GUIWIDGETS_FL_EXPORT CStatusBarGuard
- {
- public:
- CStatusBarGuard(CStatusBar& bar, const string& msg);
- ~CStatusBarGuard();
- private:
- CStatusBar& m_Bar;
- };
- END_NCBI_SCOPE
- /* @} */
- /*
- * ===========================================================================
- * $Log: status_bar.hpp,v $
- * Revision 1000.2 2004/06/01 19:52:25 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- *
- * Revision 1.5 2004/05/13 17:22:17 yazhuk
- * Added ISBSlot, CSBSlot and CStatusBar1 classes
- *
- * Revision 1.4 2004/05/11 18:55:14 dicuccio
- * Added doxygen modules info
- *
- * Revision 1.3 2004/05/03 12:47:08 dicuccio
- * Added #include for gui/gui.hpp. gui/utils ->gui/objutils where needed.
- *
- * Revision 1.2 2004/04/14 20:57:22 johnson
- * added Clear() to IReporter interface
- *
- * Revision 1.1 2003/12/04 18:08:39 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */
- #endif // GUI_WIDGETS_FL___STATUS_BAR__HPP