///////////////////////////////////////////////////////////////////////////// // Name: advancedprefs.cpp // tag: a advanced preferences tab. // Author: David Roundy // Modified by: // Copyright: (c) 2002 David Roundy // Licence: GPL /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes . #include #ifndef WX_PRECOMP #include #include #include #include #include #include #include #endif #include "globals.h" #include "prefmacros.h" #include "debug.h" // include config.h for VERSION #include "config.h" #include "advancedprefs.h" enum Boxes_and_stuff { CACHEDIR=37, CACHEDIR_BUTTON }; BEGIN_EVENT_TABLE(advancedPreferences, wxPanel) EVT_BUTTON(CACHEDIR_BUTTON, advancedPreferences::OnChooseCachedirClicked) END_EVENT_TABLE() // My frame constructor advancedPreferences::advancedPreferences(wxWindow *parent) : wxPanel(parent, -1) { wxButton *cachedir_button = new wxButton(this, CACHEDIR_BUTTON, "Choose..."); wxLayoutConstraints *c; // // Cache directory // wxStaticText *cache_prompt_string = new wxStaticText(this, -1, "Cache directory", wxPoint(0,0)); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 10); c->top.SameAs(this, wxTop, 10); c->height.AsIs(); c->width.AsIs(); cache_prompt_string->SetConstraints(c); wxString cachedir_str = GetCacheDir(); m_cachedir = new wxTextCtrl(this, CACHEDIR, cachedir_str); c = new wxLayoutConstraints; c->left.RightOf(cache_prompt_string, 10); c->centreY.SameAs(cache_prompt_string, wxCentreY,0); c->height.AsIs(); c->right.LeftOf(cachedir_button, 10); m_cachedir->SetConstraints(c); c = new wxLayoutConstraints; c->centreY.SameAs(cache_prompt_string, wxCentreY, 0); c->height.AsIs(); c->width.AsIs(); c->right.SameAs(this, wxRight, 10); cachedir_button->SetConstraints(c); SetAutoLayout( TRUE ); } void advancedPreferences::ApplyChanges() { wxConfig::Get()->Write("/General/Cachedir", m_cachedir->GetValue()); wxConfig::Get()->Flush(); } advancedPreferences::~advancedPreferences() { ApplyChanges(); } void advancedPreferences::OnChooseCachedirClicked(wxCommandEvent &evt) { wxString dir = wxPathOnly(m_cachedir->GetValue()); wxDirDialog mydlg(this, "Choose a directory for cache", dir); if (mydlg.ShowModal() == wxID_OK) { if (wxDirExists(mydlg.GetPath())) m_cachedir->SetValue(mydlg.GetPath()); } }