test_treebrowser.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:5k
- /*
- * ===========================================================================
- * PRODUCTION $Log: test_treebrowser.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:10:05 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: test_treebrowser.cpp,v 1000.1 2004/06/01 21:10:05 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 <memory>
- #include <corelib/ncbistd.hpp>
- #include <corelib/ncbiapp.hpp>
- #include <corelib/ncbienv.hpp>
- #include <corelib/ncbiargs.hpp>
- #include <gui/widgets/fl/tree_browser.hpp>
- #include <FL/Fl.H>
- #include <FL/Fl_Double_Window.H>
- #include <FL/Fl_Menu_Bar.H>
- #include <FL/Fl_Menu_.H>
- #include <FL/Fl_Button.H>
- BEGIN_NCBI_SCOPE
- #include "test_treebrowser_.cpp"
- CTreeBrowserTestUI::CTreeBrowserTestUI()
- {
- m_Window.reset(x_CreateWindow());
- m_Tree->set_root("My Root");
- }
- CTreeBrowserTestUI::~CTreeBrowserTestUI()
- {
- m_Window.reset();
- }
- void CTreeBrowserTestUI::Show(int argc, char** argv)
- {
- m_Window->show(argc, argv);
- while (m_Window->shown()) {
- Fl::wait();
- }
- }
- void CTreeBrowserTestUI::x_OnAddSub()
- {
- static int counter = 0;
- string str = "SubNode " + NStr::IntToString(++counter);
- CTreeBrowser::Node* node = m_Tree->GetSelected();
- if (node) {
- m_Tree->AddChild(str, node);
- }
- m_Tree->redraw();
- }
- void CTreeBrowserTestUI::x_OnAddLeaf()
- {
- static int counter = 0;
- string str = "Leaf " + NStr::IntToString(++counter);
- CTreeBrowser::Node* node = m_Tree->GetSelected();
- if (node) {
- m_Tree->AddLeaf(str, node);
- }
- m_Tree->redraw();
- }
- class CTestTreeApp : public CNcbiApplication
- {
- private:
- virtual void Init(void);
- virtual int Run(void);
- virtual void Exit(void);
- };
- void CTestTreeApp::Init(void)
- {
- // Create command-line argument descriptions class
- auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
- // Specify USAGE context
- arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
- "CTreeBrowser demo program");
- // Setup arg.descriptions for this application
- SetupArgDescriptions(arg_desc.release());
- }
- int CTestTreeApp::Run(void)
- {
- // Get arguments
- CArgs args = GetArgs();
- char *argv[1];
- argv[0] = "app";
- CTreeBrowserTestUI window;
- window.Show(1, argv);
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Cleanup
- void CTestTreeApp::Exit(void)
- {
- SetDiagStream(0);
- }
- /////////////////////////////////////////////////////////////////////////////
- // MAIN
- END_NCBI_SCOPE
- USING_SCOPE(ncbi);
- int main(int argc, const char* argv[])
- {
- // Execute main application function
- return CTestTreeApp().AppMain(argc, argv, 0, eDS_Default, 0);
- }
- /*
- * ===========================================================================
- * $Log: test_treebrowser.cpp,v $
- * Revision 1000.1 2004/06/01 21:10:05 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 19:08:16 dicuccio
- * Moved test_treebrowser from widgets/FLU/demo to here
- *
- * Revision 1.1 2003/12/09 15:51:31 dicuccio
- * Deprecated Fl_Toggle_Tree - replaced with Flu_Tree_Browser. Added CTreeBrowser
- * as a standard tree interface
- *
- * Revision 1.2 2003/08/21 12:06:42 dicuccio
- * Many bug fixes - Fl_Toggle_Tree is nearly completed. Reimplemented correct
- * clipping of the widget to its extent. Added scroll bar (not yet working).
- * Removed dead code
- *
- * Revision 1.1 2003/07/30 12:25:25 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */