3 NewConnectionWindow - DialUp Networking
5 Author: Sikosis (phil@sikosis.com)
7 (C)2002-2004 OpenBeOS under MIT license
11 // Includes -------------------------------------------------------------------------------------------------- //
13 #include <Application.h>
15 #include <Directory.h>
21 #include <TextControl.h>
25 #include "DUNWindow.h"
26 #include "NewConnectionWindow.h"
29 // Constants ------------------------------------------------------------------------------------------------- //
30 const uint32 BTN_ADD
= 'BAdd';
31 const uint32 BTN_CANCEL
= 'BCnl';
32 const uint32 TXT_NEW_CONNECTION
= 'TxCx';
33 // ---------------------------------------------------------------------------------------------------------- //
36 // NewConnectionWindow - Constructor
37 NewConnectionWindow::NewConnectionWindow(BRect frame
) : BWindow (frame
, "NewConnectionWindow", B_MODAL_WINDOW
, B_NOT_RESIZABLE
, 0)
45 // NewConnectionWindow - Destructor
46 NewConnectionWindow::~NewConnectionWindow()
52 // NewConnectionWindow::InitWindow
53 void NewConnectionWindow::InitWindow(void)
56 r
= Bounds(); // the whole view
59 int AddButtonSize
= 75;
60 int CancelButtonSize
= 75;
62 //float CancelLeftMargin = (r.right / 2) - ((AddButtonSize + 20 + CancelButtonSize) / 2);
63 //float AddLeftMargin = CancelLeftMargin + CancelButtonSize + 20;;
65 float AddLeftMargin
= r
.right
- (AddButtonSize
+ 10);
66 float CancelLeftMargin
= AddLeftMargin
- (CancelButtonSize
+ 11);
68 int NewConnectionTop
= 10;
70 txtNewConnection
= new BTextControl(BRect(LeftMargin
,NewConnectionTop
,r
.right
-10,NewConnectionTop
+10), "txtNewConnection","Connection name:","New Connection",new BMessage(TXT_NEW_CONNECTION
), B_FOLLOW_LEFT
| B_FOLLOW_TOP
, B_WILL_DRAW
| B_NAVIGABLE
);
71 txtNewConnection
->SetDivider(88);
73 btnCancel
= new BButton(BRect (CancelLeftMargin
,r
.bottom
-34,CancelLeftMargin
+CancelButtonSize
,r
.bottom
-14),"Cancel","Cancel", new BMessage(BTN_CANCEL
), B_FOLLOW_LEFT
| B_FOLLOW_TOP
, B_WILL_DRAW
| B_NAVIGABLE
);
74 btnAdd
= new BButton(BRect (AddLeftMargin
,r
.bottom
-34,AddLeftMargin
+AddButtonSize
,r
.bottom
-14),"Add","Add", new BMessage(BTN_ADD
), B_FOLLOW_LEFT
| B_FOLLOW_TOP
, B_WILL_DRAW
| B_NAVIGABLE
);
75 btnAdd
->MakeDefault(true);
77 AddChild(ptrNewConnectionWindowView
= new NewConnectionWindowView(r
));
78 ptrNewConnectionWindowView
->AddChild(txtNewConnection
);
79 ptrNewConnectionWindowView
->AddChild(btnCancel
);
80 ptrNewConnectionWindowView
->AddChild(btnAdd
);
81 txtNewConnection
->MakeFocus(true);
83 // ---------------------------------------------------------------------------------------------------------- //
85 // NewConnectionWindow::MessageReceived -- receives messages
86 void NewConnectionWindow::MessageReceived (BMessage
*message
)
92 // Send Messages to DUNWindow to Add New Connectionupdate
93 BWindow
*ptrDUNWindow
;
94 ptrDUNWindow
= be_app
->WindowAt(0); // its the first window
95 BMessage
msg(ADD_NEW_CONNECTION
);
96 msg
.AddString("ConnectionName", txtNewConnection
->Text());
97 BMessenger(ptrDUNWindow
).SendMessage(&msg
);
99 // before closing we need to change the main window to state 1
108 BWindow::MessageReceived(message
);
112 // ---------------------------------------------------------------------------------------------------------- //