field_assoc.cpp
来自「ncbi源码」· C++ 代码 · 共 126 行
CPP
126 行
/* * =========================================================================== * PRODUCTION $Log: field_assoc.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:46:36 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//* * =========================================================================== * * 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: * Implementation of classes that manitains the drop down menu choices and * values used by the table entry form class CEntryFormTable. */#include <ncbi_pch.hpp>#include <gui/dialogs/entry_form/field_assoc.hpp>BEGIN_NCBI_SCOPECEntryFormMenu::CEntryFormMenu() : m_DataChanged(false){}CEntryFormMenu::CEntryFormMenu(SMenuEntryInfo* info) : m_DataChanged(false){ // first, count our items size_t count = 0; SMenuEntryInfo* ptr = info; for ( ; ptr && ptr->m_Label; ++count, ++ptr) { AddItem(ptr->m_Label, ptr->m_Value, ptr->m_Cb, ptr->m_UserData); }}void CEntryFormMenu::AddItem(const string& label, int value, Fl_Callback* cb, void* user_data){ CMenuData data; data.m_Label = label; data.m_Value = value; data.m_Cb = cb; data.m_UserData = user_data; m_MenuData.push_back(data); m_DataChanged = true;}const Fl_Menu_Item* CEntryFormMenu::GetMenuItems(void) const{ if ( !m_DataChanged ) { return m_MenuItems.get(); } m_MenuItems.reset(new Fl_Menu_Item[ m_MenuData.size() + 1 ]); Fl_Menu_Item* mi = m_MenuItems.get(); if ( !mi ) { return mi; } memset(mi, 0, sizeof(Fl_Menu_Item) * (m_MenuData.size() + 1)); int i = 0; ITERATE (list<CMenuData>, iter, m_MenuData) { mi[i].label (iter->m_Label.c_str()); mi[i].callback (iter->m_Cb); mi[i].user_data(iter->m_UserData); mi[i].labeltype(FL_NORMAL_LABEL); mi[i].labelsize(14); ++i; } m_DataChanged = false; return mi;}int CEntryFormMenu::FindEntry(int value) const{ int i = 0; ITERATE (list<CMenuData>, iter, m_MenuData) { if (iter->m_Value == value) { return i; } ++i; } return -1;} END_NCBI_SCOPE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?