#include "RConfigure.h"
#include "TGResourcePool.h"
#include "TGClient.h"
#include "TGWindow.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TEnv.h"
#include "TVirtualX.h"
#include "TGGC.h"
#include "TGPicture.h"
#include "TGFont.h"
#include "TGMimeTypes.h"
const int gray_width = 8;
const int gray_height = 8;
static unsigned char gray_bits[] = {
0x55, 0xaa, 0x55, 0xaa,
0x55, 0xaa, 0x55, 0xaa
};
ClassImp(TGResourcePool)
TGResourcePool::TGResourcePool(TGClient *client)
{
fClient = client;
fDefaultColormap = gVirtualX->GetColormap();
TString default_font = gEnv->GetValue("Gui.DefaultFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
TString menu_font = gEnv->GetValue("Gui.MenuFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
TString menu_hi_font = gEnv->GetValue("Gui.MenuHiFont", "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
TString doc_fixed_font = gEnv->GetValue("Gui.DocFixedFont", "-*-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
TString doc_prop_font = gEnv->GetValue("Gui.DocPropFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
TString icon_font = gEnv->GetValue("Gui.IconFont", "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1");
TString status_font = gEnv->GetValue("Gui.StatusFont", "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1");
TString backcolor = gEnv->GetValue("Gui.BackgroundColor", "#e0e0e0");
TString forecolor = gEnv->GetValue("Gui.ForegroundColor", "black");
TString highlightcolor = gEnv->GetValue("Gui.HighLightColor", "#d0d0d0");
TString selbackcolor = gEnv->GetValue("Gui.SelectBackgroundColor", "#86abd9");
TString selforecolor = gEnv->GetValue("Gui.SelectForegroundColor", "white");
TString docbackcolor = gEnv->GetValue("Gui.DocumentBackgroundColor", "white");
TString docforecolor = gEnv->GetValue("Gui.DocumentForegroundColor", "black");
TString tipbackcolor = gEnv->GetValue("Gui.TooltipBackgroundColor", "LightYellow");
TString tipforecolor = gEnv->GetValue("Gui.TooltipForegroundColor", "black");
TString framebgpixmap = gEnv->GetValue("Gui.FrameBackgroundPixmap", "");
TString docbgpixmap = gEnv->GetValue("Gui.DocumentBackgroundPixmap", "");
TString icon_path;
TString mime_file;
TString line;
#ifndef R__WIN32
# ifdef ROOTICONPATH
icon_path = TString::Format("%s/icons:%s:.:", gSystem->HomeDirectory(),
ROOTICONPATH);
# ifdef EXTRAICONPATH
icon_path += gEnv->GetValue("Gui.IconPath", EXTRAICONPATH);
# else
icon_path += gEnv->GetValue("Gui.IconPath", "");
# endif
# else
icon_path = TString::Format("%s/icons:%s/icons:.:", gSystem->HomeDirectory(),
gSystem->Getenv("ROOTSYS"));
icon_path += gEnv->GetValue("Gui.IconPath", "");
# endif
line = TString::Format("%s/.root.mimes", gSystem->HomeDirectory());
mime_file = gEnv->GetValue("Gui.MimeTypeFile", line.Data());
char *mf = gSystem->ExpandPathName(mime_file.Data());
if (mf) {
mime_file = mf;
delete [] mf;
}
if (gSystem->AccessPathName(mime_file, kReadPermission))
#ifdef ROOTETCDIR
mime_file = TString::Format("%s/root.mimes", ROOTETCDIR);
#else
mime_file = TString::Format("%s/etc/root.mimes", gSystem->Getenv("ROOTSYS"));
#endif
#else // R__WIN32
icon_path = TString::Format("%s\\icons:.:\\", gSystem->Getenv("ROOTSYS"));
icon_path += gEnv->GetValue("Gui.IconPath", "");
line = TString::Format("%s\\root.mimes", gSystem->HomeDirectory());
mime_file = gEnv->GetValue("Gui.MimeTypeFile", line.Data());
if (gSystem->AccessPathName(mime_file, kReadPermission))
mime_file = TString::Format("%s\\etc\\root.mimes", gSystem->Getenv("ROOTSYS"));
#endif
fClient->GetColorByName("white", fWhite);
fClient->GetColorByName("black", fBlack);
if (!fClient->GetColorByName(backcolor, fBackColor))
fBackColor = fWhite;
if (!fClient->GetColorByName(forecolor, fForeColor))
fForeColor = fBlack;
if (!fClient->GetColorByName(highlightcolor, fHighLightColor))
fHighLightColor = fWhite;
fHilite = fClient->GetHilite(fBackColor);
fShadow = fClient->GetShadow(fBackColor);
if (!fClient->GetColorByName(selbackcolor, fSelBackColor))
fSelBackColor = fBlack;
if (!fClient->GetColorByName(selforecolor, fSelForeColor))
fSelForeColor = fWhite;
if (!fClient->GetColorByName(docbackcolor, fDocBackColor))
fDocBackColor = fWhite;
if (!fClient->GetColorByName(docforecolor, fDocForeColor))
fDocForeColor = fBlack;
if (!fClient->GetColorByName(tipbackcolor, fTipBackColor))
fTipBackColor = fWhite;
if (!fClient->GetColorByName(tipforecolor, fTipForeColor))
fTipForeColor = fBlack;
fCheckered = gVirtualX->CreatePixmap(fClient->GetDefaultRoot()->GetId(),
(const char *)gray_bits,
gray_width, gray_height,
fBackColor, fWhite ,
gVirtualX->GetDepth());
fCheckeredBitmap = gVirtualX->CreatePixmap(fClient->GetDefaultRoot()->GetId(),
(const char *)gray_bits,
gray_width, gray_height,
1, 0, 1);
fPicturePool = new TGPicturePool(fClient, icon_path);
fDefaultBackPicture = 0;
fDefaultDocBackPicture = 0;
if (!framebgpixmap.IsNull())
fDefaultBackPicture = fPicturePool->GetPicture(framebgpixmap);
if (!docbgpixmap.IsNull())
fDefaultDocBackPicture = fPicturePool->GetPicture(docbgpixmap);
fFontPool = new TGFontPool(fClient);
fDefaultFont = fFontPool->GetFont(default_font);
fMenuFont = fFontPool->GetFont(menu_font);
fMenuHiFont = fFontPool->GetFont(menu_hi_font);
fDocFixedFont = fFontPool->GetFont(doc_fixed_font);
fDocPropFont = fFontPool->GetFont(doc_prop_font);
fIconFont = fFontPool->GetFont(icon_font);
fStatusFont = fFontPool->GetFont(status_font);
fGCPool = new TGGCPool(fClient);
GCValues_t gval;
gval.fMask = kGCForeground | kGCBackground | kGCFont |
kGCFillStyle | kGCGraphicsExposures;
gval.fGraphicsExposures = kFALSE;
gval.fFillStyle = kFillSolid;
gval.fFont = fDefaultFont->GetFontHandle();
gval.fBackground = fBackColor;
gval.fForeground = fBlack;
fBlackGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fWhite;
fWhiteGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fHilite;
fHiliteGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fShadow;
fShadowGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fBackColor;
fBckgndGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fForeColor;
fFrameGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fSelBackColor;
fSelbgndGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fSelForeColor;
gval.fBackground = fSelBackColor;
fSelGC = fGCPool->GetGC(&gval, kTRUE);
gval.fFont = fDocPropFont->GetFontHandle();
gval.fForeground = fDocForeColor;
gval.fBackground = fDocBackColor;
fDocGC = fGCPool->GetGC(&gval, kTRUE);
gval.fForeground = fDocBackColor;
fDocbgndGC = fGCPool->GetGC(&gval, kTRUE);
gval.fFont = fStatusFont->GetFontHandle();
gval.fForeground = fTipForeColor;
gval.fBackground = fTipBackColor;
fTipGC = fGCPool->GetGC(&gval, kTRUE);
gval.fMask = kGCForeground | kGCBackground | kGCFillStyle |
kGCLineWidth | kGCSubwindowMode |
kGCGraphicsExposures | kGCStipple;
gval.fForeground = fBlack;
gval.fBackground = fSelBackColor;
gval.fLineWidth = 0;
gval.fFillStyle = kFillStippled;
gval.fSubwindowMode = kIncludeInferiors;
gval.fGraphicsExposures = kFALSE;
gval.fStipple = fCheckeredBitmap;
fFocusGC = fGCPool->GetGC(&gval, kTRUE);
fDefaultCursor = kNone;
fGrabCursor = gVirtualX->CreateCursor(kArrowRight);
fTextCursor = gVirtualX->CreateCursor(kCaret);
fWaitCursor = gVirtualX->CreateCursor(kWatch);
fMimeTypeList = new TGMimeTypes(fClient, mime_file);
#ifndef R__WIN32
fClipboardAtom = gVirtualX->InternAtom("_ROOT_CLIPBOARD", kFALSE);
#else
fClipboardAtom = gVirtualX->InternAtom("CLIPBOARD", kFALSE);
#endif
}
TGResourcePool::~TGResourcePool()
{
delete fPicturePool;
delete fFontPool;
delete fGCPool;
delete fMimeTypeList;
gVirtualX->DeletePixmap(fCheckered);
gVirtualX->DeletePixmap(fCheckeredBitmap);
}