include/gui/widgets/wx/wm_client.hpp

Go to the documentation of this file.
00001 #ifndef GUI_WIDGETS_WORKSPACE___WM_CLIENT_HPP
00002 #define GUI_WIDGETS_WORKSPACE___WM_CLIENT_HPP
00003 
00004 /*  $Id: wm_client.hpp 20097 2009-09-11 20:34:25Z kuznets $
00005  * ===========================================================================
00006  *
00007  *                            PUBLIC DOMAIN NOTICE
00008  *               National Center for Biotechnology Information
00009  *
00010  *  This software/database is a "United States Government Work" under the
00011  *  terms of the United States Copyright Act.  It was written as part of
00012  *  the author's official duties as a United States Government employee and
00013  *  thus cannot be copyrighted.  This software/database is freely available
00014  *  to the public for use. The National Library of Medicine and the U.S.
00015  *  Government have not placed any restriction on its use or reproduction.
00016  *
00017  *  Although all reasonable efforts have been taken to ensure the accuracy
00018  *  and reliability of the software and data, the NLM and the U.S.
00019  *  Government do not and cannot warrant the performance or results that
00020  *  may be obtained by using this software or data. The NLM and the U.S.
00021  *  Government disclaim all warranties, express or implied, including
00022  *  warranties of performance, merchantability or fitness for any particular
00023  *  purpose.
00024  *
00025  *  Please cite the author in any work or product based on this material.
00026  *
00027  * ===========================================================================
00028  *
00029  * Authors:  Andrey Yazhuk
00030  *
00031  * File Description:
00032  *
00033  */
00034 
00035 #include <corelib/ncbistd.hpp>
00036 
00037 #include <gui/utils/rgba_color.hpp>
00038 
00039 class wxWindow;
00040 class wxMenu;
00041 class wxEvtHandler;
00042 
00043 BEGIN_NCBI_SCOPE
00044 
00045 ///////////////////////////////////////////////////////////////////////////////
00046 /// IWClient - abstract Window Manager client
00047 class IWMClient
00048 {
00049 public:
00050     /// CFingerprint identifies an instance of IWMClient and is used for
00051     /// labeling layout positions.
00052     /// If Fingerprint is persistent it will be saved with the layout and when
00053     /// the layout is loaded a client will be automatically instantiated based
00054     /// on the saved fingerprint using a client factory.
00055     class  CFingerprint
00056     {
00057     public:
00058         CFingerprint();
00059         CFingerprint(const string& id, bool persistent);
00060         CFingerprint(const CFingerprint& orig);
00061 
00062         bool    operator==(const CFingerprint& orig) const;
00063         bool    IsEmpty() const;
00064 
00065         /// returns a string for serialization (if persistent) or ""
00066         string  AsPersistentString() const;
00067         void    FromPersistentString(const string& s);
00068 
00069     protected:
00070         string  m_Id;
00071         bool    m_Persistent;
00072     };
00073 
00074     /// Different flavors of label types for different GUI aspects
00075     enum ELabel
00076     {
00077         eContent,  ///< Short name with content 
00078         eDetailed, ///< Detailed name
00079         eDefault = eDetailed
00080     };
00081 
00082 public:
00083     /// returns a pointer to the wxWindow representing the client
00084     virtual wxWindow* GetWindow() = 0;
00085 
00086     /// returns a pointer to the command handler (for menu commands and updates)
00087     virtual wxEvtHandler* GetCommandHandler() = 0;
00088 
00089     /// returns the client label (name) to be displayed in UI
00090     virtual string  GetClientLabel(IWMClient::ELabel ltype = IWMClient::eDefault) const = 0;
00091 
00092     /// returns an icon alias that can be used to retrieve the client's icon
00093     virtual string GetIconAlias() const = 0;
00094 
00095     /// returns a color associated with the client, n/a if NULL
00096     virtual const CRgbaColor* GetColor() const = 0;
00097 
00098     /// returns a color associated with the client
00099     virtual void SetColor(const CRgbaColor& color) = 0;
00100 
00101     /// returns menu that can be merged with main menu of an application
00102     virtual const wxMenu*  GetMenu() = 0;
00103     virtual void    UpdateMenu(wxMenu& root_menu) = 0;
00104 
00105     /// returns a fingerprint identifying the client
00106     virtual CFingerprint  GetFingerprint() const = 0;
00107 
00108     virtual ~IWMClient()    {}
00109 };
00110 
00111 
00112 ///////////////////////////////////////////////////////////////////////////////
00113 /// IWMClientFactory - IWMClient factory.
00114 
00115 class  IWMClientFactory
00116 {
00117 public:
00118     typedef IWMClient::CFingerprint TFingerprint;
00119 
00120     /// creates a client by fingerprint
00121     /// returns NULL if fingerprint is not recognized.
00122     virtual IWMClient*  CreateClient(const TFingerprint& fingerprint,
00123                                      wxWindow* parent) = 0;
00124 
00125     virtual ~IWMClientFactory() {};
00126 };
00127 
00128 
00129 END_NCBI_SCOPE
00130 
00131 
00132 #endif  // GUI_WIDGETS_WORKSPACE___WM_CLIENT_HPP
00133 
00134 

Generated on Sun Dec 6 22:05:39 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:20:38 2009 by modify_doxy.py rev. 173732