Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGResourcePool.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 19/5/2003
3
4/*************************************************************************
5 * Copyright (C) 1995-2003, 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 TGResourcePool
25 \ingroup guiwidgets
26
27This class implements a pool for the default GUI resource set,
28like GC's, colors, fonts, etc.
29*/
30
31
32#include "RConfigure.h"
33
34#include "TGResourcePool.h"
35#include "TGWindow.h"
36#include "TROOT.h"
37#include "TSystem.h"
38#include "TEnv.h"
39#include "TVirtualX.h"
40#include "TGGC.h"
41#include "TGPicture.h"
42#include "TGFont.h"
43#include "TGMimeTypes.h"
44
45
46const int gray_width = 8;
47const int gray_height = 8;
48static unsigned char gray_bits[] = {
49 0x55, 0xaa, 0x55, 0xaa,
50 0x55, 0xaa, 0x55, 0xaa
51};
52
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Create the global GUI resource pool manager.
57
59{
60 fClient = client;
61 fDefaultColormap = gVirtualX->GetColormap();
62
63 // Get GUI defaults from [system].rootrc
64 TString default_font = gEnv->GetValue("Gui.DefaultFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
65 TString menu_font = gEnv->GetValue("Gui.MenuFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
66 TString menu_hi_font = gEnv->GetValue("Gui.MenuHiFont", "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
67 TString doc_fixed_font = gEnv->GetValue("Gui.DocFixedFont", "-*-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
68 TString doc_prop_font = gEnv->GetValue("Gui.DocPropFont", "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
69 TString icon_font = gEnv->GetValue("Gui.IconFont", "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1");
70 TString status_font = gEnv->GetValue("Gui.StatusFont", "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1");
71 TString backcolor = gEnv->GetValue("Gui.BackgroundColor", "#e0e0e0");
72 TString forecolor = gEnv->GetValue("Gui.ForegroundColor", "black");
73 TString highlightcolor = gEnv->GetValue("Gui.HighLightColor", "#d0d0d0");
74 TString selbackcolor = gEnv->GetValue("Gui.SelectBackgroundColor", "#86abd9");
75 TString selforecolor = gEnv->GetValue("Gui.SelectForegroundColor", "white");
76 TString docbackcolor = gEnv->GetValue("Gui.DocumentBackgroundColor", "white");
77 TString docforecolor = gEnv->GetValue("Gui.DocumentForegroundColor", "black");
78 TString tipbackcolor = gEnv->GetValue("Gui.TooltipBackgroundColor", "LightYellow");
79 TString tipforecolor = gEnv->GetValue("Gui.TooltipForegroundColor", "black");
80 TString framebgpixmap = gEnv->GetValue("Gui.FrameBackgroundPixmap", "");
81 TString docbgpixmap = gEnv->GetValue("Gui.DocumentBackgroundPixmap", "");
82
83 TString icon_path = gEnv->GetValue("Gui.IconPath", "");
84 if (icon_path.IsNull()) {
85 icon_path = "icons";
86 gSystem->PrependPathName(gSystem->HomeDirectory(), icon_path);
87#ifndef R__WIN32
88 icon_path = ".:" + icon_path + ":" + TROOT::GetIconPath() + ":" + EXTRAICONPATH;
89#else
90 icon_path = ".;" + icon_path + ";" + TROOT::GetIconPath() + ";" + EXTRAICONPATH;
91#endif
92 }
93
94 TString mime_file = ".root.mimes";
95 gSystem->PrependPathName(gSystem->HomeDirectory(), mime_file);
96 mime_file = gEnv->GetValue("Gui.MimeTypeFile", mime_file.Data());
97 gSystem->ExpandPathName(mime_file);
98
99 if (gSystem->AccessPathName(mime_file, kReadPermission)) {
100 mime_file = "root.mimes";
101 gSystem->PrependPathName(TROOT::GetEtcDir(), mime_file);
102 }
103
104 // Setup colors...
105 fClient->GetColorByName("white", fWhite); // white and black always exist
106 fClient->GetColorByName("black", fBlack);
107 if (!fClient->GetColorByName(backcolor, fBackColor))
109 if (!fClient->GetColorByName(forecolor, fForeColor))
111 if (!fClient->GetColorByName(highlightcolor, fHighLightColor))
113 fHilite = fClient->GetHilite(fBackColor);
114 fShadow = fClient->GetShadow(fBackColor);
115 if (!fClient->GetColorByName(selbackcolor, fSelBackColor))
117 if (!fClient->GetColorByName(selforecolor, fSelForeColor))
119 if (!fClient->GetColorByName(docbackcolor, fDocBackColor))
121 if (!fClient->GetColorByName(docforecolor, fDocForeColor))
123 if (!fClient->GetColorByName(tipbackcolor, fTipBackColor))
125 if (!fClient->GetColorByName(tipforecolor, fTipForeColor))
127
128 // Setup checkered pix/bit-maps...
129 fCheckered = gVirtualX->CreatePixmap(fClient->GetDefaultRoot()->GetId(),
130 (const char *)gray_bits,
132 fBackColor, fWhite /*fHilite*/,
133 gVirtualX->GetDepth());
134 fCheckeredBitmap = gVirtualX->CreatePixmap(fClient->GetDefaultRoot()->GetId(),
135 (const char *)gray_bits,
137 1, 0, 1);
138
139 // Create picture pool, GC pool, font pool, mime type list, etc.
140
141 // Create picture pool and pre-load some pictures...
142 fPicturePool = new TGPicturePool(fClient, icon_path);
143
146 if (!framebgpixmap.IsNull())
147 fDefaultBackPicture = fPicturePool->GetPicture(framebgpixmap);
148 if (!docbgpixmap.IsNull())
149 fDefaultDocBackPicture = fPicturePool->GetPicture(docbgpixmap);
150
151 // Create font pool and pre-load some fonts...
153 fDefaultFont = fFontPool->GetFont(default_font);
154 fMenuFont = fFontPool->GetFont(menu_font);
155 fMenuHiFont = fFontPool->GetFont(menu_hi_font);
156 fDocFixedFont = fFontPool->GetFont(doc_fixed_font);
157 fDocPropFont = fFontPool->GetFont(doc_prop_font);
158 fIconFont = fFontPool->GetFont(icon_font);
159 fStatusFont = fFontPool->GetFont(status_font);
160
161 // Create GC pool and pre-load some GCs...
162 fGCPool = new TGGCPool(fClient);
163
164 GCValues_t gval;
168 gval.fFillStyle = kFillSolid;
169 gval.fFont = fDefaultFont ? fDefaultFont->GetFontHandle() : FontH_t(0);
170 gval.fBackground = fBackColor;
171 gval.fForeground = fBlack;
172 fBlackGC = fGCPool->GetGC(&gval, kTRUE);
173
174 gval.fForeground = fWhite;
175 fWhiteGC = fGCPool->GetGC(&gval, kTRUE);
176
177 gval.fForeground = fHilite;
178 fHiliteGC = fGCPool->GetGC(&gval, kTRUE);
179
180 gval.fForeground = fShadow;
181 fShadowGC = fGCPool->GetGC(&gval, kTRUE);
182
183 gval.fForeground = fBackColor;
184 fBckgndGC = fGCPool->GetGC(&gval, kTRUE);
185
186 gval.fForeground = fForeColor;
187 fFrameGC = fGCPool->GetGC(&gval, kTRUE);
188
190 fSelbgndGC = fGCPool->GetGC(&gval, kTRUE);
191
194 fSelGC = fGCPool->GetGC(&gval, kTRUE);
195
196 gval.fFont = fDocPropFont ? fDocPropFont->GetFontHandle() : FontH_t(0);
199 fDocGC = fGCPool->GetGC(&gval, kTRUE);
200
202 fDocbgndGC = fGCPool->GetGC(&gval, kTRUE);
203
204 gval.fFont = fStatusFont ? fStatusFont->GetFontHandle() : FontH_t(0);
207 fTipGC = fGCPool->GetGC(&gval, kTRUE);
208
212 gval.fForeground = fBlack;
214 gval.fLineWidth = 0;
219 fFocusGC = fGCPool->GetGC(&gval, kTRUE);
220
221 // Setup cursors...
223 fGrabCursor = gVirtualX->CreateCursor(kArrowRight);
224 fTextCursor = gVirtualX->CreateCursor(kCaret);
225 fWaitCursor = gVirtualX->CreateCursor(kWatch);
226
227 // Read in mime type...
228 fMimeTypeList = new TGMimeTypes(fClient, mime_file);
229
230 // Clipboard handle...
231#ifndef R__WIN32
232 fClipboardAtom = gVirtualX->InternAtom("_ROOT_CLIPBOARD", kFALSE);
233#else
234 fClipboardAtom = gVirtualX->InternAtom("CLIPBOARD", kFALSE);
235#endif
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Cleanup the resource pool...
240
242{
243 delete fPicturePool;
244 delete fFontPool;
245 delete fGCPool;
246 delete fMimeTypeList;
247
248 gVirtualX->DeletePixmap(fCheckered);
249 gVirtualX->DeletePixmap(fCheckeredBitmap);
250}
const Mask_t kGCBackground
Definition GuiTypes.h:290
const Mask_t kGCForeground
Definition GuiTypes.h:289
const Mask_t kGCSubwindowMode
Definition GuiTypes.h:302
const Mask_t kGCLineWidth
Definition GuiTypes.h:291
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index).
Definition GuiTypes.h:36
const Mask_t kGCFillStyle
Definition GuiTypes.h:295
const Mask_t kGCFont
Definition GuiTypes.h:301
const Handle_t kNone
Definition GuiTypes.h:89
@ kIncludeInferiors
Definition GuiTypes.h:54
@ kFillStippled
Definition GuiTypes.h:52
@ kFillSolid
Definition GuiTypes.h:52
const Mask_t kGCStipple
Definition GuiTypes.h:298
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:303
@ kArrowRight
Definition GuiTypes.h:376
@ kCaret
Definition GuiTypes.h:376
@ kWatch
Definition GuiTypes.h:376
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
externTEnv * gEnv
Definition TEnv.h:170
const int gray_height
const int gray_width
static unsigned char gray_bits[]
@ kReadPermission
Definition TSystem.h:55
externTSystem * gSystem
Definition TSystem.h:582
#define gVirtualX
Definition TVirtualX.h:375
Window client.
Definition TGClient.h:37
Provides a pool of fonts.
Definition TGFont.h:217
This class handles mime types, used by browsers to map file types to applications and icons.
Definition TGMimeTypes.h:47
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
TGFont * fDocFixedFont
document fixed font
TGFont * fDefaultFont
default font
Pixel_t fDocForeColor
default document foreground color
Pixel_t fForeColor
default foreground color
TGGC * fDocGC
document gc
TGGC * fBlackGC
black gc
Pixel_t fTipBackColor
default tip background color
Pixel_t fTipForeColor
default tip foreground color
Cursor_t fWaitCursor
wait cursor
Pixel_t fWhite
white color index
TGFont * fStatusFont
status bar font
TGGC * fHiliteGC
frame hilite gc
TGGC * fShadowGC
frame shadow gc
Pixel_t fHighLightColor
highlight color
const TGPicture * fDefaultBackPicture
default background picture
TGPicturePool * fPicturePool
picture pool manager
Pixel_t fBackColor
default background color
Cursor_t fTextCursor
text cursor
TGGC * fSelbgndGC
selection background gc
TGFont * fDocPropFont
document proportional font
TGGC * fFocusGC
frame focus gc
TGFont * fIconFont
icon font
TGFontPool * fFontPool
font pool manager
TGMimeTypes * fMimeTypeList
list of mime types
Cursor_t fGrabCursor
grab cursor
TGGC * fDocbgndGC
document background gc
Pixel_t fDocBackColor
default document background color
TGFont * fMenuFont
menu font
TGGC * fFrameGC
frame gc
Pixmap_t fCheckered
checkered pixmap
TGFont * fMenuHiFont
menu highlight font
TGResourcePool(TGClient *client)
Create the global GUI resource pool manager.
~TGResourcePool() override
Cleanup the resource pool...
TGGCPool * fGCPool
graphics drawing context pool manager
Pixel_t fBlack
black color index
Atom_t fClipboardAtom
handle to clipboard
Pixel_t fSelForeColor
default selection foreground color
Pixel_t fShadow
default shadow color
Pixmap_t fCheckeredBitmap
checkered bitmap
TGGC * fTipGC
tooltip gc
Cursor_t fDefaultCursor
default cursor
Colormap_t fDefaultColormap
default colormap
const TGPicture * fDefaultDocBackPicture
default document background picture
TGGC * fSelGC
selection gc
Pixel_t fHilite
default highlight color
Pixel_t fSelBackColor
default selection background color
TGGC * fBckgndGC
frame background gc
TGGC * fWhiteGC
white gc
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3381
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
Bool_t IsNull() const
Definition TString.h:422
Graphics context structure.
Definition GuiTypes.h:225
ULong_t fBackground
background pixel
Definition GuiTypes.h:229
Int_t fLineWidth
line width
Definition GuiTypes.h:230
Pixmap_t fStipple
stipple 1 plane pixmap for stippling
Definition GuiTypes.h:240
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:252
Bool_t fGraphicsExposures
boolean, should exposures be generated
Definition GuiTypes.h:245
ULong_t fForeground
foreground pixel
Definition GuiTypes.h:228
Int_t fFillStyle
kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled
Definition GuiTypes.h:235
FontH_t fFont
default text font for text operations
Definition GuiTypes.h:243
Int_t fSubwindowMode
kClipByChildren, kIncludeInferiors
Definition GuiTypes.h:244