ROOT
master
Reference Guide
Loading...
Searching...
No Matches
iconAsXPMData.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// A simple example of creating icon image from XPM data, included into the code.
4
///
5
/// \macro_code
6
///
7
/// \author Ilka Antcheva 27/09/2007
8
9
#include <
TGClient.h
>
10
#include <
TGButton.h
>
11
#include <
TGFrame.h
>
12
#include <
TGIcon.h
>
13
#include <
TGResourcePool.h
>
14
#include <
TGPicture.h
>
15
#include <
TString.h
>
16
#include <
TApplication.h
>
17
18
const
char
*
const
icon1
[] = {
19
"16 16 8 1"
,
" c None s None"
,
". c #808080"
,
"X c #FFFF00"
,
"o c #c0c0c0"
,
20
"O c black"
,
"+ c #00FFFF"
,
"@ c #00FF00"
,
"# c white"
,
" ..... "
,
21
" ..XXoooOO "
,
" .+XXXoooooO "
,
" .@++XXoooo#oO "
,
" .@@+XXooo#ooO "
,
".oo@@+Xoo#ooooO "
,
22
".ooo@+.O.oooooO "
,
".oooo@O#OoooooO "
,
".oooo#.O.+ooooO "
,
".ooo#oo#@X+oooO "
,
" .o#oooo@X++oO "
,
23
" .#ooooo@XX++O "
,
" .ooooo@@XXO "
,
" ..ooo@@OO "
,
" ..OOO "
,
" "
};
24
25
class
MyMainFrame
:
public
TGMainFrame
{
26
27
public
:
28
MyMainFrame
(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
);
29
~MyMainFrame
()
override
;
30
31
void
DoExit();
32
33
ClassDefOverride
(
MyMainFrame
, 0)
34
};
35
36
void
MyMainFrame::DoExit()
37
{
38
Cleanup();
39
gApplication
->
Terminate
(0);
40
}
41
42
MyMainFrame::MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
) :
TGMainFrame
(
p
,
w
,
h
)
43
{
44
// Create a main frame
45
46
TString
name
=
"myicon"
;
47
ULong_t
yellow
;
48
gClient
->GetColorByName(
"yellow"
,
yellow
);
49
50
// Create a picture from the XPM data
51
TGPicturePool
*
picpool
=
gClient
->GetResourcePool()->GetPicturePool();
52
const
TGPicture
*
iconpic
=
picpool
->GetPicture(
name
.Data(), (
char
**)
icon1
);
53
TGIcon
*icon =
new
TGIcon
(
this
,
iconpic
, 40, 40,
kChildFrame
,
yellow
);
54
AddFrame(icon,
new
TGLayoutHints
(
kLHintsLeft
, 1, 15, 1, 1));
55
56
TGTextButton
*
exit
=
new
TGTextButton
(
this
,
"&Exit"
,
"gApplication->Terminate(0)"
);
57
AddFrame(
exit
,
new
TGLayoutHints
(
kLHintsExpandX
, 2, 0, 2, 2));
58
59
SetWindowName(
"Icon test"
);
60
MapSubwindows
();
61
Resize(GetDefaultSize());
62
MapWindow();
63
}
64
65
MyMainFrame::~MyMainFrame()
66
{
67
// Clean up all widgets, frames and layouthints.
68
Cleanup();
69
}
70
71
void
iconAsXPMData
()
72
{
73
// Popup the GUI...
74
new
MyMainFrame
(
gClient
->GetRoot(), 350, 80);
75
}
kChildFrame
@ kChildFrame
Definition
GuiTypes.h:379
h
#define h(i)
Definition
RSha256.hxx:106
ULong_t
unsigned long ULong_t
Definition
RtypesCore.h:55
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
gApplication
R__EXTERN TApplication * gApplication
Definition
TApplication.h:170
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TGButton.h
TGClient.h
gClient
#define gClient
Definition
TGClient.h:157
TGFrame.h
TGIcon.h
kLHintsLeft
@ kLHintsLeft
Definition
TGLayout.h:24
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGPicture.h
TGResourcePool.h
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Definition
TGWin32VirtualXProxy.cxx:94
name
char name[80]
Definition
TGX11.cxx:110
TString.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TApplication::Terminate
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Definition
TApplication.cxx:1928
TGIcon
This class handles GUI icons.
Definition
TGIcon.h:22
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition
TGLayout.h:50
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition
TGFrame.h:397
TGPicturePool
Definition
TGPicture.h:89
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition
TGPicture.h:25
TGTextButton
Yield an action as soon as it is clicked.
Definition
TGButton.h:142
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
TString
Basic string class.
Definition
TString.h:139
tutorials
visualisation
gui
iconAsXPMData.C
ROOT master - Reference Guide Generated on Mon Mar 10 2025 15:21:32 (GVA Time) using Doxygen 1.10.0