Window.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #include "Window.h"
00027 
00028 #include <Base/Console.h>
00029 #include <App/Application.h>
00030 
00031 using namespace Gui;
00032 
00033 //**************************************************************************
00034 //**************************************************************************
00035 // WindowParameter
00036 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00037 
00038 
00039 //**************************************************************************
00040 // Construction/Destruction
00041 
00042 WindowParameter::WindowParameter(const char *name)
00043 {
00044   // not allowed to use a Window without a name, see the constructor of a DockWindow or a other QT Widget
00045   assert(name);
00046   //printf("Instanceate:%s\n",name);
00047 
00048   // if string is empty do not create group
00049   if ( strcmp(name, "") != 0 )
00050     _handle = getDefaultParameter()->GetGroup( name );
00051 }
00052 
00053 WindowParameter::~WindowParameter()
00054 {
00055 }
00056 
00058 bool WindowParameter::setGroupName(const char* name)
00059 {
00060   if (_handle.isValid())
00061     return false; // cannot change parameter group
00062 
00063   assert(name);
00064   std::string prefGroup = name;
00065   if (prefGroup.compare(0,15,"User parameter:") == 0 ||
00066       prefGroup.compare(0,17,"System parameter:") == 0)
00067     _handle = App::GetApplication().GetParameterGroupByPath( name );
00068   else
00069     _handle = getDefaultParameter()->GetGroup( name );
00070   return true;
00071 }
00072 
00073 void WindowParameter::OnChange(Base::Subject<const char*> &rCaller, const char * sReason)
00074 {
00075   Base::Console().Log("Parameter has changed and window (%s) has not overridden this function!",_handle->GetGroupName());
00076 }
00077 
00078 ParameterGrp::handle  WindowParameter::getWindowParameter(void)
00079 {
00080   return _handle;
00081 }
00082 
00087 ParameterGrp::handle  WindowParameter::getDefaultParameter(void)
00088 {
00089   return App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences");
00090 }

Generated on Wed Nov 23 19:01:02 2011 for FreeCAD by  doxygen 1.6.1