test_config_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 327 行
CPP
327 行
/* * =========================================================================== * PRODUCTION $Log: test_config_dlg.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:46:09 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== *//* $Id $ * =========================================================================== * * 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: Robert Smith * * File Description: * Test application for plugins */#include <ncbi_pch.hpp>#include <corelib/ncbiapp.hpp>#include <corelib/ncbiargs.hpp>#include <corelib/ncbienv.hpp>#include <corelib/ncbireg.hpp>#include <serial/serial.hpp>#include <serial/objostr.hpp>#include <serial/objistr.hpp>#include <corelib/ncbifile.hpp>#include <gui/config/PluginConfigCache.hpp>#include <gui/config/settings.hpp>#include <gui/widgets/seq_graphic/color_conf.hpp>#include <gui/widgets/seq_graphic/render_policy_conf.hpp>#include <gui/widgets/seq_graphic/pane_content_conf.hpp>#include <gui/dialogs/config/config_dlg.hpp>#include <gui/dialogs/config/theme_dlg.hpp>#include <gui/dialogs/config/theme_mediator.hpp>#include <gui/dialogs/config/theme_config_panel.hpp>#include <gui/dialogs/config/theme_config_panel2.hpp>#include <gui/widgets/seq_graphic/seqgraphic_conf.hpp>#include <FL/Fl.H>#include <gui/utils/fltk_utils.hpp>//#include "test_theme_set.hpp"//#include "test_config_mediat.hpp"//#include "test_config_panel.hpp"//#include "test_settings.hpp"USING_NCBI_SCOPE;USING_SCOPE(objects);static string PreDefinedASN();//// a test exception class//class CPluginTestException : EXCEPTION_VIRTUAL_BASE public CException{public: // Enumerated list of document management errors enum EErrCode { eTestFailed }; // Translate the specific error code into a string representations of // that error code. virtual const char* GetErrCodeString(void) const { switch (GetErrCode()) { case eTestFailed: return "eTestFailed"; default: return CException::GetErrCodeString(); } } NCBI_EXCEPTION_DEFAULT(CPluginTestException, CException);};class CPluginTestApp : public CNcbiApplication{public: CPluginTestApp();private: virtual void Init(void); virtual int Run(void); virtual void Exit(void);};CPluginTestApp::CPluginTestApp(){}/////////////////////////////////////////////////////////////////////////////// Init test for all different types of argumentsvoid CPluginTestApp::Init(void){ // Create command-line argument descriptions class auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions); // Specify USAGE context arg_desc->SetUsageContext(GetArguments().GetProgramBasename(), "Test for the Configuration dialog."); // Setup arg.descriptions for this application SetupArgDescriptions(arg_desc.release());}int CPluginTestApp::Run(void){ CFltkUtils::Lock(); Fl::visual(FL_DOUBLE | FL_RGB); // Fl::scheme("plastic"); CRef<objects::CPluginConfigCache> pcc(new objects::CPluginConfigCache); string pcc_file("~/test_config.asn"); CSettings::ReadPluginConfigFromString(CSettings::GetBuiltInPluginConfig(), *pcc); CRef<CSeqGraphicConfig> configSettings(new CSeqGraphicConfig(pcc)); // create panel { CThemeConfigPanel preference_panel; // create configuration mediator from data set and panel CThemeMediator preference_mediator(*configSettings, preference_panel); // create and display dialog given the mediator. //CConfigDlg preference_dialog(preference_mediator); CThemeDlg preference_dialog(preference_mediator); int dlg_ret = preference_dialog.ShowModal(); if (eCancel != dlg_ret) { cerr << "ok chosen" << endl; // CSettings::WritePluginConfig( pcc_file , *pcc); } else { cerr << "cancel chosen, no processing done." << endl; } } { CThemeConfigPanel2 preference_panel; preference_panel.SetLayoutDirection(CThemeConfigPanel2::eLayoutDirection_Vertical); // create configuration mediator from data set and panel CThemeMediator preference_mediator(*configSettings, preference_panel); // create and display dialog given the mediator. //CConfigDlg preference_dialog(preference_mediator); CThemeDlg preference_dialog(preference_mediator); int dlg_ret = preference_dialog.ShowModal(); if (eCancel != dlg_ret) { cerr << "ok chosen" << endl; // CSettings::WritePluginConfig( pcc_file , *pcc); } else { cerr << "cancel chosen, no processing done." << endl; } } { CThemeConfigPanel2 preference_panel; preference_panel.SetLayoutDirection(CThemeConfigPanel2::eLayoutDirection_Horizontal); // create configuration mediator from data set and panel CThemeMediator preference_mediator(*configSettings, preference_panel); // create and display dialog given the mediator. //CConfigDlg preference_dialog(preference_mediator); CThemeDlg preference_dialog(preference_mediator); EDialogReturnValue dlg_ret = preference_dialog.ShowModal(); if (eCancel != dlg_ret) { cerr << "ok chosen" << endl; // CSettings::WritePluginConfig( pcc_file , *pcc); } else { cerr << "cancel chosen, no processing done." << endl; } } return 0;}/////////////////////////////////////////////////////////////////////////////// Cleanupvoid CPluginTestApp::Exit(void){ SetDiagStream(0);}namespace {#include "settings_builtin.cpp"}static string PreDefinedASN() { string result; for (const char** ps = m_BuiltInASN; ps != 0 && *ps != 0; ++ps) { result += *ps; } return result;}/////////////////////////////////////////////////////////////////////////////// MAINint main(int argc, const char* argv[]){ // Execute main application function return CPluginTestApp().AppMain(argc, argv, 0, eDS_Default, 0);}/* * =========================================================================== * $Log: test_config_dlg.cpp,v $ * Revision 1000.1 2004/06/01 20:46:09 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * * Revision 1.4 2004/05/21 22:27:41 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.3 2004/02/20 16:07:17 rsmith * Make a bit more portable and show all style of theme dialogs. * * Revision 1.2 2004/02/17 20:35:24 rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.1 2004/02/12 14:57:45 rsmith * initial checkin. Moved from gui/config/test * * Revision 1.1 2003/11/18 20:17:15 rsmith * Initial checkin. Demo of gui_config dialog. * * Revision 1.14 2003/10/24 02:13:15 ucko * Fix for new CPluginArgDialog interface * * Revision 1.13 2003/10/07 17:26:15 dicuccio * FIxed for URL -> Value conversion * * Revision 1.12 2003/09/29 15:42:05 dicuccio * Deprecated gui/scope.hpp. Merged gui/core/types.hpp into gui/types.hpp * * Revision 1.11 2003/09/04 14:01:52 dicuccio * Introduce IDocument and IView as abstract base classes for CDocument and CView * * Revision 1.10 2003/07/17 11:59:50 friedman * Include CSelectionBuffer::TSelList for SertArgs. Test Boolesn/Flag dialog widgets. * * Revision 1.9 2003/07/16 15:22:36 dicuccio * Implemented tool tips for arguments * * Revision 1.8 2003/06/20 14:47:41 dicuccio * Revised handling of plugin registration (moved GetInfo() out of plugin factory * and into each handler as a static function) * * Revision 1.7 2003/05/19 13:36:00 dicuccio * Moved gui/core/plugin/ -> gui/plugin/. Merged gui/core/algo, gui/core/doc/, * and gui/core/view/ into one library (gui/core/) * * Revision 1.6 2003/05/09 16:49:01 dicuccio * Added explicit check so that default set-constraint arguments will have their * values shown * * Revision 1.5 2003/04/25 14:15:24 dicuccio * Fix compilation errors resulting from changes to plugin API * * Revision 1.4 2003/04/21 15:13:15 dicuccio * Added real-life test arguments * * Revision 1.3 2003/04/16 11:39:50 dicuccio * Added torture-test menu with many entries * * Revision 1.2 2003/03/28 19:20:19 dicuccio * Added default argument for testing * * Revision 1.1 2003/03/20 19:57:28 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?