From 1f3db0d0d68a411559e58a3b76e982153e1d6a13 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 21 Jul 2015 22:24:38 -0400 Subject: [PATCH] Debugger: Flesh out option-based value editors. TableCellOptionPopUpEditor: - Add virtual hook for retrieving the final selected value. Implement accordingly in Bool and Enumeration editor subclasses. - Implement calling the edit completion hook upon value changes. --- .../gui/value/TableCellBoolEditor.cpp | 15 ++++++++++++++ .../gui/value/TableCellBoolEditor.h | 2 ++ .../gui/value/TableCellEnumerationEditor.cpp | 20 +++++++++++++++++++ .../gui/value/TableCellEnumerationEditor.h | 2 ++ .../gui/value/TableCellOptionPopUpEditor.cpp | 8 +++++++- .../gui/value/TableCellOptionPopUpEditor.h | 2 ++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp index 5a5b7afa33..7a0ed75dea 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp +++ b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp @@ -38,3 +38,18 @@ TableCellBoolEditor::ConfigureOptions() return SelectOptionFor(initialValue->GetValue()); } + + +status_t +TableCellBoolEditor::GetSelectedValue(::Value*& _value) const +{ + const char* name = NULL; + int32 selectedValue = 0; + SelectedOption(&name, &selectedValue); + BoolValue* value = new(std::nothrow) BoolValue((bool)selectedValue); + if (value == NULL) + return B_NO_MEMORY; + + _value = value; + return B_OK; +} diff --git a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h index b8fd82811a..7b02830b89 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h +++ b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h @@ -18,6 +18,8 @@ public: virtual status_t ConfigureOptions(); +protected: + virtual status_t GetSelectedValue(::Value*& _value) const; }; #endif // TABLE_CELL_BOOL_EDITOR_H diff --git a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp index fdae22afe3..0ab8ef5af8 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp +++ b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp @@ -46,3 +46,23 @@ TableCellEnumerationEditor::ConfigureOptions() return SelectOptionFor(integerValue.ToInt32()); } + + +status_t +TableCellEnumerationEditor::GetSelectedValue(::Value*& _value) const +{ + EnumerationValue* initialValue = dynamic_cast( + InitialValue()); + EnumerationType* type = initialValue->GetType(); + const char* name = NULL; + int32 selectedValue = 0; + SelectedOption(&name, &selectedValue); + + EnumerationValue* value = new(std::nothrow) EnumerationValue(type, + BVariant(selectedValue)); + if (value == NULL) + return B_NO_MEMORY; + + _value = value; + return B_OK; +} diff --git a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h index 4a26e34de4..94808a454e 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h +++ b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h @@ -19,6 +19,8 @@ public: virtual status_t ConfigureOptions(); +protected: + virtual status_t GetSelectedValue(::Value*& _value) const; }; #endif // TABLE_CELL_ENUMERATION_EDITOR_H diff --git a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp index 4fa432dec4..2eef714be5 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp +++ b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp @@ -65,7 +65,13 @@ TableCellOptionPopUpEditor::MessageReceived(BMessage* message) switch (message->what) { case MSG_SELECTED_OPTION_CHANGED: { - // TODO: implement + ::Value* value = NULL; + if (GetSelectedValue(value) == B_OK) { + BReference< ::Value> valueReference(value, true); + NotifyEditCompleted(value); + } else + NotifyEditCancelled(); + break; } default: diff --git a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h index e9f3d9ee0c..d65d971bd1 100644 --- a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h +++ b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h @@ -27,6 +27,8 @@ public: virtual status_t ConfigureOptions() = 0; protected: + virtual status_t GetSelectedValue(::Value*& _value) const = 0; + virtual void AttachedToWindow(); virtual void MessageReceived(BMessage* message); };