iconAsXPMData.C

Go to the documentation of this file.
00001 // A simple example of creating icon image from XPM data, 
00002 // included into the code. 
00003 //
00004 // Author: Ilka Antcheva   27/09/2007
00005 
00006 #include <TGClient.h>
00007 #include <TGButton.h>
00008 #include <TGFrame.h>
00009 #include <TGIcon.h>
00010 #include <TGResourcePool.h>
00011 #include <TGPicture.h>
00012 #include <TString.h>
00013 #include <TApplication.h>
00014 
00015 char *icon1[] =
00016 {
00017 "16 16 8 1",
00018 "    c None s None",
00019 ".   c #808080",
00020 "X   c #FFFF00",
00021 "o   c #c0c0c0",
00022 "O   c black",
00023 "+   c #00FFFF",
00024 "@   c #00FF00",
00025 "#   c white",
00026 "     .....      ",
00027 "   ..XXoooOO    ",
00028 "  .+XXXoooooO   ",
00029 " .@++XXoooo#oO  ",
00030 " .@@+XXooo#ooO  ",
00031 ".oo@@+Xoo#ooooO ",
00032 ".ooo@+.O.oooooO ",
00033 ".oooo@O#OoooooO ",
00034 ".oooo#.O.+ooooO ",
00035 ".ooo#oo#@X+oooO ",
00036 " .o#oooo@X++oO  ",
00037 " .#ooooo@XX++O  ",
00038 "  .ooooo@@XXO   ",
00039 "   ..ooo@@OO    ",
00040 "     ..OOO      ",
00041 "                "
00042 }; 
00043 
00044 class MyMainFrame : public TGMainFrame {
00045 
00046 public:
00047    MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
00048    virtual ~MyMainFrame();
00049    
00050    void DoExit();
00051 
00052    ClassDef(MyMainFrame, 0)
00053 };
00054 
00055 void MyMainFrame::DoExit()
00056 {
00057    Cleanup();
00058    gApplication->Terminate(0);
00059 }
00060 
00061 MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
00062    TGMainFrame(p, w, h)
00063 {
00064    // Create a main frame
00065 
00066    TString name = "myicon";
00067    ULong_t yellow;
00068    gClient->GetColorByName("yellow", yellow);
00069 
00070    // Create a picture from the XPM data 
00071    TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool();
00072    const TGPicture *iconpic = picpool->GetPicture(name.Data(),icon1);
00073    TGIcon *icon = new TGIcon(this, iconpic, 40, 40, kChildFrame, yellow);
00074    AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1));
00075    
00076    TGTextButton *exit = new TGTextButton(this, "&Exit","gApplication->Terminate(0)");
00077    AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2));
00078    
00079    SetWindowName("Icon test");
00080    MapSubwindows();
00081    Resize(GetDefaultSize());
00082    MapWindow();
00083 }
00084 
00085 MyMainFrame::~MyMainFrame()
00086 {
00087    // Clean up all widgets, frames and layouthints.
00088    Cleanup();
00089 }
00090 
00091 void iconAsXPMData()
00092 {
00093    // Popup the GUI...
00094    new MyMainFrame(gClient->GetRoot(), 350, 80);
00095 }

Generated on Tue Jul 5 15:44:25 2011 for ROOT_528-00b_version by  doxygen 1.5.1