field_assoc.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: field_assoc.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:47:45 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CORE_VIEW_TEXT___FIELD_ASSOC__HPP
- #define GUI_CORE_VIEW_TEXT___FIELD_ASSOC__HPP
- /*
- * ===========================================================================
- *
- * 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: Lou Friedman
- *
- * File Description:
- * Header file for classes that manitains the drop down menu choices and
- * values used by the table entry form class CEntryFormTable.
- */
- #include <corelib/ncbistd.hpp>
- #include <gui/gui.hpp>
- #include <FL/Fl_Menu_.H>
- #include <FL/Fl_Menu_Item.H>
- #include <vector>
- BEGIN_NCBI_SCOPE
- //class CObjectEntryFormView;
- // struct SMenuEntryInfo holds information about a single menu entry, and is
- // designed for specific cases of static or automatic initialization
- struct NCBI_GUIDIALOGS_EXPORT SMenuEntryInfo
- {
- const char* m_Label;
- int m_Value;
- Fl_Callback* m_Cb;
- void * m_UserData;
- };
- //
- // class CEntryFormMenu manages a drop-down list in entry forms
- //
- class NCBI_GUIDIALOGS_EXPORT CEntryFormMenu
- {
- public:
- CEntryFormMenu();
- CEntryFormMenu(SMenuEntryInfo* info);
- // add an item to the menu
- void AddItem(const string& label, int value,
- Fl_Callback* cb = NULL, void* user_data = NULL);
- // access our menu items. This may trigger creation of a menu item array.
- const Fl_Menu_Item* GetMenuItems(void) const;
- // find an entry whose value corresponds to a known value
- int FindEntry(int value) const;
- private:
- // we hold an AutoPtr<> for (optional) internal memory management
- mutable AutoPtr<Fl_Menu_Item, ArrayDeleter<Fl_Menu_Item> > m_MenuItems;
- // flag: is our internal data 'stale'?
- mutable bool m_DataChanged;
- // internal class to manage data present in a dynamic menu
- // This class has the responsibility of holding on to things such as
- // strings for labels, because FLTK doesn't copy these internally :(.
- class CMenuData
- {
- public:
- CMenuData()
- : m_Value(0),
- m_Cb(NULL),
- m_UserData(NULL) {}
- string m_Label;
- int m_Value;
- Fl_Callback* m_Cb;
- void* m_UserData;
- };
- list<CMenuData> m_MenuData;
- // copying prohibited
- CEntryFormMenu(const CEntryFormMenu&);
- CEntryFormMenu& operator= (const CEntryFormMenu&);
- };
- END_NCBI_SCOPE
- #endif