// @(#)root/gui:$Id$
// Author: Fons Rademakers   24/02/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TRootHelpDialog                                                      //
//                                                                      //
// A TRootHelpDialog is used to display help text (or any text in a     //
// dialog window). There is on OK button to popdown the dialog.         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TRootHelpDialog.h"
#include "TGButton.h"
#include "TGTextView.h"


ClassImp(TRootHelpDialog)

//______________________________________________________________________________
TRootHelpDialog::TRootHelpDialog(const TGWindow *main,
    const char *title, UInt_t w, UInt_t h) :
    TGTransientFrame(gClient->GetRoot(), main, w, h)
{
   // Create a help text dialog.

   fView = new TGTextView(this, w, h, kSunkenFrame | kDoubleBorder);
   fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
   AddFrame(fView, fL1);

   fOK = new TGTextButton(this, "  &OK  ");
   fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
   AddFrame(fOK, fL2);

   SetWindowName(title);
   SetIconName(title);

   MapSubwindows();

   Resize(GetDefaultSize());

   // position relative to the parent's window
   CenterOnParent();
}

//______________________________________________________________________________
TRootHelpDialog::~TRootHelpDialog()
{
   // Delete help text dialog.

   delete fView;
   delete fOK;
   delete fL1;
   delete fL2;
}

//______________________________________________________________________________
void TRootHelpDialog::Popup()
{
   // Show help dialog.

   MapWindow();
}

//______________________________________________________________________________
void TRootHelpDialog::SetText(const char *helpText)
{
   // Set help text from helpText buffer in TGTextView.

   fView->LoadBuffer(helpText);
}

//______________________________________________________________________________
void TRootHelpDialog::AddText(const char *helpText)
{
   // Add help text from helpText buffer to already existing text in TGTextView.

   TGText tt;
   tt.LoadBuffer(helpText);
   fView->AddText(&tt);
}

//______________________________________________________________________________
void TRootHelpDialog::CloseWindow()
{
   // Called when closed via window manager action.

   DeleteWindow();
}

//______________________________________________________________________________
Bool_t TRootHelpDialog::ProcessMessage(Long_t msg, Long_t, Long_t)
{
   // Process OK button.

   switch (GET_MSG(msg)) {
      case kC_COMMAND:
         switch (GET_SUBMSG(msg)) {
            case kCM_BUTTON:
               // Only one button and one action...
               DeleteWindow();
               break;
            default:
               break;
         }
      default:
         break;
   }

   return kTRUE;
}

 TRootHelpDialog.cxx:1
 TRootHelpDialog.cxx:2
 TRootHelpDialog.cxx:3
 TRootHelpDialog.cxx:4
 TRootHelpDialog.cxx:5
 TRootHelpDialog.cxx:6
 TRootHelpDialog.cxx:7
 TRootHelpDialog.cxx:8
 TRootHelpDialog.cxx:9
 TRootHelpDialog.cxx:10
 TRootHelpDialog.cxx:11
 TRootHelpDialog.cxx:12
 TRootHelpDialog.cxx:13
 TRootHelpDialog.cxx:14
 TRootHelpDialog.cxx:15
 TRootHelpDialog.cxx:16
 TRootHelpDialog.cxx:17
 TRootHelpDialog.cxx:18
 TRootHelpDialog.cxx:19
 TRootHelpDialog.cxx:20
 TRootHelpDialog.cxx:21
 TRootHelpDialog.cxx:22
 TRootHelpDialog.cxx:23
 TRootHelpDialog.cxx:24
 TRootHelpDialog.cxx:25
 TRootHelpDialog.cxx:26
 TRootHelpDialog.cxx:27
 TRootHelpDialog.cxx:28
 TRootHelpDialog.cxx:29
 TRootHelpDialog.cxx:30
 TRootHelpDialog.cxx:31
 TRootHelpDialog.cxx:32
 TRootHelpDialog.cxx:33
 TRootHelpDialog.cxx:34
 TRootHelpDialog.cxx:35
 TRootHelpDialog.cxx:36
 TRootHelpDialog.cxx:37
 TRootHelpDialog.cxx:38
 TRootHelpDialog.cxx:39
 TRootHelpDialog.cxx:40
 TRootHelpDialog.cxx:41
 TRootHelpDialog.cxx:42
 TRootHelpDialog.cxx:43
 TRootHelpDialog.cxx:44
 TRootHelpDialog.cxx:45
 TRootHelpDialog.cxx:46
 TRootHelpDialog.cxx:47
 TRootHelpDialog.cxx:48
 TRootHelpDialog.cxx:49
 TRootHelpDialog.cxx:50
 TRootHelpDialog.cxx:51
 TRootHelpDialog.cxx:52
 TRootHelpDialog.cxx:53
 TRootHelpDialog.cxx:54
 TRootHelpDialog.cxx:55
 TRootHelpDialog.cxx:56
 TRootHelpDialog.cxx:57
 TRootHelpDialog.cxx:58
 TRootHelpDialog.cxx:59
 TRootHelpDialog.cxx:60
 TRootHelpDialog.cxx:61
 TRootHelpDialog.cxx:62
 TRootHelpDialog.cxx:63
 TRootHelpDialog.cxx:64
 TRootHelpDialog.cxx:65
 TRootHelpDialog.cxx:66
 TRootHelpDialog.cxx:67
 TRootHelpDialog.cxx:68
 TRootHelpDialog.cxx:69
 TRootHelpDialog.cxx:70
 TRootHelpDialog.cxx:71
 TRootHelpDialog.cxx:72
 TRootHelpDialog.cxx:73
 TRootHelpDialog.cxx:74
 TRootHelpDialog.cxx:75
 TRootHelpDialog.cxx:76
 TRootHelpDialog.cxx:77
 TRootHelpDialog.cxx:78
 TRootHelpDialog.cxx:79
 TRootHelpDialog.cxx:80
 TRootHelpDialog.cxx:81
 TRootHelpDialog.cxx:82
 TRootHelpDialog.cxx:83
 TRootHelpDialog.cxx:84
 TRootHelpDialog.cxx:85
 TRootHelpDialog.cxx:86
 TRootHelpDialog.cxx:87
 TRootHelpDialog.cxx:88
 TRootHelpDialog.cxx:89
 TRootHelpDialog.cxx:90
 TRootHelpDialog.cxx:91
 TRootHelpDialog.cxx:92
 TRootHelpDialog.cxx:93
 TRootHelpDialog.cxx:94
 TRootHelpDialog.cxx:95
 TRootHelpDialog.cxx:96
 TRootHelpDialog.cxx:97
 TRootHelpDialog.cxx:98
 TRootHelpDialog.cxx:99
 TRootHelpDialog.cxx:100
 TRootHelpDialog.cxx:101
 TRootHelpDialog.cxx:102
 TRootHelpDialog.cxx:103
 TRootHelpDialog.cxx:104
 TRootHelpDialog.cxx:105
 TRootHelpDialog.cxx:106
 TRootHelpDialog.cxx:107
 TRootHelpDialog.cxx:108
 TRootHelpDialog.cxx:109
 TRootHelpDialog.cxx:110
 TRootHelpDialog.cxx:111
 TRootHelpDialog.cxx:112
 TRootHelpDialog.cxx:113
 TRootHelpDialog.cxx:114
 TRootHelpDialog.cxx:115
 TRootHelpDialog.cxx:116
 TRootHelpDialog.cxx:117
 TRootHelpDialog.cxx:118
 TRootHelpDialog.cxx:119
 TRootHelpDialog.cxx:120