src/gui/widgets/wx/dialog.cpp

Go to the documentation of this file.
00001 /*  $Id: dialog.cpp 17877 2008-09-24 13:03:09Z dicuccio $
00002  * ===========================================================================
00003  *
00004  *                            PUBLIC DOMAIN NOTICE
00005  *               National Center for Biotechnology Information
00006  *
00007  *  This software/database is a "United States Government Work" under the
00008  *  terms of the United States Copyright Act.  It was written as part of
00009  *  the author's official duties as a United States Government employee and
00010  *  thus cannot be copyrighted.  This software/database is freely available
00011  *  to the public for use. The National Library of Medicine and the U.S.
00012  *  Government have not placed any restriction on its use or reproduction.
00013  *
00014  *  Although all reasonable efforts have been taken to ensure the accuracy
00015  *  and reliability of the software and data, the NLM and the U.S.
00016  *  Government do not and cannot warrant the performance or results that
00017  *  may be obtained by using this software or data. The NLM and the U.S.
00018  *  Government disclaim all warranties, express or implied, including
00019  *  warranties of performance, merchantability or fitness for any particular
00020  *  purpose.
00021  *
00022  *  Please cite the author in any work or product based on this material.
00023  *
00024  * ===========================================================================
00025  *
00026  * Authors:  Andrey Yazhuk
00027  *
00028  * File Description:
00029  *
00030  */
00031 
00032 #include <ncbi_pch.hpp>
00033 
00034 #include <gui/widgets/wx/dialog.hpp>
00035 #include <gui/widgets/wx/wx_utils.hpp>
00036 
00037 BEGIN_NCBI_SCOPE
00038 
00039 CDialog::CDialog()
00040 {
00041 }
00042 
00043 
00044 void CDialog::SetRegistryPath(const string& path)
00045 {
00046     m_RegPath = path; // store for later use
00047 }
00048 
00049 
00050 static const char* kWinRectTag = "WindowRect";
00051 
00052 void CDialog::SaveSettings() const
00053 {
00054     if( ! m_RegPath.empty())   {
00055         CGuiRegistry& gui_reg = CGuiRegistry::GetInstance();
00056         CGuiRegistry::TReadWriteView view = gui_reg.GetReadWriteView(m_RegPath);
00057 
00058         x_SaveSettings(view);
00059     }
00060 }
00061 
00062 
00063 void CDialog::LoadSettings()
00064 {
00065     if( ! m_RegPath.empty())   {
00066         CGuiRegistry& gui_reg = CGuiRegistry::GetInstance();
00067         CGuiRegistry::TReadView view = gui_reg.GetReadView(m_RegPath);
00068 
00069         x_LoadSettings(view);
00070     }
00071 }
00072 
00073 
00074 void CDialog::InitDialog()
00075 {
00076     wxDialog::InitDialog();
00077 
00078     LoadSettings();
00079 }
00080 
00081 
00082 void CDialog::EndModal(int retCode)
00083 {
00084     SaveSettings();
00085 
00086     wxDialog::EndModal(retCode);
00087 }
00088 
00089 
00090 void CDialog::x_SaveSettings(CGuiRegistry::TReadWriteView& view) const
00091 {
00092     // save window rect
00093     wxRect rc = GetRect();
00094     SaveToRegistry(rc, view, kWinRectTag);
00095 }
00096 
00097 
00098 void CDialog::x_LoadSettings(CGuiRegistry::TReadView& view)
00099 {
00100     // load window rect
00101     wxRect rc = GetRect();
00102     LoadFromRegistry(rc, view, kWinRectTag);
00103     SetSize(rc);
00104 }
00105 
00106 
00107 END_NCBI_SCOPE
00108 
00109 

Generated on Wed Dec 9 04:41:19 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:18:05 2009 by modify_doxy.py rev. 173732