print_options_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 193 行
CPP
193 行
/* * =========================================================================== * PRODUCTION $Log: print_options_dlg.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 21:04:15 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * PRODUCTION * =========================================================================== *//* $Id: print_options_dlg.cpp,v 1000.1 2004/06/01 21:04:15 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: Peter Meric * * File Description: * CPrintOptionsDlg - Print options dialog * */#include <ncbi_pch.hpp>#include "print_options_dlg.hpp"#include <gui/print/print_utils.hpp>#include <gui/print/print_media.hpp>#include <FL/Fl_File_Chooser.H>BEGIN_NCBI_SCOPE#include "print_options_dlg_.cpp"CPrintOptionsDlg::CPrintOptionsDlg(const CPrintOptions& opts){ m_Window.reset(x_Create()); Init(opts); m_Footer->buffer(m_FooterBuf); m_Header->buffer(m_HeaderBuf);}void CPrintOptionsDlg::Init(const CPrintOptions& opts){ // initialise fields m_Title->value(opts.GetTitle().c_str()); m_HeaderBuf.text(opts.GetHeader().c_str()); m_FooterBuf.text(opts.GetFooter().c_str()); m_HeaderOffset->value(PdfUnitsToInches(opts.GetHeaderOffset())); m_FooterOffset->value(PdfUnitsToInches(opts.GetFooterOffset())); const string& media = opts.GetMedia().GetName(); // find a set the menu item const Fl_Menu_Item* ptr = m_PaperSize->menu(); for (int i = 0; i < m_PaperSize->size(); ++i, ++ptr) { if (media == ptr->label()) { m_PaperSize->Fl_Menu_::value(ptr); x_OnSelectPaper(ptr); break; } } if (opts.GetPageOrientation() == CPrintOptions::ePortrait) { m_Portrait->setonly(); } else { m_Landscape->setonly(); } m_PagesTall->value(opts.GetPagesTall()); m_PagesWide->value(opts.GetPagesWide()); m_MarginTop->value(PdfUnitsToInches(opts.GetMarginTop())); m_MarginBottom->value(PdfUnitsToInches(opts.GetMarginBottom())); m_MarginLeft->value(PdfUnitsToInches(opts.GetMarginLeft())); m_MarginRight->value(PdfUnitsToInches(opts.GetMarginRight()));}void CPrintOptionsDlg::x_UpdateOptions(void){ m_Options.SetTitle(m_Title->value()); m_Options.SetHeader(m_HeaderBuf.text()); m_Options.SetFooter(m_FooterBuf.text()); m_Options.SetHeaderOffset(int(InchesToPdfUnits(m_HeaderOffset->value()))); m_Options.SetFooterOffset(int(InchesToPdfUnits(m_FooterOffset->value()))); m_Options.SetMedia(*m_Media); m_Options.SetPageOrientation(m_Portrait->value() == 1 ? CPrintOptions::ePortrait : CPrintOptions::eLandscape ); m_Options.SetPagesTall((unsigned int) m_PagesTall->value()); m_Options.SetPagesWide((unsigned int) m_PagesWide->value()); m_Options.SetMarginTop((unsigned int) InchesToPdfUnits(m_MarginTop->value())); m_Options.SetMarginBottom((unsigned int) InchesToPdfUnits(m_MarginBottom->value())); m_Options.SetMarginLeft((unsigned int) InchesToPdfUnits(m_MarginLeft->value())); m_Options.SetMarginRight((unsigned int) InchesToPdfUnits(m_MarginRight->value()));}void CPrintOptionsDlg::x_OnOK(){ x_UpdateOptions(); CDialog::x_OnOK();}void CPrintOptionsDlg::x_SelectPaper(const string& paper){ const CMedia& media = CMedia::GetMedia(paper); m_Media = &media; const string unit(CUnit::UnitToSymbol(media.GetUnit())); string s(NStr::IntToString(int(media.GetNativeWidth()))); s += unit + " x " + NStr::IntToString(int(media.GetNativeHeight())); s += unit; m_PaperSizeDisplay->value(s.c_str());}void CPrintOptionsDlg::x_OnSelectPaper(const Fl_Menu_Item* item){ x_SelectPaper(item->label());}CPrintOptions CPrintOptionsDlg::GetOptions(void){ return m_Options;}END_NCBI_SCOPE/* * =========================================================================== * $Log: print_options_dlg.cpp,v $ * Revision 1000.1 2004/06/01 21:04:15 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * * Revision 1.5 2004/05/21 22:27:50 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.4 2003/09/29 15:46:36 dicuccio * Inherit dialogs from CDialog * * Revision 1.3 2003/08/15 17:02:16 meric * Updates include paths for print-related files from gui/utils to gui/print * * Revision 1.2 2003/06/24 15:40:22 meric * explicit float->[unsigned] int casts to avoid compiler warnings * * Revision 1.1 2003/06/16 16:01:38 dicuccio * Moved generic print code code from opengl/print to utils. * * Revision 1.2 2003/06/16 12:44:52 dicuccio * Clean-up after initial commit * * Revision 1.1 2003 / 06 / 13 18:13:56 meric * Initial version * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?