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
40
41////////////////////////////////////////////////////////////////////////////////
42/// TGObject destructor.
43
45{
46 // Required since we overload TObject::Hash.
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Write this TGObject to a file using TImage, if filename's extension signals
52/// a valid TImage::EImageFileType, as defined by TImage::GetImageFileTypeFromFilename().
53/// Otherwise forward to TObject::SaveAs().
54
55void TGObject::SaveAs(const char* filename /*= ""*/, Option_t* option /*= ""*/) const
56{
58 if (type != TImage::kUnknown) {
60 gVirtualX->GetWindowAttributes(GetId(), wattr);
61 TImage* img = TImage::Create();
62 if (img) {
63 img->FromWindow(GetId(), 0, 0, wattr.fWidth, wattr.fHeight);
65 delete img;
66 }
67 return;
68 }
69
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Equal comparison (TGObjects are equal if they have the same
75/// window identifier). If the TGObjects have not been created by
76/// the Window manager (e.g. a TGLVEntry), then fall back to the
77/// default TObject equal comparison
78
80{
81 if (auto gobj = dynamic_cast<const TGObject *>(obj)) {
82 if (fId == 0 && gobj->fId == 0)
83 return TObject::IsEqual(obj);
84 return fId == gobj->fId;
85 }
86 // TGObject != some-other-TObject:
87 return false;
88}
89
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
#define gVirtualX
Definition TVirtualX.h:337
This class is the baseclass for all ROOT GUI widgets.
Definition TGObject.h:21
~TGObject() override
TGObject destructor.
Definition TGObject.cxx:44
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:79
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:55
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:35
virtual void FromWindow(Drawable_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition TImage.h:244
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:59
Mother of all ROOT objects.
Definition TObject.h:41
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:570
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
Definition TObject.cxx:692
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:395
Window attributes that can be inquired.
Definition GuiTypes.h:114
Int_t fHeight
width and height of window
Definition GuiTypes.h:116