colselect_dlg.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: colselect_dlg.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:08:48 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: colselect_dlg.cpp,v 1000.1 2004/06/01 21:08:48 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
- *
- * File Description:
- *
- */
- #include <ncbi_pch.hpp>
- #include "colselect_dlg.hpp"
- BEGIN_NCBI_SCOPE
- // We include the _.cpp here to avoid a compiler bug in gcc-2.95.3
- #include "colselect_dlg_.cpp"
- CColumnSelectDlg::~CColumnSelectDlg()
- {
- delete m_MainWin;
- }
- EDialogReturnValue CColumnSelectDlg::Show()
- {
- if ( !m_MainWin ) {
- return eCancel;
- }
- m_RetVal = eCancel;
- m_MainWin->show();
- while (m_MainWin->shown()) {
- Fl::wait();
- }
- return m_RetVal;
- }
- void CColumnSelectDlg::AddColumn(const string& str, int col, bool state)
- {
- if (state) {
- m_ShownData.push_back(std::make_pair(col, str));
- m_ShownList->add(str.c_str());
- } else {
- m_HiddenData.push_back(std::make_pair(col, str));
- m_HiddenList->add(str.c_str());
- }
- }
- void CColumnSelectDlg::Clear()
- {
- m_ShownData.clear();
- m_ShownList->clear();
- m_HiddenData.clear();
- m_HiddenList->clear();
- }
- vector<int> CColumnSelectDlg::GetSelected(void) const
- {
- vector<int> ret_val;
- for (size_t i = 0; i < m_ShownData.size(); ++i) {
- ret_val.push_back(m_ShownData[i].first);
- }
- return ret_val;
- }
- void CColumnSelectDlg::x_OnOK()
- {
- m_RetVal = eOK;
- m_MainWin->hide();
- }
- void CColumnSelectDlg::x_OnCancel()
- {
- m_RetVal = eCancel;
- m_MainWin->hide();
- }
- void CColumnSelectDlg::x_OnDown()
- {
- int start = -1;
- int stop = -1;
- for (int i = 1; i < m_ShownList->size()+1; ++i) {
- if ( m_ShownList->selected(i) && start == -1) {
- start = i;
- } else if ( !m_ShownList->selected(i) && start != -1) {
- stop = i - 1;
- break;
- }
- }
- if (start == -1) {
- return;
- }
- if (stop == -1 || stop >= m_ShownList->size() + 1) {
- return;
- }
- m_ShownList->remove(stop + 1);
- m_ShownList->insert(start, m_ShownData[stop].second.c_str());
- m_ShownData.insert(m_ShownData.begin() + start - 1, m_ShownData[stop]);
- m_ShownData.erase(m_ShownData.begin() + stop + 1);
- }
- void CColumnSelectDlg::x_OnUp()
- {
- int start = -1;
- int stop = -1;
- for (int i = 1; i < m_ShownList->size()+1; ++i) {
- if ( m_ShownList->selected(i) && start == -1) {
- start = i;
- } else if ( !m_ShownList->selected(i) && start != -1) {
- stop = i - 1;
- break;
- }
- }
- if (start <= 1) {
- return;
- }
- if (stop == -1) {
- stop = m_ShownList->size();
- }
- m_ShownList->insert(stop + 1, m_ShownData[start - 2].second.c_str());
- m_ShownList->remove(start - 1);
- m_ShownData.insert(m_ShownData.begin() + stop, m_ShownData[start - 2]);
- m_ShownData.erase(m_ShownData.begin() + start - 2);
- }
- void CColumnSelectDlg::x_OnHide()
- {
- int i;
- int start = -1;
- int stop = -1;
- for (int i = 1; i < m_ShownList->size()+1; ++i) {
- if ( m_ShownList->selected(i) && start == -1) {
- start = i;
- } else if ( !m_ShownList->selected(i) && start != -1) {
- stop = i - 1;
- break;
- }
- }
- if (start == -1) {
- return;
- }
- if (stop == -1) {
- stop = m_ShownList->size();
- }
- // move the items...
- for (i = start; i <= stop; ++i) {
- m_HiddenList->add(m_ShownData[start - 1].second.c_str());
- m_HiddenData.push_back(m_ShownData[start - 1]);
- m_ShownList->remove(start);
- m_ShownData.erase(m_ShownData.begin() + start - 1);
- }
- }
- void CColumnSelectDlg::x_OnShow()
- {
- int i;
- int start = -1;
- int stop = -1;
- for (int i = 1; i < m_HiddenList->size()+1; ++i) {
- if ( m_HiddenList->selected(i) && start == -1) {
- start = i;
- } else if ( !m_HiddenList->selected(i) && start != -1) {
- stop = i - 1;
- break;
- }
- }
- if (start == -1) {
- return;
- }
- if (stop == -1) {
- stop = m_HiddenList->size();
- }
- // move the items...
- for (i = start; i <= stop; ++i) {
- m_ShownList->add(m_HiddenData[start - 1].second.c_str());
- m_ShownData.push_back(m_HiddenData[start - 1]);
- m_HiddenList->remove(start);
- m_HiddenData.erase(m_HiddenData.begin() + start - 1);
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: colselect_dlg.cpp,v $
- * Revision 1000.1 2004/06/01 21:08:48 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- *
- * Revision 1.2 2004/05/21 22:27:53 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.1 2003/12/09 15:51:47 dicuccio
- * Deprecated Fl_Toggle_Tree - replaced with Flu_Tree_Browser. Added CTreeBrowser
- * as a standard tree interface
- *
- * Revision 1.6 2003/05/01 12:55:57 dicuccio
- * Fixed compiler warning about signed/unsigend comparison
- *
- * Revision 1.5 2003/02/21 17:43:32 dicuccio
- * Changed the column select dialog to avoid using a check browser - now have two
- * independent lists with back-and-forth selection
- *
- * Revision 1.4 2003/02/05 19:58:15 dicuccio
- * Implemented moving items up and down in the list
- *
- * Revision 1.3 2003/01/13 13:10:14 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted all to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.2 2003/01/08 15:04:58 dicuccio
- * Moved header files out of include/ tree -> made private
- *
- * Revision 1.1 2003/01/03 17:36:02 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */