Debugger: Add table cell editors for various value types.

TableCell{Bool,Enumeration}Editor:
- OptionPopUp-derived editors for their respective value types.

TableCellIntegerEditor:
- TextControl-derived editor for integer values that validates inputs
  based on the target integer size and type.

Not actually used yet, but together with the previous changes, these lay
the groundwork for the remaining part of #9708.
This commit is contained in:
Rene Gollent
2015-06-13 16:57:19 -04:00
parent a82499551d
commit 026596dd1d
7 changed files with 216 additions and 0 deletions
+3
View File
@@ -300,8 +300,11 @@ Application Debugger :
WatchPromptWindow.cpp
# user_interface/gui/value
TableCellBoolEditor.cpp
TableCellEnumerationEditor.cpp
TableCellFormattedValueEditor.cpp
TableCellFormattedValueRenderer.cpp
TableCellIntegerEditor.cpp
TableCellOptionPopUpEditor.cpp
TableCellTextControlEditor.cpp
TableCellValueEditor.cpp
@@ -0,0 +1,40 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "TableCellBoolEditor.h"
#include "BoolValue.h"
TableCellBoolEditor::TableCellBoolEditor(::Value* initialValue,
ValueFormatter* formatter)
:
TableCellOptionPopUpEditor(initialValue, formatter)
{
}
TableCellBoolEditor::~TableCellBoolEditor()
{
}
status_t
TableCellBoolEditor::ConfigureOptions()
{
BoolValue* initialValue = dynamic_cast<BoolValue*>(InitialValue());
if (initialValue == NULL)
return B_BAD_VALUE;
status_t error = AddOption("true", true);
if (error != B_OK)
return error;
error = AddOption("false", false);
if (error != B_OK)
return error;
return SelectOptionFor(initialValue->GetValue());
}
@@ -0,0 +1,23 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef TABLE_CELL_BOOL_EDITOR_H
#define TABLE_CELL_BOOL_EDITOR_H
#include <TextControl.h>
#include "TableCellOptionPopUpEditor.h"
class TableCellBoolEditor : public TableCellOptionPopUpEditor {
public:
TableCellBoolEditor(::Value* initialValue,
ValueFormatter* formatter);
virtual ~TableCellBoolEditor();
virtual status_t ConfigureOptions();
};
#endif // TABLE_CELL_BOOL_EDITOR_H
@@ -0,0 +1,48 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "TableCellEnumerationEditor.h"
#include "EnumerationValue.h"
#include "Type.h"
TableCellEnumerationEditor::TableCellEnumerationEditor(::Value* initialValue,
ValueFormatter* formatter)
:
TableCellOptionPopUpEditor(initialValue, formatter)
{
}
TableCellEnumerationEditor::~TableCellEnumerationEditor()
{
}
status_t
TableCellEnumerationEditor::ConfigureOptions()
{
EnumerationValue* initialValue = dynamic_cast<EnumerationValue*>(
InitialValue());
if (initialValue == NULL)
return B_BAD_VALUE;
EnumerationType* type = initialValue->GetType();
for (int32 i = 0; i < type->CountValues(); i++) {
EnumeratorValue* value = type->ValueAt(i);
BString output;
status_t error = AddOption(value->Name(), value->Value().ToInt32());
if (error != B_OK)
return error;
}
BVariant integerValue;
if (!initialValue->ToVariant(integerValue))
return B_NO_MEMORY;
return SelectOptionFor(integerValue.ToInt32());
}
@@ -0,0 +1,24 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef TABLE_CELL_ENUMERATION_EDITOR_H
#define TABLE_CELL_ENUMERATION_EDITOR_H
#include <TextControl.h>
#include "TableCellOptionPopUpEditor.h"
class TableCellEnumerationEditor : public TableCellOptionPopUpEditor {
public:
TableCellEnumerationEditor(
::Value* initialValue,
ValueFormatter* formatter);
virtual ~TableCellEnumerationEditor();
virtual status_t ConfigureOptions();
};
#endif // TABLE_CELL_ENUMERATION_EDITOR_H
@@ -0,0 +1,52 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "TableCellIntegerEditor.h"
#include <ctype.h>
#include <Variant.h>
#include "IntegerValue.h"
#include "IntegerValueFormatter.h"
TableCellIntegerEditor::TableCellIntegerEditor(::Value* initialValue,
ValueFormatter* formatter)
:
TableCellTextControlEditor(initialValue, formatter)
{
}
TableCellIntegerEditor::~TableCellIntegerEditor()
{
}
bool
TableCellIntegerEditor::ValidateInput() const
{
BVariant variantValue;
if (!InitialValue()->ToVariant(variantValue))
return false;
return GetValueFormatter()->ValidateFormattedValue(Text(),
variantValue.Type());
}
status_t
TableCellIntegerEditor::GetValueForInput(::Value*& _output) const
{
BVariant variantValue;
if (!InitialValue()->ToVariant(variantValue))
return B_NO_MEMORY;
return GetValueFormatter()->GetValueFromFormattedInput(Text(),
variantValue.Type(), _output);
}
@@ -0,0 +1,26 @@
/*
* Copyright 2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef TABLE_CELL_INTEGER_EDITOR_H
#define TABLE_CELL_INTEGER_EDITOR_H
#include <TextControl.h>
#include "IntegerFormatter.h"
#include "TableCellTextControlEditor.h"
class TableCellIntegerEditor : public TableCellTextControlEditor {
public:
TableCellIntegerEditor(::Value* initialValue,
ValueFormatter* formatter);
virtual ~TableCellIntegerEditor();
virtual bool ValidateInput() const;
virtual status_t GetValueForInput(::Value*& _output) const;
// returns reference
};
#endif // TABLE_CELL_INTEGER_EDITOR_H