//*CMZ :  2.23/01 26/08/99  12.56.10  by  Rene Brun
//*CMZ :  2.00/08 25/05/98  18.32.39  by  Fons Rademakers
//*CMZ :  2.00/00 26/02/98  23.06.20  by  Fons Rademakers
//*CMZ :  1.00/07 24/03/97  15.41.07  by  Fons Rademakers
//*-- Author :    Nenad Buncic   20/02/96

//*KEEP,CopyRight,T=C.
/*************************************************************************
 * Copyright(c) 1995-1999, The ROOT System, All rights reserved.         *
 * Authors: Rene Brun and Fons Rademakers.                               *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/AA_LICENSE.                      *
 * For the list of contributors see $ROOTSYS/AA_CREDITS.                 *
 *************************************************************************/
//*KEND.

/////////////////////////////////////////////////////////////////////////
//                                                                     //
//   ControlBar is fully user configurable tool which provides fast    //
// access to frequently used operations. User can choose between       //
// buttons and drawnbuttons (let's say icons) and assign to them his   //
// own actions (let's say ROOT or C++ commands).                       //
//
// The macro belows shows an example of controlbar.
// To execute an item, click with the left mouse button.
// To see the HELP of a button, click on the right mouse button.
//
//{
//   gROOT.Reset("a");
//   TControlBar bar("vertical");
//   bar.AddButton("Help to run demos",".x demoshelp.C",
//                 "Explains how to run the demos");
//   bar.AddButton("framework",        ".x framework.C",
//                 "An Example of Object Oriented User Interface");
//   bar.AddButton("hsimple",          ".x hsimple.C",
//                 "An Example Creating Histograms/Ntuples on File");
//   bar.AddButton("hsum",             ".x hsum.C",
//                 "Filling histograms and some graphics options");
//   bar.AddButton("canvas",           ".x canvas.C",
//                 "Canvas and Pad Management");
//   bar.AddButton("formula1",         ".x formula1.C",
//                 "Simple Formula and Functions");
//   bar.AddButton("fillrandom",       ".x fillrandom.C",
//                 "Histograms with Random Numbers from a Function");
//   bar.AddButton("fit1",             ".x fit1.C",
//                 "A Simple Fitting Example");
//   bar.AddButton("h1draw",           ".x h1draw.C",
//                 "Drawing Options for 1D Histograms");
//   bar.AddButton("graph",            ".x graph.C",
//                 "Examples of a simple graph");
//   bar.AddButton("tornado",          ".x tornado.C",
//                 "Examples of 3-D PolyMarkers");
//   bar.AddButton("shapes",           ".x shapes.C",
//                 "The Geometry Shapes");
//   bar.AddButton("atlasna49",        ".x atlasna49.C",
//                 "Creating and Viewing Geometries");
//   bar.AddButton("file_layout",      ".x file.C",
//                 "The ROOT file format");
//   bar.AddButton("tree_layout",      ".x tree.C",
//                 "The Tree Data Structure");
//   bar.AddButton("ntuple1",          ".x ntuple1.C",
//                 "Ntuples and Selections");
//   bar.AddButton("run benchmarks",   ".x benchmarks.C",
//                 "Runs all the ROOT benchmarks");
//   bar.AddButton("rootmarks",        ".x rootmarks.C",
//                 "Prints an estimated ROOTMARKS for your machine");
//   bar.AddButton("edit_hsimple",     ".!ved hsimple.C &",
//                 "Invokes the text editor on file hsimple.C");
//   bar.AddButton("Close Bar",        "gROOT.Reset("a")",
//                 "Close ControlBar");
//   bar.Show();
//   gROOT.SaveContext();
//}
//
//
/*

*/
//
//
//                                                                     //
/////////////////////////////////////////////////////////////////////////

//*KEEP,TControlBar,T=C++.
#include "TControlBar.h"
//*KEEP,TGuiFactory.
#include "TGuiFactory.h"
//*KEEP,TList.
#include "TList.h"
//*KEND.


ClassImp(TControlBar)

//_______________________________________________________________________
 TControlBar::TControlBar() : TControlBarButton()
{
    fControlBarImp = 0;
    fOrientation   = 0;
    fButtons       = 0;
    fNoroc         = 1;
}


//_______________________________________________________________________
 TControlBar::TControlBar(const Text_t *orientation, const Text_t *title)
            : TControlBarButton(title, "", "", "button")

{
    Initialize(-999, -999);
    SetOrientation( orientation );
}

//_______________________________________________________________________
 TControlBar::TControlBar(const Text_t *orientation, const Text_t *title, Int_t x, Int_t y)
            : TControlBarButton(title, "", "", "button")

{
    Initialize(x, y);
    SetOrientation( orientation );
}

//_______________________________________________________________________
 TControlBar::~TControlBar()
{
    delete fControlBarImp;

    if( fButtons )
        fButtons->Delete();

    fButtons       = 0;
    fControlBarImp = 0;
}


//_______________________________________________________________________
 void TControlBar::AddButton(TControlBarButton &button)
{
    AddButton( &button );
}


//_______________________________________________________________________
 void TControlBar::AddButton(TControlBarButton *button)
{
    if( fButtons && button )
        fButtons->Add( button );
}


//_______________________________________________________________________
 void TControlBar::AddButton(const Text_t *label, const Text_t *action, const Text_t *hint, const Text_t *type)
{
    TControlBarButton *button = new TControlBarButton( label, action, hint, type );
    AddButton( button );
}


//_______________________________________________________________________
 void TControlBar::AddControlBar(TControlBar &controlBar)
{
    AddControlBar( &controlBar );
}


//_______________________________________________________________________
 void TControlBar::AddControlBar(TControlBar *controlBar)
{
    if( fButtons && controlBar )
        fButtons->Add( controlBar );
}


//_______________________________________________________________________
 void TControlBar::AddSeparator()
{

}


//_______________________________________________________________________
 void TControlBar::Create()
{
    if( fControlBarImp )
        fControlBarImp->Create();
}


//_______________________________________________________________________
 void TControlBar::Hide()
{
    if( fControlBarImp )
        fControlBarImp->Hide();
}


//_______________________________________________________________________
 void TControlBar::Initialize(Int_t x, Int_t y)
{
   if (x == -999)
      fControlBarImp = gGuiFactory->CreateControlBarImp( this, GetName() );
   else
      fControlBarImp = gGuiFactory->CreateControlBarImp( this, GetName(), x, y );

    fButtons       = new TList();
    fNoroc         = 1;
}


//_______________________________________________________________________
 void TControlBar::SetOrientation(const Text_t *o)
{
    fOrientation = kVertical;

    if( *o ) {
        if( !strcasecmp( o, "vertical" ) )
            fOrientation = kVertical;
        else if( !strcasecmp( o, "horizontal" ) )
            fOrientation = kHorizontal;
        else
            Error( "SetOrientation", "Unknown orientation: '%s' !n\tt(choice of: %s, %s)",
                    o, "vertical", "horizontal" );
    }
}


//_______________________________________________________________________
 void TControlBar::SetOrientation(Int_t o)
{
    fOrientation = kVertical;

    if( ( o == kVertical ) || ( o == kHorizontal ) )
        fOrientation = o;
    else
        Error( "SetOrientation", "Unknown orientation: %d !n\tt(choice of: %d, %d)",
                o, kVertical, kHorizontal );
}


//_______________________________________________________________________
 void TControlBar::Show()
{
    if( fControlBarImp )
        fControlBarImp->Show();
}


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.