Logo ROOT  
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
18const 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
47class MyMainFrame : public TGMainFrame {
48
49public:
50 MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
51 ~MyMainFrame() override;
52
53 void DoExit();
54
55 ClassDefOverride(MyMainFrame, 0)
56};
57
58void MyMainFrame::DoExit()
59{
60 Cleanup();
62}
63
64MyMainFrame::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");
84 Resize(GetDefaultSize());
85 MapWindow();
86}
87
88MyMainFrame::~MyMainFrame()
89{
90 // Clean up all widgets, frames and layouthints.
91 Cleanup();
92}
93
94void iconAsXPMData()
95{
96 // Popup the GUI...
97 new MyMainFrame(gClient->GetRoot(), 350, 80);
98}
@ kChildFrame
Definition GuiTypes.h:379
#define h(i)
Definition RSha256.hxx:106
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned int UInt_t
Definition RtypesCore.h:46
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
R__EXTERN TApplication * gApplication
#define gClient
Definition TGClient.h:156
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
char name[80]
Definition TGX11.cxx:110
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
This class handles GUI icons.
Definition TGIcon.h:22
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:82
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Yield an action as soon as it is clicked.
Definition TGButton.h:142
ROOT GUI Window base class.
Definition TGWindow.h:23
Basic string class.
Definition TString.h:139