dlg_demo.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: dlg_demo.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:05:22 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: dlg_demo.cpp,v 1000.1 2004/06/01 21:05:22 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:
- * 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 <FL/Fl.H>
- #include <gui/utils/message_box.hpp>
- USING_NCBI_SCOPE;
- class CPluginTestApp : public CNcbiApplication
- {
- public:
- virtual void Init(void);
- virtual int Run(void);
- virtual void Exit(void);
- };
- void CPluginTestApp::Init(void)
- {
- // Create command-line argument descriptions class
- auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
- // Specify USAGE context
- arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
- "Plug-in test application");
- // Setup arg.descriptions for this application
- SetupArgDescriptions(arg_desc.release());
- }
- int CPluginTestApp::Run(void)
- {
- // Get arguments
- CArgs args = GetArgs();
- #ifdef NCBI_OS_DARWIN
- // plastic scheme mimics the Darwin look-and-feel
- Fl::scheme("plastic");
- #endif
- EDialogReturnValue ret_val;
- // first dialog box: OK only
- ret_val = NcbiMessageBox("This has one button ('OK')",
- eDialog_Ok, eIcon_Info,
- "OK Dialog");
- switch (ret_val) {
- case eOK:
- cout << "user chose OK" << endl;
- break;
- case eCancel:
- LOG_POST(Error << "user chose CANCEL: invalid value");
- break;
- default:
- LOG_POST(Error << "unexpected return value: " << ret_val);
- break;
- }
- // second dialog: OK and Cancel, multi-line message
- ret_val = NcbiMessageBox("This has two buttons:n('OK' and 'Cancel')n"
- "as well as having a few longer mesagesn"
- "that span several lines,n"
- "so we can see how our justification andn"
- "text measuring stacks upnn"
- "What do you think - works or not?n",
- eDialog_OkCancel, eIcon_Exclamation,
- "OK Dialog");
- switch (ret_val) {
- case eOK:
- cout << "user chose OK" << endl;
- break;
- case eCancel:
- cout << "user chose Cancel" << endl;
- break;
- default:
- LOG_POST(Error << "unexpected return value: " << ret_val);
- break;
- }
- // third dialog: yes/no, long lines
- ret_val = NcbiMessageBox("This has two buttons ('Yes' and 'No'), and "
- "this line is exceptionally long, don't you "
- "think?",
- eDialog_YesNo, eIcon_Question,
- "OK Dialog");
- switch (ret_val) {
- case eYes:
- cout << "user chose Yes" << endl;
- break;
- case eNo:
- cout << "user chose No" << endl;
- break;
- default:
- LOG_POST(Error << "unexpected return value: " << ret_val);
- break;
- }
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Cleanup
- void CPluginTestApp::Exit(void)
- {
- SetDiagStream(0);
- }
- /////////////////////////////////////////////////////////////////////////////
- // MAIN
- int main(int argc, const char* argv[])
- {
- // Execute main application function
- return CPluginTestApp().AppMain(argc, argv, 0, eDS_Default, 0);
- }
- /*
- * ===========================================================================
- * $Log: dlg_demo.cpp,v $
- * Revision 1000.1 2004/06/01 21:05:22 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- *
- * Revision 1.3 2004/05/21 22:27:51 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.2 2003/05/30 14:15:45 dicuccio
- * Renamed MessageBox to NcbiMessageBox because brain-dead MSVC thinks this is
- * ::MessageBox and rewrites the symbol as MessageBoxA, which results in an
- * unresolved external and conflict with the Win32 API :(.
- *
- * Revision 1.1 2003/05/30 12:51:12 dicuccio
- * Moved message box code from gui/dialogs/general -> gui/utils, as it is a very
- * basic piece of code that lots of other code depends on (specifically works
- * around circular dependency with various gui/widget libraries)
- *
- * Revision 1.5 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.4 2003/05/09 16:50:28 dicuccio
- * Previous log message should have been:
- * Revised all tests - made reporting more explicit. Added tests for optional and
- * default arguments, explicitly test IsValid() and IsEmpty()
- *
- * Revision 1.3 2003/05/09 16:48:25 dicuccio
- * Added explicit verification that default set-constraint string arguments will
- * ave their menu values shown
- *
- * Revision 1.2 2003/04/25 14:15:24 dicuccio
- * Fix compilation errors resulting from changes to plugin API
- *
- * Revision 1.1 2003/03/20 19:57:28 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */