diag_panel.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:5k
- /*
- * ===========================================================================
- * PRODUCTION $Log: diag_panel.cpp,v $
- * PRODUCTION Revision 1000.4 2004/06/02 20:24:29 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: diag_panel.cpp,v 1000.4 2004/06/02 20:24:29 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/widgets/fl/diag_panel.hpp>
- #include <gui/utils/clipboard.hpp>
- #include <FL/Fl.H>
- BEGIN_NCBI_SCOPE
- CDiagPanel::CDiagPanel(int px, int py, int wid, int ht, const char* label)
- : Fl_Group(px, py, wid, ht, label)
- , m_Display(px, py, wid, ht)
- , m_OrigHandler(GetDiagHandler(true))
- {
- SetDiagHandler(this, false);
- m_Display.buffer(m_Buffer);
- m_Display.box(FL_THIN_DOWN_FRAME);
- /**
- m_Display.resize(px + Fl::box_dx(box()),
- py + Fl::box_dy(box()),
- wid - Fl::box_dw(box()),
- ht - Fl::box_dh(box()));
- **/
- resizable(&m_Display);
- m_Handler.StandardConfig();
- }
- CDiagPanel::~CDiagPanel()
- {
- RestoreOrigHandler();
- }
- void CDiagPanel::RestoreOrigHandler(void)
- {
- if (m_OrigHandler) {
- SetDiagHandler(m_OrigHandler);
- m_OrigHandler = NULL;
- }
- }
- void CDiagPanel::Post(const SDiagMessage& mess)
- {
- if (m_OrigHandler) {
- m_OrigHandler->Post(mess);
- }
- // append the text to the buffer's window
- string str(mess.m_Buffer, mess.m_BufferLen);
- //str += "n";
- if ( !str.empty() && str[ str.length()-1 ] == 'n') {
- str.erase(str.length()-1);
- }
- if (m_Buffer.length() != 0) {
- m_Buffer.append("n");
- }
- m_Buffer.append(str.c_str());
- int lines = m_Buffer.count_lines(0, m_Buffer.length());
- m_Display.scroll(lines, 0);
- }
- void CDiagPanel::SetTextSize(int size)
- {
- m_Display.textsize(size);
- }
- void CDiagPanel::SetTextFont(Fl_Font font)
- {
- m_Display.textfont(font);
- }
- int CDiagPanel::handle(int event)
- {
- m_Handler.OnFLTKEvent(event);
- switch (m_Handler.GetGUIState()) {
- case CGUIEvent::eCopyState:
- {{
- const char* sel = m_Buffer.selection_text();
- if (sel) {
- CClipboard::Clear();
- CClipboard::Add(sel);
- CClipboard::Copy();
- return 1;
- }
- }}
- break;
- default:
- break;
- }
- return Fl_Group::handle(event);
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: diag_panel.cpp,v $
- * Revision 1000.4 2004/06/02 20:24:29 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8
- *
- * Revision 1.8 2004/06/02 14:15:43 dicuccio
- * Removed Fl::check() - infinite loop in FLTK
- *
- * Revision 1.7 2004/05/28 15:09:25 dicuccio
- * Added call to Fl::check() after adding a message
- *
- * Revision 1.6 2004/05/21 22:27:53 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.5 2004/05/07 15:43:07 dicuccio
- * Use new CClipboard class - relieves dependency on objutils
- *
- * Revision 1.4 2004/05/03 13:23:57 dicuccio
- * gui/utils --> gui/objutils where needed
- *
- * Revision 1.3 2004/03/01 15:14:24 dicuccio
- * Added handling of copy events
- *
- * Revision 1.2 2003/11/26 17:17:19 dicuccio
- * Added autoscrolling
- *
- * Revision 1.1 2003/10/27 17:45:25 dicuccio
- * Added CDiagPanel
- *
- * ===========================================================================
- */