ROOT
v6-26
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
{
20
"16 16 8 1"
,
21
" c None s None"
,
22
". c #808080"
,
23
"X c #FFFF00"
,
24
"o c #c0c0c0"
,
25
"O c black"
,
26
"+ c #00FFFF"
,
27
"@ c #00FF00"
,
28
"# c white"
,
29
" ..... "
,
30
" ..XXoooOO "
,
31
" .+XXXoooooO "
,
32
" .@++XXoooo#oO "
,
33
" .@@+XXooo#ooO "
,
34
".oo@@+Xoo#ooooO "
,
35
".ooo@+.O.oooooO "
,
36
".oooo@O#OoooooO "
,
37
".oooo#.O.+ooooO "
,
38
".ooo#oo#@X+oooO "
,
39
" .o#oooo@X++oO "
,
40
" .#ooooo@XX++O "
,
41
" .ooooo@@XXO "
,
42
" ..ooo@@OO "
,
43
" ..OOO "
,
44
" "
45
};
46
47
class
MyMainFrame :
public
TGMainFrame
{
48
49
public
:
50
MyMainFrame(
const
TGWindow
*p,
UInt_t
w,
UInt_t
h
);
51
virtual
~MyMainFrame();
52
53
void
DoExit();
54
55
ClassDef
(MyMainFrame, 0)
56
};
57
58
void
MyMainFrame::DoExit()
59
{
60
Cleanup();
61
gApplication
->
Terminate
(0);
62
}
63
64
MyMainFrame::MyMainFrame(
const
TGWindow
*p,
UInt_t
w,
UInt_t
h
) :
65
TGMainFrame
(p, w,
h
)
66
{
67
// Create a main frame
68
69
TString
name
=
"myicon"
;
70
ULong_t
yellow;
71
gClient
->GetColorByName(
"yellow"
, yellow);
72
73
// Create a picture from the XPM data
74
TGPicturePool
*picpool =
gClient
->GetResourcePool()->GetPicturePool();
75
const
TGPicture
*iconpic = picpool->
GetPicture
(
name
.Data(),(
char
**)icon1);
76
TGIcon
*icon =
new
TGIcon
(
this
, iconpic, 40, 40,
kChildFrame
, yellow);
77
AddFrame(icon,
new
TGLayoutHints
(
kLHintsLeft
, 1,15,1,1));
78
79
TGTextButton
*exit =
new
TGTextButton
(
this
,
"&Exit"
,
"gApplication->Terminate(0)"
);
80
AddFrame(exit,
new
TGLayoutHints
(
kLHintsExpandX
,2,0,2,2));
81
82
SetWindowName(
"Icon test"
);
83
MapSubwindows();
84
Resize(GetDefaultSize());
85
MapWindow();
86
}
87
88
MyMainFrame::~MyMainFrame()
89
{
90
// Clean up all widgets, frames and layouthints.
91
Cleanup();
92
}
93
94
void
iconAsXPMData()
95
{
96
// Popup the GUI...
97
new
MyMainFrame(
gClient
->GetRoot(), 350, 80);
98
}
kChildFrame
@ kChildFrame
Definition
GuiTypes.h:379
h
#define h(i)
Definition
RSha256.hxx:106
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
ULong_t
unsigned long ULong_t
Definition
RtypesCore.h:55
ClassDef
#define ClassDef(name, id)
Definition
Rtypes.h:325
TApplication.h
gApplication
R__EXTERN TApplication * gApplication
Definition
TApplication.h:165
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
name
char name[80]
Definition
TGX11.cxx:110
TString.h
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:1670
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:398
TGPicturePool
Definition
TGPicture.h:89
TGPicturePool::GetPicture
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition
TGPicture.cxx:82
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:136
tutorials
gui
iconAsXPMData.C
ROOT v6-26 - Reference Guide Generated on Mon Sep 11 2023 21:03:03 (GVA Time) using Doxygen 1.9.8