51 ClassImp(TGPasswdDialog);
 
   56 TGPasswdDialog::TGPasswdDialog(
const char *prompt, 
char *pwdbuf, Int_t pwdlenmax,
 
   60    fPwdLenMax = pwdlenmax;
 
   62    const TGWindow *mainw = gClient->GetRoot();
 
   63    fDialog = 
new TGTransientFrame(mainw, mainw, w, h);
 
   64    fDialog->Connect(
"CloseWindow()", 
"TGPasswdDialog", 
this, 
"CloseWindow()");
 
   67    fDialog->AddFrame(
new TGLabel(fDialog, prompt),
 
   68                      new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 10, 5));
 
   71    fPasswdText = 
new TGTextBuffer(40);
 
   72    fPasswd = 
new TGTextEntry(fDialog, fPasswdText);
 
   73    fPasswd->SetCursorPosition(0);
 
   74    fPasswd->Resize(300, fPasswd->GetDefaultHeight());
 
   75    fPasswd->SetEchoMode(TGTextEntry::kPassword);
 
   76    fPasswd->Connect(
"ReturnPressed()", 
"TGPasswdDialog", 
this, 
"ReturnPressed()");
 
   78    fDialog->AddFrame(fPasswd, 
new TGLayoutHints(kLHintsCenterY |
 
   79                                                 kLHintsLeft | kLHintsExpandX,
 
   82    fOk = 
new TGTextButton(fDialog, 
"     &Ok     ");
 
   83    fOk->Connect(
"Clicked()", 
"TGPasswdDialog", 
this, 
"ReturnPressed()");
 
   84    fDialog->AddFrame(fOk, 
new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5));
 
   86    fDialog->SetWindowName(
"Password dialog");
 
   87    fDialog->SetIconName(
"Password dialog");
 
   89    fDialog->MapSubwindows();
 
   91    Int_t width  = fDialog->GetDefaultWidth();
 
   92    Int_t height = fDialog->GetDefaultHeight();
 
   94    fDialog->Resize(width, height);
 
  100    Int_t    mw = ((TGFrame *) mainw)->GetWidth();
 
  101    Int_t    mh = ((TGFrame *) mainw)->GetHeight();
 
  103    gVirtualX->TranslateCoordinates(mainw->GetId(), mainw->GetId(),
 
  104                           (mw - width) >> 1, (mh - height) >> 1, ax, ay, wdum);
 
  105    fDialog->Move(ax, ay);
 
  106    fDialog->SetWMPosition(ax, ay);
 
  109    fDialog->SetWMSize(width, height);
 
  110    fDialog->SetWMSizeHints(width, height, width, height, 0, 0);
 
  113    gROOT->SetInterrupt(kTRUE);
 
  115    fDialog->MapWindow();
 
  121 TGPasswdDialog::~TGPasswdDialog()
 
  130 void TGPasswdDialog::DoClose()
 
  132    fDialog->SendCloseMessage();
 
  138 void TGPasswdDialog::CloseWindow()
 
  146 void TGPasswdDialog::ReturnPressed()
 
  149       Int_t len = strlen(fPasswdText->GetString());
 
  150       len = (len < (fPwdLenMax - 1)) ? len : fPwdLenMax - 1;
 
  151       memcpy(fPwdBuf, fPasswdText->GetString(), len);
 
  153       fPasswdText->Clear();
 
  155       Error(
"ReturnPressed", 
"passwd buffer undefined");
 
  158    gROOT->SetInterrupt(kFALSE);
 
  161    fDialog->UnmapWindow();