xref: /haiku/src/apps/debugger/user_interface/gui/team_settings_window/TeamSettingsWindow.cpp (revision 4e3137c085bae361922078f123dceb92da700640)
1 /*
2  * Copyright 2013-2015, Rene Gollent, rene@gollent.com.
3  * Distributed under the terms of the MIT License.
4  */
5 #include "TeamSettingsWindow.h"
6 
7 #include <Button.h>
8 #include <LayoutBuilder.h>
9 #include <TabView.h>
10 
11 #include "ExceptionStopConfigView.h"
12 #include "ImageStopConfigView.h"
13 #include "MessageCodes.h"
14 #include "SignalsConfigView.h"
15 
16 
17 TeamSettingsWindow::TeamSettingsWindow(::Team* team,
18 	UserInterfaceListener* listener, BHandler* target)
19 	:
20 	BWindow(BRect(), "Team settings", B_TITLED_WINDOW,
21 		B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
22 	fTeam(team),
23 	fListener(listener),
24 	fCloseButton(NULL),
25 	fTarget(target)
26 {
27 }
28 
29 
30 TeamSettingsWindow::~TeamSettingsWindow()
31 {
32 	BMessenger(fTarget).SendMessage(MSG_TEAM_SETTINGS_WINDOW_CLOSED);
33 }
34 
35 
36 TeamSettingsWindow*
37 TeamSettingsWindow::Create(::Team* team,
38 	UserInterfaceListener* listener, BHandler* target)
39 {
40 	TeamSettingsWindow* self = new TeamSettingsWindow(
41 		team, listener, target);
42 
43 	try {
44 		self->_Init();
45 	} catch (...) {
46 		delete self;
47 		throw;
48 	}
49 
50 	return self;
51 }
52 
53 
54 void
55 TeamSettingsWindow::Show()
56 {
57 	CenterOnScreen();
58 	BWindow::Show();
59 }
60 
61 
62 void
63 TeamSettingsWindow::_Init()
64 {
65 	BTabView* tabView = new BTabView("config tab view");
66 	BLayoutBuilder::Group<>(this, B_VERTICAL)
67 		.SetInsets(B_USE_DEFAULT_SPACING)
68 		.Add(tabView)
69 		.AddGroup(B_HORIZONTAL)
70 			.AddGlue()
71 			.Add(fCloseButton = new BButton("Close", new BMessage(
72 					B_QUIT_REQUESTED)))
73 		.End();
74 
75 	SignalsConfigView* signalsView = SignalsConfigView::Create(fTeam,
76 		fListener);
77 	tabView->AddTab(signalsView);
78 	ImageStopConfigView* imageView = ImageStopConfigView::Create(fTeam,
79 		fListener);
80 	tabView->AddTab(imageView);
81 	ExceptionStopConfigView* exceptionView = ExceptionStopConfigView::Create(
82 		fTeam, fListener);
83 	tabView->AddTab(exceptionView);
84 
85 	fCloseButton->SetTarget(this);
86 }
87