TGObject.cxx

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGObject.cxx 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   27/12/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 /**************************************************************************
00012 
00013     This source is based on Xclass95, a Win95-looking GUI toolkit.
00014     Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
00015 
00016     Xclass95 is free software; you can redistribute it and/or
00017     modify it under the terms of the GNU Library General Public
00018     License as published by the Free Software Foundation; either
00019     version 2 of the License, or (at your option) any later version.
00020 
00021 **************************************************************************/
00022 
00023 //////////////////////////////////////////////////////////////////////////
00024 //                                                                      //
00025 // TGObject                                                             //
00026 //                                                                      //
00027 // This class is the baseclass for all ROOT GUI widgets.                //
00028 // The ROOT GUI components emulate the Win95 look and feel and the code //
00029 // is based on the XClass'95 code (see Copyleft in source).             //
00030 //                                                                      //
00031 //////////////////////////////////////////////////////////////////////////
00032 
00033 #include "TGObject.h"
00034 #include "TVirtualX.h"
00035 #include "TImage.h"
00036 
00037 ClassImp(TGObject)
00038 
00039 void TGObject::SaveAs(const char* filename /*= ""*/, Option_t* option /*= ""*/) const
00040 {
00041    // Write this TGObject to a file using TImage, if filename's extension signals 
00042    // a valid TImage::EImageFileType, as defined by TImage::GetImageFileTypeFromFilename().
00043    // Otherwise forward to TObject::SaveAs().
00044 
00045    TImage::EImageFileTypes type = TImage::GetImageFileTypeFromFilename(filename);
00046    if (type != TImage::kUnknown) {
00047       WindowAttributes_t wattr;
00048       gVirtualX->GetWindowAttributes(GetId(), wattr);
00049       TImage* img = TImage::Create();
00050       img->FromWindow(GetId(), 0, 0, wattr.fWidth, wattr.fHeight);
00051       img->WriteImage(filename, type);
00052       delete img;
00053       return;
00054    }
00055 
00056    TObject::SaveAs(filename, option);
00057 }

Generated on Tue Jul 5 14:22:02 2011 for ROOT_528-00b_version by  doxygen 1.5.1