theme_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 225 行
CPP
225 行
/* * =========================================================================== * PRODUCTION $Log: theme_dlg.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:45:55 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== *//* $Id $ * =========================================================================== * * 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 G. Smith * * File Description: * User-modifiable implementation file for extension of basic class, * CThemeDlg, a prototype dialog box used for editing preferences. * A suitable mediator must be supplied to instantiate one. */#include <ncbi_pch.hpp>#include <gui/dialogs/config/theme_dlg.hpp>#include <gui/dialogs/config/iconfig_mediator.hpp>#include <gui/dialogs/config/config_panel.hpp>#include <gui/utils/message_box.hpp>#include <gui/dialogs/config/edit_styles_dlg.hpp>#include <FL/fl_ask.H>BEGIN_NCBI_SCOPE#include "theme_dlg_.cpp"CThemeDlg::CThemeDlg(IConfigMediator& mediator){ m_ConfigMediator.Reset(& mediator); m_Window.reset(x_CreateWindow()); SetTitle(m_ConfigMediator->GetWindowTitle()); SetConfigPanel(* m_ConfigMediator->GetPanel().GetConfigPanel()); // populate our browser x_SetStates(m_ConfigMediator->GetStates()); // select the first thing in the state browser and Load it // NO. find out what the current state/style is and load that. // m_StyleBrowser->deselect(); // m_StyleBrowser->value(1); // m_ConfigMediator->Load(kEmptyStr); string first_state = m_ConfigMediator->GetCurrentState(); x_SetLoadedState(first_state);}void CThemeDlg::SetConfigPanel(Fl_Group& new_group){ // we don't know the size of the new group of widgets // so most of this code is moving things to accomodate it. const int configPanelOffset = 0; Fl_Window* dlg_win = m_ConfigPanelHolder->window(); // find out things relative positions before we start moving stuff around. int right_margin = dlg_win->w() - (m_ConfigPanelHolder->x() + m_ConfigPanelHolder->w()); int holder_bot_margin = dlg_win->h() - (m_ConfigPanelHolder->y() + m_ConfigPanelHolder->h()); int win_h = dlg_win->h(); int win_w = dlg_win->w(); // make the whole window the right size. // do not decrease its size. It starts at its minimum. int new_window_width = right_margin + (m_ConfigPanelHolder->x() + new_group.w() + 2*configPanelOffset); new_window_width = max(new_window_width, dlg_win->w()); int new_window_height = holder_bot_margin + (m_ConfigPanelHolder->y() + new_group.h() + 2*configPanelOffset); new_window_height = max(new_window_height, dlg_win->h()); dlg_win->size(new_window_width, new_window_height); // Right now, is the smallest this window can be. dlg_win->size_range(dlg_win->w(), dlg_win->h()); // and Add it. m_ConfigPanelHolder->clear(); new_group.position(m_ConfigPanelHolder->x() + configPanelOffset, m_ConfigPanelHolder->y() + configPanelOffset); m_ConfigPanelHolder->size(new_group.w() + 2*configPanelOffset, new_group.h() + 2*configPanelOffset); m_ConfigPanelHolder->add(& new_group);}void CThemeDlg::x_SetStates(list<string> const& states){ m_ThemeList->clear(); ITERATE(list<string>, state_it, states) { m_ThemeList->add(state_it->c_str()); }}string CThemeDlg::x_GetLoadedState(){ const char *t = m_ThemeList->text(); if (t) { return t; } return kEmptyStr;}void CThemeDlg::x_SetLoadedState(const string& theme){// m_ThemeList->value(theme.c_str()); const Fl_Menu_Item* menu_items = m_ThemeList->menu(); for (int item_n = 0; menu_items != NULL && menu_items->label() != NULL; ++menu_items, ++item_n) { if (theme == menu_items->label()) { m_ThemeList->value(item_n); return; } } return;}void CThemeDlg::x_OnUse(){ string this_state = x_GetLoadedState(); // TODO: Make auto-save optional m_ConfigMediator->Save(kEmptyStr); m_ConfigMediator->Load(this_state); m_Window->redraw(); }// Default callback for clicking the 'OK' buttonvoid CThemeDlg::x_OnOK(){ m_ConfigMediator->Save(kEmptyStr); CDialog::x_OnOK();}void CThemeDlg::x_OnDefVals(){ m_ConfigMediator->LoadDefault(); m_Window->redraw();}void CThemeDlg::x_OnShowStateDlg(){ CEditStylesDlg edit_styles(*m_ConfigMediator); edit_styles.ShowModal(); // populate our browser again x_SetStates(m_ConfigMediator->GetStates()); // find out what the current state/style is and load that. string first_state = m_ConfigMediator->GetCurrentState(); x_SetLoadedState(first_state); m_Window->redraw();}END_NCBI_SCOPE/* * =========================================================================== * $Log: theme_dlg.cpp,v $ * Revision 1000.1 2004/06/01 20:45:55 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * * Revision 1.4 2004/05/21 22:27:41 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.3 2004/01/02 21:15:31 ucko * Include edit_styles_dlg.hpp from the right directory. * * Revision 1.2 2004/01/02 21:06:44 rsmith * Add link to edit_styles dialog. * Change CComboBox to Fl_Choice. and other cleanups. * * Revision 1.1 2003/12/30 14:09:42 dicuccio * Initial check-in - moved from gui/config * * Revision 1.1 2003/12/29 14:41:37 rsmith * initial checkin * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?