dlg_messagebox.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:5k
- /*
- * ===========================================================================
- * PRODUCTION $Log: dlg_messagebox.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 20:54:32 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: dlg_messagebox.cpp,v 1000.1 2004/06/01 20:54:32 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: Yuri Kapustin
- *
- * File Description:
- * CDlgMessageBox -- FLTK-based message box class
- */
- #include <ncbi_pch.hpp>
- #include <corelib/ncbistd.hpp>
- #include "dlg_messagebox.hpp"
- BEGIN_NCBI_SCOPE
- CDlgMessageBox::CDlgMessageBox( const char* message, const char* title,
- EMessageBoxType type ):
- m_title(title),
- m_msg(message),
- m_btnclicked(eID_ERROR)
- {
- m_wnd = new Fl_Window(235, 100, m_title.c_str());
- m_wnd->labeltype(FL_NORMAL_LABEL);
- m_wnd->user_data((void*)(this));
- m_textbox = new Fl_Box(1, 1, 233, 45, m_msg.c_str());
- m_button[0] = m_button[1] = 0;
- switch(type) {
- case eMB_OK: {
- m_button[0] = new Fl_Button(80, 55, 85, 32, "Ok");
- }
- break;
- case eMB_CANCEL: {
- m_button[0] = new Fl_Button(80, 55, 85, 32, "Cancel");
- }
- break;
- case eMB_OKCANCEL: {
- m_button[0] = new Fl_Button(26, 55, 85, 32, "Ok");
- m_button[1] = new Fl_Button(126, 55, 85, 32, "Cancel");
- }
- break;
- case eMB_YESNO: {
- m_button[0] = new Fl_Button(26, 55, 85, 32, "Yes");
- m_button[1] = new Fl_Button(126, 55, 85, 32, "No");
- }
- break;
- }
- if(m_button[0])
- m_button[0]->callback((Fl_Callback*)x_OnButtonClicked, (void*) this);
- if(m_button[1])
- m_button[1]->callback((Fl_Callback*)x_OnButtonClicked, (void*) this);
-
- m_wnd->end();
- }
- CDlgMessageBox::~CDlgMessageBox()
- {
- delete m_textbox;
- delete m_button[0];
- delete m_button[1];
- delete m_wnd;
- }
- CDlgMessageBox::EMessageBoxButton CDlgMessageBox::DoModal()
- {
- if(!m_wnd)
- return eID_ERROR;
- m_wnd->show();
- while(m_wnd->shown()) {
- Fl::wait();
- }
- return m_btnclicked;
- }
- // button callback
- void CDlgMessageBox::x_OnButtonClicked(Fl_Button* button, void* owner)
- {
- CDlgMessageBox* pmb = reinterpret_cast<CDlgMessageBox*>(owner);
- const string btnlabel (string(button->label()));
- if(btnlabel == "Yes") {
- pmb->m_btnclicked = eID_YES;
- }
- else if(btnlabel == "No") {
- pmb->m_btnclicked = eID_NO;
- }
- else if(btnlabel == "Ok") {
- pmb->m_btnclicked = eID_OK;
- }
- else if(btnlabel == "Cancel") {
- pmb->m_btnclicked = eID_CANCEL;
- }
- pmb->m_wnd->hide();
- }
- CDlgMessageBox::EMessageBoxButton CDlgMessageBox::GetLastButtonClicked()
- {
- return m_btnclicked;
- }
- void CDlgMessageBox::Show()
- {
- if(m_wnd)
- m_wnd->show();
- }
- void CDlgMessageBox::Hide()
- {
- if(m_wnd)
- m_wnd->hide();
- }
- void CDlgMessageBox::SetText(const char* new_text)
- {
- if(m_textbox) {
- m_textbox->label(new_text);
- m_textbox->redraw();
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: dlg_messagebox.cpp,v $
- * Revision 1000.1 2004/06/01 20:54:32 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- *
- * Revision 1.5 2004/05/21 22:27:46 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.4 2003/04/22 16:01:07 kapustin
- * Rearrange init order to supress gcc warnings
- *
- * Revision 1.3 2003/03/12 21:12:07 kapustin
- * Change sub-objects destruction order
- *
- * Revision 1.2 2003/02/21 17:13:54 dicuccio
- * Changed enums in CDlgMessageBox - added leading 'e' to avoid
- * impossible-to-remove conflict with Windows code.
- *
- * Revision 1.1 2003/02/04 22:56:46 kapustin
- * Initial revision
- *
- * ===========================================================================
- */