⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_window.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: main_window.cpp,v $ * PRODUCTION Revision 1000.7  2004/06/01 20:48:16  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.32 * PRODUCTION * =========================================================================== *//*  $Id: main_window.cpp,v 1000.7 2004/06/01 20:48:16 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: *    CMainWindow -- main window for Genome Workbench */#include <ncbi_pch.hpp>#include "main_window.hpp"#include "plugin_mgr_dlg.hpp"#include "document_dlg.hpp"#include "gbench_frame.hpp"#include "about_dlg.hpp"#include "scanner_output_dlg.hpp"#include "browser_config_dlg.hpp"#include "browser_config.hpp"#include <corelib/ncbireg.hpp>#include <corelib/ncbiapp.hpp>#include <gui/core/algo_menu.hpp>#include <gui/core/dload_menu.hpp>#include <gui/core/selection_buffer.hpp>#include <gui/core/doc_manager.hpp>#include <gui/core/idocument.hpp>#include <gui/config/settings.hpp>#include <gui/core/version.hpp>#include <gui/core/iview.hpp>#include <gui/core/view_menu.hpp>#include <gui/utils/app_popup.hpp>#include <gui/widgets/fl/diag_panel.hpp>BEGIN_NCBI_SCOPE#include "main_window_.cpp"CMainWindow::CMainWindow()    : m_LastConsoleHeight(100){    m_Window.reset(x_CreateWindow());    CNcbiApplication* app = CNcbiApplication::Instance();    _ASSERT(app);    const CNcbiRegistry& reg = app->GetConfig();    // make sure we position our window correctly    string window_size = reg.Get("APP.MainWindow", "Position");    if ( !window_size.empty() ) {        list<string> toks;        NStr::Split(window_size, ", ", toks);        try {            int win_x = m_Window->x();            int win_y = m_Window->y();            int win_w = m_Window->w();            int win_h = m_Window->h();            switch (toks.size()) {            case 2:                {{                     list<string>::const_iterator iter = toks.begin();                     win_x = NStr::StringToInt(*iter++);                     win_y = NStr::StringToInt(*iter++);                 }}                break;            case 4:                {{                     list<string>::const_iterator iter = toks.begin();                     win_x = NStr::StringToInt(*iter++);                     win_y = NStr::StringToInt(*iter++);                     win_w = NStr::StringToInt(*iter++);                     win_h = NStr::StringToInt(*iter++);                 }}                break;            default:                // unhandled                LOG_POST(Warning << "CMainWindow(): "                         "window size = " << window_size                         << " is poorly formatted");                break;            }            m_Window->resize(win_x, win_y, win_w, win_h);        }        catch (...){        }    }    /** FIXME: not yet working    // hide the console window, if we need to    if (reg.Get("APP.MainWindow", "console") == "false") {        x_OnToggleConsole();    }    **/    // m_VersionStr and m_BuildStr must either be static or member variables    // (FLTK doesn't copy the contents, it just stores a pointer)    m_VersionStr = "version ";    m_VersionStr += NStr::IntToString(CPluginVersion::eMajor) + ".";    m_VersionStr += NStr::IntToString(CPluginVersion::eMinor);    m_Version->label(m_VersionStr.c_str());    m_BuildStr = "build ";    m_BuildStr += __DATE__;    m_BuildStr += "  ";    m_BuildStr += __TIME__;    m_BuildDate->label(m_BuildStr.c_str());    // establish the console window    m_ShowConsoleBtn->clear_visible_focus();    m_LastConsoleHeight = m_Console->h();;    m_Console->SetTextSize(10);    // create the menu managers    m_ToolMgr.reset     (new CAlgoMenuMgr     (m_ToolsMenu, "", this));    m_ViewMgr.reset     (new CViewMenuMgr     (m_ViewsMenu, "", this));    m_DocLoaderMgr.reset(new CDocLoaderMenuMgr(m_OpenMenu,  ""));    // refresh our dynamic menus    x_RefreshDynMenus();}CMainWindow::~CMainWindow(){    //    // here we dump the window state to the config file    //    // window size and position    string win_size;    win_size += NStr::IntToString(m_Window->x()) + ", ";    win_size += NStr::IntToString(m_Window->y()) + ", ";    win_size += NStr::IntToString(m_Window->w()) + ", ";    win_size += NStr::IntToString(m_Window->h());        CNcbiApplication* app = CNcbiApplication::Instance();    _ASSERT(app);    CNcbiRegistry& reg = app->GetConfig();    reg.Set("APP.MainWindow", "Position", win_size,            CNcbiRegistry::ePersistent);    // hide state of the window    reg.Set("APP.MainWindow", "Console",            NStr::BoolToString(m_Console->visible() ? true : false),            CNcbiRegistry::ePersistent);}bool CMainWindow::Shown(void) const{    return (m_Window.get()  &&  m_Window->shown());}void CMainWindow::Show(int argc, char** argv){    if (m_Window.get()) {        m_Window->show(argc, argv);    }}void CMainWindow::Show(){    if (m_Window.get()) {        m_Window->show();        m_Window->take_focus();    }}void CMainWindow::Hide(){    if (m_Window.get()) {        m_Window->hide();    }}void CMainWindow::x_OnSwitchDocs(){    const Fl_Menu_Item* item = m_OpenDocs->mvalue();    m_CurrentDoc.Reset(reinterpret_cast<IDocument*>(item->user_data()));    m_OpenDocs->label(item->label());    x_HideAllBut(m_CurrentDoc);    x_Show(m_CurrentDoc);    x_RefreshDynMenus();}void CMainWindow::Update(TUpdateFlags flags){    if (flags & (fDocumentCreated | fDocumentReleased) ) {        // remove the document items from the menu        for (int i = 0;  i < m_OpenDocs->size() - 1;  ++i) {            if (m_OpenDocs->menu()[i].label()[0] == '{') {                m_OpenDocs->remove(i);            }        }        int val = 0;        NON_CONST_ITERATE (CDocManager::TDocList, doc_iter,                            CDocManager::GetDocuments()) {            IDocument* doc = *doc_iter;            string label("{");            label += NStr::IntToString(doc->GetDocID());            label += "} " + doc->GetTitle();            // escape the forward slashes            string::size_type pos = 0;            while ( (pos = label.find_first_of("/", pos)) != string::npos) {                label.insert(pos, "\\");                pos += 2;            }            val = m_OpenDocs->add(label.c_str(), "", NULL, doc);        }        m_OpenDocs->value(val);        if (val != 0) {            m_OpenDocs->label(m_OpenDocs->mvalue()->label());            m_OpenDocs->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);        }        m_CurrentDoc.Reset();        if (CDocManager::GetDocuments().size()) {            m_CurrentDoc.Reset(CDocManager::GetDocuments().back());        }    }    if (m_OpenDocs->size() > 0) {        m_OpenDocs->activate();        m_ViewsMenu->activate();    } else {        m_OpenDocs->deactivate();        m_ViewsMenu->deactivate();        m_CurrentDoc.Reset();    }    // refresh our dynamic menus    x_RefreshDynMenus();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -