TAttFillEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/ged:$Id: TAttFillEditor.cxx 31790 2009-12-10 14:14:17Z bellenot $
00002 // Author: Ilka Antcheva   10/05/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 //  TAttFillEditor                                                      //
00015 //                                                                      //
00016 //  Implements GUI for editing fill attributes.                         //                                             //
00017 //             color and fill style                                     //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 //Begin_Html
00021 /*
00022 <img src="gif/TAttFillEditor.gif">
00023 */
00024 //End_Html
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    // Constructor of fill attributes GUI.
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   // Destructor of fill editor.
00066 }
00067 
00068 //______________________________________________________________________________
00069 void TAttFillEditor::ConnectSignals2Slots()
00070 {
00071    // Connect signals to slots.
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    // Pick up the used fill attributes.
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    // Slot connected to the fill area color.
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    // Slot connected to the fill area pattern.
00114 
00115    if (fAvoidSignal) return;
00116    fAttFill->SetFillStyle(pattern);
00117    Update();
00118 }
00119 

Generated on Tue Jul 5 14:19:45 2011 for ROOT_528-00b_version by  doxygen 1.5.1