progress_dlg_ex.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: progress_dlg_ex.cpp,v $
- * PRODUCTION Revision 1000.3 2004/06/01 20:46:49 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: progress_dlg_ex.cpp,v 1000.3 2004/06/01 20:46:49 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/dialogs/progress/progress_dlg_ex.hpp>
- #include <gui/utils/fltk_utils.hpp>
- BEGIN_NCBI_SCOPE
- #include "progress_dlg_ex_.cpp"
- CProgressDlgEx::CProgressDlgEx()
- {
- m_Window.reset(x_CreateWindow());
- m_Buffer.reset(new Fl_Text_Buffer());
- m_Text->buffer(m_Buffer.get());
- m_Progress->minimum( 0);
- m_Progress->maximum(100);
- SetTitle("Waiting...");
- m_Window->position((Fl::w() - m_Window->w()) / 2,
- (Fl::h() - m_Window->h()) / 2);
- m_RetValue = eOK;
- }
- CProgressDlgEx::~CProgressDlgEx()
- {
- m_Window.reset();
- m_Buffer.reset();
- }
- void CProgressDlgEx::SetTitle(const string& title)
- {
- CFastMutexGuard LOCK(m_Mutex);
- //CFltkGuard FL_GUARD;
- m_TitleStr = title;
- m_Window->label(m_TitleStr.c_str());
- }
- void CProgressDlgEx::SetMessage(const string& label)
- {
- CFastMutexGuard LOCK(m_Mutex);
- //CFltkGuard FL_GUARD;
-
- if ( m_Buffer->length() != 0 ) {
- m_Buffer->append("n");
- }
- m_Buffer->append(label.c_str());
- int lines = m_Buffer->count_lines(0, m_Buffer->length());
- m_Text->scroll(lines, 0);
- m_Text->redraw();
- }
- void CProgressDlgEx::SetPctCompleted(int pct)
- {
- CFastMutexGuard LOCK(m_Mutex);
- //CFltkGuard FL_GUARD;
-
- m_Progress->value(pct);
- }
- void CProgressDlgEx::Clear(void)
- {
- CFastMutexGuard LOCK(m_Mutex);
- //CFltkGuard FL_GUARD;
-
- m_Buffer->text("");
- m_Text->redraw();
- m_RetValue = eOK;
- }
- bool CProgressDlgEx::HasBeenCanceled(void) const
- {
- return (m_RetValue == eCancel);
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: progress_dlg_ex.cpp,v $
- * Revision 1000.3 2004/06/01 20:46:49 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- *
- * Revision 1.7 2004/05/28 19:13:31 johnson
- * Added asynchronous mechanism to poll for 'cancel' message.
- *
- * Revision 1.6 2004/05/21 22:27:41 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.5 2004/04/14 20:57:22 johnson
- * added Clear() to IReporter interface
- *
- * Revision 1.4 2004/04/07 12:50:48 dicuccio
- * Commented use of CFltkGuard
- *
- * Revision 1.3 2003/12/22 19:22:15 dicuccio
- * Added calls to FLTK's locking mechanism via CFltkGuard
- *
- * Revision 1.2 2003/12/04 18:10:58 dicuccio
- * Added locking for thread safety
- *
- * Revision 1.1 2003/11/26 17:21:21 dicuccio
- * Initial version
- *
- * ===========================================================================
- */