Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
iconAsXPMData.C File Reference

Detailed Description

A simple example of creating icon image from XPM data, included into the code.

#include <TGClient.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TGIcon.h>
#include <TGResourcePool.h>
#include <TGPicture.h>
#include <TString.h>
#include <TApplication.h>
const char * const icon1[] =
{
"16 16 8 1",
" c None s None",
". c #808080",
"X c #FFFF00",
"o c #c0c0c0",
"O c black",
"+ c #00FFFF",
"@ c #00FF00",
"# c white",
" ..... ",
" ..XXoooOO ",
" .+XXXoooooO ",
" .@++XXoooo#oO ",
" .@@+XXooo#ooO ",
".oo@@+Xoo#ooooO ",
".ooo@+.O.oooooO ",
".oooo@O#OoooooO ",
".oooo#.O.+ooooO ",
".ooo#oo#@X+oooO ",
" .o#oooo@X++oO ",
" .#ooooo@XX++O ",
" .ooooo@@XXO ",
" ..ooo@@OO ",
" ..OOO ",
" "
};
class MyMainFrame : public TGMainFrame {
public:
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
~MyMainFrame() override;
void DoExit();
ClassDefOverride(MyMainFrame, 0)
};
void MyMainFrame::DoExit()
{
Cleanup();
}
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
{
// Create a main frame
TString name = "myicon";
ULong_t yellow;
gClient->GetColorByName("yellow", yellow);
// Create a picture from the XPM data
TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool();
const TGPicture *iconpic = picpool->GetPicture(name.Data(),(char **)icon1);
TGIcon *icon = new TGIcon(this, iconpic, 40, 40, kChildFrame, yellow);
AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1));
TGTextButton *exit = new TGTextButton(this, "&Exit","gApplication->Terminate(0)");
AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2));
SetWindowName("Icon test");
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
// Clean up all widgets, frames and layouthints.
Cleanup();
}
void iconAsXPMData()
{
// Popup the GUI...
new MyMainFrame(gClient->GetRoot(), 350, 80);
}
@ 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
Author
Ilka Antcheva 27/09/2007

Definition in file iconAsXPMData.C.