From 55fc8da14328ae333d03079f092948f29411e8b3 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 13 Jun 2013 20:39:06 -0400 Subject: [PATCH] Initial implementation of exception configuration window. Doesn't actually take any actions yet, just presents a UI. --- src/apps/debugger/Jamfile | 1 + src/apps/debugger/MessageCodes.h | 2 + .../gui/team_window/ExceptionConfigWindow.cpp | 112 ++++++++++++++++++ .../gui/team_window/ExceptionConfigWindow.h | 50 ++++++++ 4 files changed, 165 insertions(+) create mode 100644 src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp create mode 100644 src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 39a1c4fd6f..f6300edcc4 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -234,6 +234,7 @@ Application Debugger : # user_interface/gui/team_window BreakpointListView.cpp BreakpointsView.cpp + ExceptionConfigWindow.cpp ImageFunctionsView.cpp ImageListView.cpp RegistersView.cpp diff --git a/src/apps/debugger/MessageCodes.h b/src/apps/debugger/MessageCodes.h index ccf5e65d34..560ec53648 100644 --- a/src/apps/debugger/MessageCodes.h +++ b/src/apps/debugger/MessageCodes.h @@ -52,6 +52,8 @@ enum { MSG_TEAM_RESTART_REQUESTED = 'trrq', MSG_SHOW_TEAMS_WINDOW = 'stsw', MSG_TEAMS_WINDOW_CLOSED = 'tswc', + MSG_SHOW_EXCEPTION_CONFIG_WINDOW = 'secw', + MSG_EXCEPTION_CONFIG_WINDOW_CLOSED = 'ecwc', MSG_START_NEW_TEAM = 'sttt', MSG_DEBUG_THIS_TEAM = 'dbtt', MSG_SHOW_INSPECTOR_WINDOW = 'sirw', diff --git a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp new file mode 100644 index 0000000000..8da82d1f33 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.cpp @@ -0,0 +1,112 @@ +/* + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#include "ExceptionConfigWindow.h" + +#include +#include +#include + +#include "MessageCodes.h" +#include "UserInterface.h" +#include "Team.h" + + +enum { + MSG_STOP_ON_THROWN_EXCEPTION_CHANGED = 'stec', + MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED = 'scec' +}; + + +ExceptionConfigWindow::ExceptionConfigWindow(::Team* team, + UserInterfaceListener* listener, BHandler* target) + : + BWindow(BRect(), "Configure Exceptions", B_FLOATING_WINDOW, + B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), + fTeam(team), + fListener(listener), + fExceptionThrown(NULL), + fExceptionCaught(NULL), + fCloseButton(NULL), + fTarget(target) +{ +} + + +ExceptionConfigWindow::~ExceptionConfigWindow() +{ + BMessenger(fTarget).SendMessage(MSG_EXCEPTION_CONFIG_WINDOW_CLOSED); +} + + +ExceptionConfigWindow* +ExceptionConfigWindow::Create(::Team* team, + UserInterfaceListener* listener, BHandler* target) +{ + ExceptionConfigWindow* self = new ExceptionConfigWindow(team, listener, + target); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; + +} + +void +ExceptionConfigWindow::_Init() +{ + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) + .Add(fExceptionThrown = new BCheckBox("exceptionThrown", + "Stop when an exception is thrown", new BMessage( + MSG_STOP_ON_THROWN_EXCEPTION_CHANGED))) + .Add(fExceptionCaught = new BCheckBox("exceptionCaught", + "Stop when an exception is caught", new BMessage( + MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED))) + .AddGroup(B_HORIZONTAL, 4.0f) + .AddGlue() + .Add(fCloseButton = new BButton("Close", new BMessage( + B_QUIT_REQUESTED))) + .End(); + + fExceptionThrown->SetTarget(this); + fExceptionCaught->SetTarget(this); + + // TODO: enable once implemented + fExceptionCaught->SetEnabled(false); + + fCloseButton->SetTarget(this); +} + +void +ExceptionConfigWindow::Show() +{ + CenterOnScreen(); + BWindow::Show(); +} + +void +ExceptionConfigWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_STOP_ON_THROWN_EXCEPTION_CHANGED: + { + break; + } + + case MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED: + { + break; + } + default: + BWindow::MessageReceived(message); + break; + } + +} diff --git a/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h new file mode 100644 index 0000000000..bae865bb26 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/team_window/ExceptionConfigWindow.h @@ -0,0 +1,50 @@ +/* + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef EXCEPTION_CONFIG_WINDOW_H +#define EXCEPTION_CONFIG_WINDOW_H + + +#include + + +class BButton; +class BCheckBox; +class Team; +class UserInterfaceListener; + + +class ExceptionConfigWindow : public BWindow +{ +public: + ExceptionConfigWindow(::Team* team, + UserInterfaceListener* listener, + BHandler* target); + + ~ExceptionConfigWindow(); + + static ExceptionConfigWindow* Create(::Team* team, + UserInterfaceListener* listener, + BHandler* target); + // throws + + virtual void MessageReceived(BMessage* message); + + virtual void Show(); + +private: + void _Init(); + + +private: + ::Team* fTeam; + UserInterfaceListener* fListener; + BCheckBox* fExceptionThrown; + BCheckBox* fExceptionCaught; + BButton* fCloseButton; + BHandler* fTarget; +}; + + +#endif // EXCEPTION_CONFIG_WINDOW_H