00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TGFrame.h"
00013 #include "TGLayout.h"
00014 #include "TString.h"
00015 #include "TGPicture.h"
00016 #include "TImage.h"
00017 #include "TGShapedFrame.h"
00018 #include "Riostream.h"
00019
00020 ClassImp(TGShapedFrame)
00021
00022
00023 TGShapedFrame::TGShapedFrame(const char *pname, const TGWindow *p, UInt_t w,
00024 UInt_t h, UInt_t options) :
00025 TGCompositeFrame(p, w, h, options), fBgnd(0), fImage(0)
00026 {
00027
00028
00029 TString picName;
00030
00031 if (options & kTempFrame) {
00032 SetWindowAttributes_t attr;
00033 attr.fMask = kWAOverrideRedirect | kWASaveUnder;
00034 attr.fOverrideRedirect = kTRUE;
00035 attr.fSaveUnder = kTRUE;
00036 gVirtualX->ChangeWindowAttributes(fId, &attr);
00037 }
00038
00039 if (pname)
00040 picName = pname;
00041 else
00042 picName = "Default.png";
00043 fImage = TImage::Open(picName.Data());
00044 if (!fImage || !fImage->IsValid())
00045 Error("TGShapedFrame", "%s not found", picName.Data());
00046 fBgnd = fClient->GetPicturePool()->GetPicture(picName.Data(),
00047 fImage->GetPixmap(), fImage->GetMask());
00048
00049 gVirtualX->ShapeCombineMask(fId, 0, 0, fBgnd->GetMask());
00050
00051 SetBackgroundPixmap(fBgnd->GetPicture());
00052
00053 MapSubwindows();
00054 Resize();
00055 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
00056 }
00057
00058
00059 TGShapedFrame::~TGShapedFrame()
00060 {
00061
00062
00063 delete fImage;
00064 fClient->FreePicture(fBgnd);
00065 }
00066
00067
00068 void TGShapedFrame::SavePrimitive(ostream &out, Option_t *option )
00069 {
00070
00071
00072 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
00073
00074 out << endl << " // shaped frame" << endl;
00075 out << " TGShapedFrame *";
00076 out << GetName() << " = new TGShapedFrame(" << fImage->GetName()
00077 << "," << fParent->GetName() << "," << GetWidth() << ","
00078 << GetHeight();
00079
00080 if (fBackground == GetDefaultFrameBackground()) {
00081 if (!GetOptions()) {
00082 out << ");" << endl;
00083 } else {
00084 out << "," << GetOptionString() <<");" << endl;
00085 }
00086 } else {
00087 out << "," << GetOptionString() << ",ucolor);" << endl;
00088 }
00089 if (option && strstr(option, "keep_names"))
00090 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00091
00092
00093 TGLayoutManager * lm = GetLayoutManager();
00094 if ((GetOptions() & kHorizontalFrame) &&
00095 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
00096 ;
00097 } else if ((GetOptions() & kVerticalFrame) &&
00098 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
00099 ;
00100 } else {
00101 out << " " << GetName() <<"->SetLayoutManager(";
00102 lm->SavePrimitive(out, option);
00103 out << ");"<< endl;
00104 }
00105
00106 SavePrimitiveSubframes(out, option);
00107 }