⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferences_dialog.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* * =========================================================================== * PRODUCTION $Log: preferences_dialog.cpp,v $ * PRODUCTION Revision 1000.3  2004/06/01 18:28:58  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.20 * PRODUCTION * =========================================================================== *//*  $Id: preferences_dialog.cpp,v 1000.3 2004/06/01 18:28:58 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:  Paul Thiessen** File Description:*      dialogs for editing program preferences** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018)   // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <corelib/ncbireg.hpp>#include "preferences_dialog.hpp"#include "wx_tools.hpp"#include "opengl_renderer.hpp"#include "cn3d_tools.hpp"#include "messenger.hpp"#include "cn3d_cache.hpp"////////////////////////////////////////////////////////////////////////////////////////////////// The following is taken unmodified from wxDesigner's C++ header from preferences_dialog.wdr////////////////////////////////////////////////////////////////////////////////////////////////#include <wx/image.h>#include <wx/statline.h>#include <wx/spinbutt.h>#include <wx/spinctrl.h>#include <wx/splitter.h>#include <wx/listctrl.h>#include <wx/treectrl.h>#include <wx/notebook.h>#include <wx/grid.h>// Declare window functions#define ID_NOTEBOOK 10000#define ID_B_DONE 10001#define ID_B_CANCEL 10002wxSizer *SetupPreferencesNotebook( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_TEXT 10003#define ID_TEXTCTRL 10004#define ID_SPINBUTTON 10005#define ID_C_HIGHLIGHT 10006#define ID_RADIOBOX 10007#define ID_B_Q_LOW 10008#define ID_B_Q_MED 10009#define ID_B_Q_HIGH 10010wxSizer *SetupQualityPage( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_C_CACHE_ON 10011#define ID_LINE 10012#define ID_T_CACHE_1 10013#define ID_B_CACHE_BROWSE 10014#define ID_T_CACHE_FOLDER 10015#define ID_T_CACHE_2 10016#define ID_B_CACHE_CLEAR 10017wxSizer *SetupCachePage( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_C_ANNOT_RO 10018#define ID_T_LAUNCH 10019#define ID_T_NSTRUCT 10020#define ID_T_FOOT 10021#define ID_T_SEPARATION 10022#define ID_C_PROXIMAL 10023wxSizer *SetupAdvancedPage( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );////////////////////////////////////////////////////////////////////////////////////////////////USING_NCBI_SCOPE;BEGIN_SCOPE(Cn3D)static IntegerSpinCtrl    *giWormSegments, *giWormSides, *giBondSides, *giHelixSides, *giAtomSlices, *giAtomStacks,    *giCacheSize, *giMaxStructs, *giFootRes;static FloatingPointSpinCtrl *gfSeparation;#define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type) \    type *var; \    var = wxDynamicCast(FindWindow(id), type); \    if (!var) { \        ERRORMSG("Can't find window with id " << id); \        return; \    }BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)    EVT_CLOSE       (       PreferencesDialog::OnCloseWindow)    EVT_BUTTON      (-1,    PreferencesDialog::OnButton)    EVT_CHECKBOX    (-1,    PreferencesDialog::OnCheckbox)END_EVENT_TABLE()#define SET_ISPINCTRL_FROM_REGISTRY_VALUE(section, name, iSpinCtrl) \    do { \        int value; \        if (!RegistryGetInteger((section), (name), &value) || !((iSpinCtrl)->SetInteger(value))) \            WARNINGMSG("PreferencesDialog::PreferencesDialog() - error with " << (name)); \    } while (0)#define SET_FSPINCTRL_FROM_REGISTRY_VALUE(section, name, fSpinCtrl) \    do { \        double value; \        if (!RegistryGetDouble((section), (name), &value) || !((fSpinCtrl)->SetDouble(value))) \            WARNINGMSG("PreferencesDialog::PreferencesDialog() - error with " << (name)); \    } while (0)#define SET_CHECKBOX_FROM_REGISTRY_VALUE(section, name, id) \    do { \        bool on; \        wxCheckBox *box = wxDynamicCast(FindWindow(id), wxCheckBox); \        if (!box || !RegistryGetBoolean((section), (name), &on)) \            WARNINGMSG("PreferencesDialog::PreferencesDialog() - error with " << (name)); \        else \            box->SetValue(on); \    } while (0)#define SET_RADIOBOX_FROM_REGISTRY_VALUE(section, name, id) \    do { \        string value; \        wxRadioBox *radio = wxDynamicCast(FindWindow(id), wxRadioBox); \        if (!radio || !RegistryGetString((section), (name), &value)) \            WARNINGMSG("PreferencesDialog::PreferencesDialog() - error with " << (name)); \        else \            radio->SetStringSelection(value.c_str()); \    } while (0)#define SET_TEXTCTRL_FROM_REGISTRY_VALUE(section, name, id) \    do { \        string value; \        wxTextCtrl *text = wxDynamicCast(FindWindow(id), wxTextCtrl); \        if (!text || !RegistryGetString((section), (name), &value)) \            WARNINGMSG("PreferencesDialog::PreferencesDialog() - error with " << (name)); \        else \            text->SetValue(value.c_str()); \    } while (0)PreferencesDialog::PreferencesDialog(wxWindow *parent) :    wxDialog(parent, -1, "Preferences", wxPoint(400, 100), wxDefaultSize,        wxCAPTION | wxSYSTEM_MENU) // not resizable{    // construct the panel    wxSizer *topSizer = SetupPreferencesNotebook(this, false);    // get SpinCtrl pointers    iWormSegments = giWormSegments;    iWormSides = giWormSides;    iBondSides = giBondSides;    iHelixSides = giHelixSides;    iAtomSlices = giAtomSlices;    iAtomStacks = giAtomStacks;    iCacheSize = giCacheSize;    iMaxStructs = giMaxStructs;    iFootRes = giFootRes;    fSeparation = gfSeparation;    // set initial values    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_ATOM_SLICES, iAtomSlices);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_ATOM_STACKS, iAtomStacks);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_BOND_SIDES, iBondSides);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_WORM_SIDES, iWormSides);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_WORM_SEGMENTS, iWormSegments);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_QUALITY_HELIX_SIDES, iHelixSides);    SET_CHECKBOX_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_HIGHLIGHTS_ON, ID_C_HIGHLIGHT);    SET_RADIOBOX_FROM_REGISTRY_VALUE(REG_QUALITY_SECTION, REG_PROJECTION_TYPE, ID_RADIOBOX);    SET_CHECKBOX_FROM_REGISTRY_VALUE(REG_CACHE_SECTION, REG_CACHE_ENABLED, ID_C_CACHE_ON);    SET_TEXTCTRL_FROM_REGISTRY_VALUE(REG_CACHE_SECTION, REG_CACHE_FOLDER, ID_T_CACHE_FOLDER);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_CACHE_SECTION, REG_CACHE_MAX_SIZE, iCacheSize);    wxCommandEvent fakeCheck(wxEVT_COMMAND_CHECKBOX_CLICKED, ID_C_CACHE_ON);    OnCheckbox(fakeCheck);  // set initial GUI enabled state    SET_CHECKBOX_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_CDD_ANNOT_READONLY, ID_C_ANNOT_RO);#ifdef __WXGTK__    SET_TEXTCTRL_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_BROWSER_LAUNCH, ID_T_LAUNCH);#endif    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_MAX_N_STRUCTS, iMaxStructs);    SET_ISPINCTRL_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_FOOTPRINT_RES, iFootRes);    SET_FSPINCTRL_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_STEREO_SEPARATION, fSeparation);    SET_CHECKBOX_FROM_REGISTRY_VALUE(REG_ADVANCED_SECTION, REG_PROXIMAL_STEREO, ID_C_PROXIMAL);    // call sizer stuff    topSizer->Fit(this);    topSizer->SetSizeHints(this);}PreferencesDialog::~PreferencesDialog(void){    delete iWormSegments;    delete iWormSides;    delete iBondSides;    delete iHelixSides;    delete iAtomSlices;    delete iAtomStacks;    delete iCacheSize;    delete iMaxStructs;    delete iFootRes;    delete fSeparation;}#define SET_INTEGER_REGISTRY_VALUE_IF_DIFFERENT(section, name, iSpinCtrl, changedPtr) \    do { \        int oldValue, newValue; \        if (!RegistryGetInteger((section), (name), &oldValue)) throw "RegistryGetInteger() failed"; \        if (!((iSpinCtrl)->GetInteger(&newValue))) throw "GetInteger() failed"; \        if (newValue != oldValue) { \            if (!RegistrySetInteger((section), (name), newValue)) \                throw "RegistrySetInteger() failed"; \            if (changedPtr) *((bool*) changedPtr) = true; \        } \    } while (0)#define SET_DOUBLE_REGISTRY_VALUE_IF_DIFFERENT(section, name, fSpinCtrl, changedPtr) \    do { \        double oldValue, newValue; \        if (!RegistryGetDouble((section), (name), &oldValue)) throw "RegistryGetInteger() failed"; \        if (!((fSpinCtrl)->GetDouble(&newValue))) throw "GetInteger() failed"; \        if (newValue != oldValue) { \            if (!RegistrySetDouble((section), (name), newValue)) \                throw "RegistrySetInteger() failed"; \            if (changedPtr) *((bool*) changedPtr) = true; \        } \    } while (0)#define SET_BOOL_REGISTRY_VALUE_IF_DIFFERENT(section, name, id, changedPtr) \    do { \        bool oldValue, newValue; \        if (!RegistryGetBoolean((section), (name), &oldValue)) throw "RegistryGetBoolean() failed"; \        wxCheckBox *box = wxDynamicCast(FindWindow(id), wxCheckBox); \        if (!box) throw "Can't get wxCheckBox*"; \        newValue = box->GetValue(); \        if (newValue != oldValue) { \            if (!RegistrySetBoolean((section), (name), newValue, true)) \                throw "RegistrySetBoolean() failed"; \            if (changedPtr) *((bool*) changedPtr) = true; \        } \    } while (0)#define SET_RADIO_REGISTRY_VALUE_IF_DIFFERENT(section, name, id, changedPtr) \    do { \        string oldValue, newValue; \        if (!RegistryGetString((section), (name), &oldValue)) throw "RegistryGetString() failed"; \        wxRadioBox *radio = wxDynamicCast(FindWindow(id), wxRadioBox); \

⌨️ 快捷键说明

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