TrackGit
CredentialsWindow.cpp
Go to the documentation of this file.
1 
7 #include "CredentialsWindow.h"
8 
9 #include <stdio.h>
10 #include <string.h>
11 
12 #include <AppKit.h>
13 #include <LayoutBuilder.h>
14 #include <SupportKit.h>
15 
16 
22 CredentialsWindow::CredentialsWindow(char* usernamePtr, char* passwordPtr)
23  :
24  BWindow(BRect(0, 0, 300, 150), "TrackGit - User Credentials",
25  B_DOCUMENT_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
26 {
27  fUsernamePtr = usernamePtr;
28  fPasswordPtr = passwordPtr;
29 
30  fUsername = new BTextControl("Username:", "", NULL);
31  fPassword = new BTextControl("Password: ", "", NULL);
32  BButton* fOK = new BButton("ok", "OK",
33  new BMessage(kCredOK));
34  BButton* fCancel = new BButton("cancel", "Cancel",
35  new BMessage(kCredCancel));
36 
37  BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
38  .SetInsets(10)
39  .Add(fUsername)
40  .Add(fPassword)
41  .AddGroup(B_HORIZONTAL, 0)
42  .AddGlue()
43  .Add(fCancel)
44  .Add(fOK)
45  .End();
46 
47  CenterOnScreen();
48  Show();
49 }
50 
51 
56 void
58 {
59  switch (msg->what) {
60  case kCredOK:
61  strcpy(fUsernamePtr, fUsername->Text());
62  strcpy(fPasswordPtr, fPassword->Text());
63  Quit();
64  break;
65  case kCredCancel:
66  Quit();
67  break;
68  default:
69  BWindow::MessageReceived(msg);
70  }
71 }
BTextControl * fPassword
The text control for password.
char * fUsernamePtr
The username pointer.
virtual void MessageReceived(BMessage *)
The handler to receive messages.
BTextControl * fUsername
The text control for username.
char * fPasswordPtr
The password pointer.
CredentialsWindow(char *, char *)
Constructor for CredentialsWindow.