Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGObject.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 27/12/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGObject
25 \ingroup guiwidgets
26
27This class is the baseclass for all ROOT GUI widgets.
28The ROOT GUI components emulate the Win95 look and feel and the code
29is based on the XClass'95 code (see Copyleft in source).
30
31*/
32
33
34#include "TGObject.h"
35#include "TVirtualX.h"
36#include "TImage.h"
37#include "TROOT.h"
38
39
40////////////////////////////////////////////////////////////////////////////////
41/// TGObject destructor.
42
44{
45 // Required since we overload TObject::Hash.
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Write this TGObject to a file using TImage, if filename's extension signals
51/// a valid TImage::EImageFileType, as defined by TImage::GetImageFileTypeFromFilename().
52/// Otherwise forward to TObject::SaveAs().
53
54void TGObject::SaveAs(const char* filename /*= ""*/, Option_t* option /*= ""*/) const
55{
57 if (type != TImage::kUnknown) {
59 gVirtualX->GetWindowAttributes(GetId(), wattr);
60 TImage* img = TImage::Create();
61 if (img) {
62 img->FromWindow(GetId(), 0, 0, wattr.fWidth, wattr.fHeight);
63 img->WriteImage(filename, type);
64 delete img;
65 }
66 return;
67 }
68
69 TObject::SaveAs(filename, option);
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Equal comparison (TGObjects are equal if they have the same
74/// window identifier). If the TGObjects have not been created by
75/// the Window manager (e.g. a TGLVEntry), then fall back to the
76/// default TObject equal comparison
77
79{
80 if (auto gobj = dynamic_cast<const TGObject *>(obj)) {
81 if (fId == 0 && gobj->fId == 0)
82 return TObject::IsEqual(obj);
83 return fId == gobj->fId;
84 }
85 // TGObject != some-other-TObject:
86 return false;
87}
88
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define gVirtualX
Definition TVirtualX.h:375
~TGObject() override
TGObject destructor.
Definition TGObject.cxx:43
TGObject()
Definition TGObject.h:38
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
Bool_t IsEqual(const TObject *obj) const override
Equal comparison (TGObjects are equal if they have the same window identifier).
Definition TGObject.cxx:78
void SaveAs(const char *filename="", Option_t *option="") const override
Write this TGObject to a file using TImage, if filename's extension signals a valid TImage::EImageFil...
Definition TGObject.cxx:54
An abstract interface to image processing library.
Definition TImage.h:29
EImageFileTypes
Definition TImage.h:36
@ kUnknown
Definition TImage.h:54
static TImage * Create()
Create an image.
Definition TImage.cxx:34
virtual void FromWindow(Drawable_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition TImage.h:245
virtual void WriteImage(const char *, EImageFileTypes=TImage::kUnknown)
Definition TImage.h:115
static EImageFileTypes GetImageFileTypeFromFilename(const char *opt)
Return the image type for the extension specified in filename.
Definition TImage.cxx:58
virtual Bool_t IsEqual(const TObject *obj) const
Default equal comparison (objects are equal if they have the same address in memory).
Definition TObject.cxx:589
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
Definition TObject.cxx:708
TObject()
TObject constructor.
Definition TObject.h:259
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:406
Window attributes that can be inquired.
Definition GuiTypes.h:115
Int_t fHeight
width and height of window
Definition GuiTypes.h:117