// A simple example of creating icon image from XPM data, // included into the code. // // Author: Ilka Antcheva 27/09/2007 #include #include #include #include #include #include #include #include #include char *bicon1[] = { "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 { RQ_OBJECT("MyMainFrame") private: TGMainFrame *fMain; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void DoExit(); }; void MyMainFrame::DoExit() { fMain->Cleanup(); delete fMain; gApplication->Terminate(0); } MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) { ULong_t yellow; gClient->GetColorByName("yellow", yellow); // Create a main frame fMain = new TGMainFrame(p, w, h); fMain->ChangeBackground(yellow); TString name = "myicon"; // Create a picture from the XPM data TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool(); const TGPicture *iconpic = picpool->GetPicture(name.Data(),bicon1); TGIcon *icon = new TGIcon(fMain, iconpic, 40, 40, kChildFrame, yellow); fMain->AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1)); TGTextButton *exit = new TGTextButton(fMain, "&Exit","gApplication->Terminate(0)"); fMain->AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2)); fMain->SetWindowName("Icon test"); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); fMain->MapWindow(); } MyMainFrame::~MyMainFrame() { // Clean up all widgets, frames and layouthints. fMain->Cleanup(); delete fMain; } void icon() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 350, 80); }