Ticket #2389: SetTitleDlg.2.cpp

File SetTitleDlg.2.cpp, 1.8 KB (added by hey68you, 15 years ago)
Line 
1/*
2 * Copyright 2001-2007, Haiku, Inc.
3 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
4 * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
5 * Distributed under the terms of the MIT license.
6 */
7#include <Rect.h>
8#include <View.h>
9#include <Message.h>
10#include <TextControl.h>
11#include <Button.h>
12
13#include "SetTitleDlg.h"
14#include "TermConst.h"
15#include "TermWindow.h"
16
17
18SetTitleDlg::SetTitleDlg (BRect frame, TermWindow *termWin)
19 : BWindow(frame, "Change Terminal Title",
20 B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL,
21 B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
22{
23
24 fParentWin = termWin;
25 fParentView = fParentWin->_ActiveTermView();
26
27 // Add a view to this dialog window
28 BView *top = new BView(Bounds(), "topview", B_FOLLOW_NONE, B_WILL_DRAW);
29 top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
30 AddChild (top);
31
32 // Add a text control to the view for entering the new title
33 BRect r(-50,10,230,50);
34 textCtl = new BTextControl(r, "", "Title:", "", NULL);
35 textCtl->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
36 top->AddChild (textCtl);
37 textCtl->MakeFocus(true);
38
39 // Add an Ok button to the view for confirming the new title
40 BButton *bOK_CHANGE_WIN_TITLE;
41 BRect rBTN(150,60,240,90);
42 bOK_CHANGE_WIN_TITLE = new BButton(rBTN, "", "Ok", new BMessage(MSG_OK_CHANGE_TITLE));
43 top->AddChild(bOK_CHANGE_WIN_TITLE);
44 bOK_CHANGE_WIN_TITLE->ResizeToPreferred();
45
46 this->SetDefaultButton(bOK_CHANGE_WIN_TITLE);
47 this->SetTitle ("Change Terminal Title");
48 this->Show();
49
50}
51
52void
53SetTitleDlg::MessageReceived(BMessage *msg)
54{
55switch (msg->what) {
56 case MSG_OK_CHANGE_TITLE:
57 fParentView->SetTitle(textCtl->Text());
58 Quit();
59 break;
60
61 default:
62 BWindow::MessageReceived(msg);
63 break;
64 }
65}
66
67
68SetTitleDlg::~SetTitleDlg (void)
69{
70
71}
72
73void
74SetTitleDlg::Quit (void)
75{
76 fParentWin->PostMessage (MSG_SET_TITLE_CLOSED);
77 BWindow::Quit ();
78}
79