dialog.cpp

来自「ncbi源码」· C++ 代码 · 共 231 行

CPP
231
字号
/* * =========================================================================== * PRODUCTION $Log: dialog.cpp,v $ * PRODUCTION Revision 1000.3  2004/06/01 21:04:48  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * PRODUCTION * =========================================================================== *//*  $Id: dialog.cpp,v 1000.3 2004/06/01 21:04: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 <gui/utils/dialog.hpp>#include <gui/utils/fltk_utils.hpp>#include <FL/Fl_Window.H>#include <FL/Fl_Widget.H>#include <FL/Fl.H>BEGIN_NCBI_SCOPECDialog::CDialog()    : m_RetValue(eCancel){}CDialog::~CDialog(){}void CDialog::SetTitle(const string& title){    m_TitleStr = title;    m_Window->label(m_TitleStr.c_str());}// non-modal operationsvoid CDialog::Show(){    if (m_Window.get()) {        //CFltkGuard GUARD(m_Window.get());        m_Window->show();    }}void CDialog::Hide(){    if (m_Window.get()) {        //CFltkGuard GUARD(m_Window.get());        m_Window->hide();    }}// modal operationsint CDialog::Show(int argc, char** argv){    //    // This version is specifically designed for the case in which this dialog    // is the main window that will appear.  As such, we can assume that we can    // perform some basic initialization.    //    CFltkUtils::Lock();    Fl::visual(FL_DOUBLE | FL_RGB8);    if ( !m_Window.get() ) {        return -1;    }    CFltkGuard GUARD(m_Window.get());    m_Window->show(argc, argv);    return Fl::run();}EDialogReturnValue CDialog::ShowModal(){    if ( !m_Window.get() ) {        return eCancel;    }    //CFltkGuard GUARD(m_Window.get());    m_RetValue = eCancel;    Show();    while (m_Window->visible()) {        Fl::wait(0.05f);    }    return m_RetValue;}bool CDialog::IsShown(void) const{    return m_Window->shown() ? true : false;}void CDialog::Center(void){    Center(0, 0, Fl::w(), Fl::h());}void CDialog::CenterOnActive(){    Fl_Widget* w = NULL;    Fl_Window* win = NULL;    w = Fl::focus();    if (w) {        win = w->window();    }    if (win) {        Center(win);    } else {        Center();    }}void CDialog::Center(int x, int y){    if (m_Window.get()) {        m_Window->position(x - m_Window->w() / 2, y - m_Window->h() / 2);    }}void CDialog::Center(int x, int y, int w, int h){    Center(x + w/2, y + h/2);}void CDialog::Center(const Fl_Widget* w){    if (w) {        Center(w->x(), w->y(), w->w(), w->h());    }}void CDialog::x_OnOK(){    m_RetValue = eOK;    Hide();}void CDialog::x_OnCancel(){    m_RetValue = eCancel;    Hide();}END_NCBI_SCOPE/* * =========================================================================== * $Log: dialog.cpp,v $ * Revision 1000.3  2004/06/01 21:04:48  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * * Revision 1.8  2004/05/21 22:27:50  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.7  2004/04/07 13:06:01  dicuccio * Commented use of CFltkGuard * * Revision 1.6  2004/01/20 18:18:57  dicuccio * Added standard initialization to Show() where Show() is assumed to be a main * application window being shown * * Revision 1.5  2003/12/22 19:36:24  dicuccio * Added use of CFltkGuard. * * Revision 1.4  2003/12/08 18:03:06  dicuccio * Added Center() functions * * Revision 1.3  2003/12/05 17:21:44  yazhuk * Added SetTitle() * * Revision 1.2  2003/11/26 17:16:58  dicuccio * Added IsShown() * * Revision 1.1  2003/09/29 15:23:09  dicuccio * Initial revision * * Revision 1.1  2003/09/12 19:50:07  dicuccio * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

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