2 * Copyright 2014-2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #include "BreakpointEditWindow.h"
8 #include <LayoutBuilder.h>
9 #include <RadioButton.h>
10 #include <StringView.h>
11 #include <TextControl.h>
13 #include <AutoDeleter.h>
14 #include <AutoLocker.h>
16 #include "AppMessageCodes.h"
18 #include "UserBreakpoint.h"
19 #include "UserInterface.h"
23 MSG_SET_BREAK_ALWAYS
= 'sbal',
24 MSG_SET_BREAK_ON_CONDITION
= 'sboc',
25 MSG_SAVE_BREAKPOINT_SETTINGS
= 'sbps'
29 BreakpointEditWindow::BreakpointEditWindow(::Team
* team
,
30 UserBreakpoint
* breakpoint
, UserInterfaceListener
* listener
,
33 BWindow(BRect(), "Edit breakpoint", B_FLOATING_WINDOW
,
34 B_AUTO_UPDATE_SIZE_LIMITS
| B_CLOSE_ON_ESCAPE
),
37 fTargetBreakpoint(breakpoint
),
42 fTargetBreakpoint
->AcquireReference();
46 BreakpointEditWindow::~BreakpointEditWindow()
48 fTargetBreakpoint
->ReleaseReference();
49 BMessenger(fTarget
).SendMessage(MSG_BREAKPOINT_EDIT_WINDOW_CLOSED
);
54 BreakpointEditWindow::Create(::Team
* team
, UserBreakpoint
* breakpoint
,
55 UserInterfaceListener
* listener
, BHandler
* target
)
57 BreakpointEditWindow
* self
= new BreakpointEditWindow(
58 team
, breakpoint
, listener
, target
);
72 BreakpointEditWindow::MessageReceived(BMessage
* message
)
74 switch (message
->what
) {
75 case MSG_SET_BREAK_ALWAYS
:
76 fConditionInput
->SetEnabled(false);
78 case MSG_SET_BREAK_ON_CONDITION
:
79 fConditionInput
->SetEnabled(true);
81 case MSG_SAVE_BREAKPOINT_SETTINGS
:
83 if (fConditionRadio
->Value() == B_CONTROL_ON
) {
84 fListener
->SetBreakpointConditionRequested(
85 fTargetBreakpoint
, fConditionInput
->Text());
87 fListener
->ClearBreakpointConditionRequested(
97 BWindow::MessageReceived(message
);
105 BreakpointEditWindow::Show()
113 BreakpointEditWindow::_Init()
115 fConditionInput
= new BTextControl(NULL
, NULL
, NULL
);
116 BLayoutItem
* textLayoutItem
= fConditionInput
->CreateTextViewLayoutItem();
117 textLayoutItem
->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET
));
118 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
119 .SetInsets(B_USE_DEFAULT_SPACING
)
120 .Add((fAlwaysRadio
= new BRadioButton("Break always",
121 new BMessage(MSG_SET_BREAK_ALWAYS
))))
122 .AddGroup(B_HORIZONTAL
)
123 .Add((fConditionRadio
= new BRadioButton("Break on condition: ",
124 new BMessage(MSG_SET_BREAK_ON_CONDITION
))))
127 .AddGroup(B_HORIZONTAL
)
129 .Add((fSaveButton
= new BButton("Save",
130 new BMessage(MSG_SAVE_BREAKPOINT_SETTINGS
))))
131 .Add((fCancelButton
= new BButton("Cancel",
132 new BMessage(B_CANCEL
))))
136 AutoLocker
< ::Team
> teamLocker(fTeam
);
137 if (fTargetBreakpoint
->HasCondition()) {
138 fConditionRadio
->SetValue(B_CONTROL_ON
);
139 fConditionInput
->SetText(fTargetBreakpoint
->Condition());
141 fAlwaysRadio
->SetValue(B_CONTROL_ON
);
142 fConditionInput
->SetEnabled(false);