paragraph.cpp

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

CPP
221
字号
/* * =========================================================================== * PRODUCTION $Log: paragraph.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 21:02:23  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== *//* * =========================================================================== * *                            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 warrantic word - diversity?ies, 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:  Lou Friedman * * File Description: *    Implmentation of the CPargarph class used to manage genbank *      paragraphs for editing. *///#include <corelib/ncbistd.hpp>#include <ncbi_pch.hpp>#include <FL/Fl.H>#include <FL/Fl_Box.H>#include <FL/fl_draw.H>#include <objtools/format/items/item.hpp>#include <objtools/format/formatter.hpp>#include "paragraph.hpp"#include "object_editor.hpp"#include "header_editor.hpp"#include "reference_editor.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(objects);static void SetTextMeasure (Fl_Widget *w){    int ww = 0;    int wh = 0;    // get currnet font state    int current_font = fl_font();    int current_size = fl_size();    // change state, measure and set widget size    fl_font(w->labelfont(), w->labelsize());    fl_measure(w->label(), ww, wh);    w->size(ww, wh);    // return to original state    fl_font(current_font, current_size);}    // Static variable initilizationCParagraph*  CParagraph::m_CurrentSelection = NULL;/*CParagraph::CParagraph(const string& buffer, int font_size, Fl_Font font,                       const CSerialObject* topic)          : Fl_Box (0, 0, 0, 0),            m_buffer (buffer){    labelsize(font_size);    labelfont(font);    labeltype(FL_NORMAL_LABEL);    labelcolor(FL_FOREGROUND_COLOR);    align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);    label(m_buffer.c_str());    box(FL_FLAT_BOX);    color(FL_BACKGROUND2_COLOR);    SetTextMeasure(this);    m_topic = topic;    m_selected = false;}*/CParagraph::CParagraph (CConstRef<IFlatItem> item, CRef<IFormatter> formatter)    : Fl_Box (0, 0, 0, 0), m_section(0), m_selected(false), m_topic(0),       m_Item(item), m_Formatter(formatter){    box(FL_FLAT_BOX);    labelsize(12);    labelfont(FL_COURIER);    labeltype(FL_NORMAL_LABEL);    labelcolor(FL_FOREGROUND_COLOR);    color(FL_BACKGROUND2_COLOR);    align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);    m_Item->Format(*m_Formatter, *this);    m_topic = item->GetObject();}CParagraph::~CParagraph(){    if (m_selected) {        Deselect();    }}void CParagraph::AddParagraph(const list<string>& text, const CSerialObject* obj){    m_buffer = NStr::Join(text, "\n");    if ( m_buffer.empty() ) {        hide();        return;    }    label(m_buffer.c_str());    SetTextMeasure(this);    redraw();}int CParagraph::handle(int event) {    switch (event) {    case FL_PUSH:        if ( !m_selected ) {            if (m_CurrentSelection) {                m_CurrentSelection->Deselect();            }            m_EntryForm.reset();            Select();        }        if (Fl::event_clicks()) {            DoubleClick();        }        return 1;    default:        return Fl_Box::handle(event);    }}void CParagraph::EditCancled(){    m_EntryForm.reset();    Deselect();}void CParagraph::EditSaved(){    m_EntryForm.reset();    Deselect();}void CParagraph::Select() {    m_selected = true;    color(FL_SELECTION_COLOR);    labelcolor(FL_WHITE);        m_CurrentSelection = this;       redraw();             }void CParagraph::DoubleClick(){    if ( m_topic == 0 ) {        return;    }    // create the CObject edit gui and store a pointer to it.    if (m_buffer.find("LOCUS") == 0) {        m_EntryForm.reset(new CLocusEntryForm(this));    } else if (m_buffer.find("DEFINITION") == 0) {        m_EntryForm.reset(new CDefinEntryForm(this));    } else if (m_buffer.find("REFERENCE") == 0) {        m_EntryForm.reset(new CReferenceEntryForm(this));    } else {         m_EntryForm.reset(new CGenbankEntryForm(this));    }    m_EntryForm->Show();}void CParagraph::Deselect() {    color(FL_BACKGROUND2_COLOR);    labelcolor(FL_FOREGROUND_COLOR);    m_CurrentSelection = 0;    m_selected = false;    m_EntryForm.reset();    redraw();}END_NCBI_SCOPE

⌨️ 快捷键说明

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