00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "TAttFillEditor.h"
00027 #include "TGedPatternSelect.h"
00028 #include "TGColorSelect.h"
00029 #include "TColor.h"
00030
00031 ClassImp(TAttFillEditor)
00032
00033 enum EFillWid {
00034 kCOLOR,
00035 kPATTERN
00036 };
00037
00038
00039
00040 TAttFillEditor::TAttFillEditor(const TGWindow *p, Int_t width,
00041 Int_t height, UInt_t options, Pixel_t back)
00042 : TGedFrame(p, width, height, options | kVerticalFrame, back)
00043 {
00044
00045
00046 fPriority = 2;
00047
00048 fAttFill = 0;
00049
00050 MakeTitle("Fill");
00051
00052 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00053 fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
00054 f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00055 fColorSelect->Associate(this);
00056 fPatternSelect = new TGedPatternSelect(f2, 1, kPATTERN);
00057 f2->AddFrame(fPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00058 fPatternSelect->Associate(this);
00059 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00060 }
00061
00062
00063 TAttFillEditor::~TAttFillEditor()
00064 {
00065
00066 }
00067
00068
00069 void TAttFillEditor::ConnectSignals2Slots()
00070 {
00071
00072
00073 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttFillEditor", this, "DoFillColor(Pixel_t)");
00074 fPatternSelect->Connect("PatternSelected(Style_t)", "TAttFillEditor", this, "DoFillPattern(Style_t)");
00075 fInit = kFALSE;
00076 }
00077
00078
00079 void TAttFillEditor::SetModel(TObject* obj)
00080 {
00081
00082
00083 TAttFill *attfill = dynamic_cast<TAttFill *>(obj);
00084 if (!attfill) return;
00085
00086 fAttFill = attfill;
00087 fAvoidSignal = kTRUE;
00088
00089 Color_t c = fAttFill->GetFillColor();
00090 Pixel_t p = TColor::Number2Pixel(c);
00091 fColorSelect->SetColor(p, kFALSE);
00092
00093 Style_t s = fAttFill->GetFillStyle();
00094 fPatternSelect->SetPattern(s, kFALSE);
00095
00096 if (fInit) ConnectSignals2Slots();
00097 fAvoidSignal = kFALSE;
00098 }
00099
00100
00101 void TAttFillEditor::DoFillColor(Pixel_t color)
00102 {
00103
00104
00105 if (fAvoidSignal) return;
00106 fAttFill->SetFillColor(TColor::GetColor(color));
00107 Update();
00108 }
00109
00110
00111 void TAttFillEditor::DoFillPattern(Style_t pattern)
00112 {
00113
00114
00115 if (fAvoidSignal) return;
00116 fAttFill->SetFillStyle(pattern);
00117 Update();
00118 }
00119