From $ROOTSYS/tutorials/gui/iconAsXPMData.C

// A simple example of creating icon image from XPM data, 
// included into the code. 
//
// Author: Ilka Antcheva   27/09/2007

#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);
   virtual ~MyMainFrame();
   
   void DoExit();

   ClassDef(MyMainFrame, 0)
};

void MyMainFrame::DoExit()
{
   Cleanup();
   gApplication->Terminate(0);
}

MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
   TGMainFrame(p, w, 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");
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}

MyMainFrame::~MyMainFrame()
{
   // Clean up all widgets, frames and layouthints.
   Cleanup();
}

void iconAsXPMData()
{
   // Popup the GUI...
   new MyMainFrame(gClient->GetRoot(), 350, 80);
}
 iconAsXPMData.C:1
 iconAsXPMData.C:2
 iconAsXPMData.C:3
 iconAsXPMData.C:4
 iconAsXPMData.C:5
 iconAsXPMData.C:6
 iconAsXPMData.C:7
 iconAsXPMData.C:8
 iconAsXPMData.C:9
 iconAsXPMData.C:10
 iconAsXPMData.C:11
 iconAsXPMData.C:12
 iconAsXPMData.C:13
 iconAsXPMData.C:14
 iconAsXPMData.C:15
 iconAsXPMData.C:16
 iconAsXPMData.C:17
 iconAsXPMData.C:18
 iconAsXPMData.C:19
 iconAsXPMData.C:20
 iconAsXPMData.C:21
 iconAsXPMData.C:22
 iconAsXPMData.C:23
 iconAsXPMData.C:24
 iconAsXPMData.C:25
 iconAsXPMData.C:26
 iconAsXPMData.C:27
 iconAsXPMData.C:28
 iconAsXPMData.C:29
 iconAsXPMData.C:30
 iconAsXPMData.C:31
 iconAsXPMData.C:32
 iconAsXPMData.C:33
 iconAsXPMData.C:34
 iconAsXPMData.C:35
 iconAsXPMData.C:36
 iconAsXPMData.C:37
 iconAsXPMData.C:38
 iconAsXPMData.C:39
 iconAsXPMData.C:40
 iconAsXPMData.C:41
 iconAsXPMData.C:42
 iconAsXPMData.C:43
 iconAsXPMData.C:44
 iconAsXPMData.C:45
 iconAsXPMData.C:46
 iconAsXPMData.C:47
 iconAsXPMData.C:48
 iconAsXPMData.C:49
 iconAsXPMData.C:50
 iconAsXPMData.C:51
 iconAsXPMData.C:52
 iconAsXPMData.C:53
 iconAsXPMData.C:54
 iconAsXPMData.C:55
 iconAsXPMData.C:56
 iconAsXPMData.C:57
 iconAsXPMData.C:58
 iconAsXPMData.C:59
 iconAsXPMData.C:60
 iconAsXPMData.C:61
 iconAsXPMData.C:62
 iconAsXPMData.C:63
 iconAsXPMData.C:64
 iconAsXPMData.C:65
 iconAsXPMData.C:66
 iconAsXPMData.C:67
 iconAsXPMData.C:68
 iconAsXPMData.C:69
 iconAsXPMData.C:70
 iconAsXPMData.C:71
 iconAsXPMData.C:72
 iconAsXPMData.C:73
 iconAsXPMData.C:74
 iconAsXPMData.C:75
 iconAsXPMData.C:76
 iconAsXPMData.C:77
 iconAsXPMData.C:78
 iconAsXPMData.C:79
 iconAsXPMData.C:80
 iconAsXPMData.C:81
 iconAsXPMData.C:82
 iconAsXPMData.C:83
 iconAsXPMData.C:84
 iconAsXPMData.C:85
 iconAsXPMData.C:86
 iconAsXPMData.C:87
 iconAsXPMData.C:88
 iconAsXPMData.C:89
 iconAsXPMData.C:90
 iconAsXPMData.C:91
 iconAsXPMData.C:92
 iconAsXPMData.C:93
 iconAsXPMData.C:94
 iconAsXPMData.C:95
 iconAsXPMData.C:96