theme_mediator.cpp
来自「ncbi源码」· C++ 代码 · 共 183 行
CPP
183 行
/* * =========================================================================== * PRODUCTION $Log: theme_mediator.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:46:01 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== *//* $Id: theme_mediator.cpp,v 1000.1 2004/06/01 20:46:01 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: Robert Smith * * File Description: * Configuration Panel Interpreter default implementation. * The interface that any configuration/preference dialog uses * to modify its data and get its particular gui widges (IPanel). * * Derived classes with this interface mediate between IConfigPanel * and classes with the CSettingsSet base class, in the context of a * CConfigDlg. */#include <ncbi_pch.hpp>#include <gui/dialogs/config/theme_mediator.hpp> // this class#include <gui/config/theme_set.hpp> // our data#include <gui/dialogs/config/theme_config_panel.hpp> // our gui.BEGIN_NCBI_SCOPECThemeMediator::CThemeMediator(CThemeSet & data, IThemeConfigPanelBase& panel) : CConfigMediator(data, panel){ x_LoadFirst();}CThemeMediator::~CThemeMediator(){}/// What should we title the dialog window?string CThemeMediator::GetWindowTitle(void) const{ return "Themes";}/// Load data into the panel the first time.void CThemeMediator::x_LoadFirst(){ CThemeSet& my_data = x_GetMyDataSet(); IThemeConfigPanelBase& my_gui = x_GetMyPanel(); vector<string> items = my_data.GetTypes(); my_gui.Clear(); ITERATE(vector<string>, item_it, items) { my_gui.AddItem( *item_it, my_data.GetSetsCurrentStyleName(*item_it), my_data.GetSetsStyles(*item_it), my_data.GetSetsDescription(*item_it) ); } my_gui.MakeWidgets();} /// Load data into that panelvoid CThemeMediator::Load(const string& state){ CThemeSet& my_data = x_GetMyDataSet(); if ( ! state.empty()) { // if state is empty use the current style in the data. my_data.SetCurrentStyleName(state); my_data.LoadCurrentSettings(CSettingsSet::eLoad_Current); } IThemeConfigPanelBase& my_gui = x_GetMyPanel(); x_Load(my_data, my_gui); }/// Load 'factory default' data into that panel.void CThemeMediator::LoadDefault(void){ CThemeSet& my_data = x_GetMyDataSet(); my_data.LoadCurrentSettings(CSettingsSet::eLoad_FactDefs); IThemeConfigPanelBase& my_gui = x_GetMyPanel(); x_Load(my_data, my_gui);}void CThemeMediator::x_Load(const CThemeSet& my_data, IThemeConfigPanelBase& my_gui){ // for all the items we know about, find out from the data what the current style is // and remember it in our internal data. vector<string> items = my_data.GetTypes(); ITERATE(vector<string>, item_it, items) { my_gui.SetCurrentStyle( *item_it, my_data.GetSetsCurrentStyleName(*item_it) ); } // Update the gui to reflect that choice. my_gui.UpdateWidgets();}/// Save the panel's data.void CThemeMediator::Save(const string& ){ IThemeConfigPanelBase& my_gui = x_GetMyPanel(); CThemeSet& my_data = x_GetMyDataSet(); vector<string> items = my_data.GetTypes(); ITERATE(vector<string>, item_it, items) { my_data.SetSetsCurrentStyleName(*item_it, my_gui.GetCurrentStyle(*item_it)); } // save values into the plugin config cache. my_data.SaveCurrentSettings();}/// Has the data represented by the panel's widgets been modified?bool CThemeMediator::Modified(void) const{ return true;}// the following accessors are just to hide the ugly down casts.CThemeSet& CThemeMediator::x_GetMyDataSet(void) { return dynamic_cast<CThemeSet&>(*m_DataSet);}const CThemeSet& CThemeMediator::x_GetMyDataSet(void) const{ return dynamic_cast<const CThemeSet&>(*m_DataSet);}IThemeConfigPanelBase& CThemeMediator::x_GetMyPanel(void) { return dynamic_cast<IThemeConfigPanelBase&>(*m_ConfigPanel);}END_NCBI_SCOPE/* * =========================================================================== * $Log $ * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?