btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / debugger / user_interface / gui / value / value_handlers / FloatValueHandler.cpp
blob039620a82a2879b464bfd142c913b57832f13e00
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "FloatValueHandler.h"
9 #include <new>
11 #include "FloatValue.h"
12 #include "FloatValueFormatter.h"
13 #include "TableCellFloatEditor.h"
14 #include "TableCellFormattedValueRenderer.h"
17 FloatValueHandler::FloatValueHandler()
22 FloatValueHandler::~FloatValueHandler()
27 status_t
28 FloatValueHandler::Init()
30 return B_OK;
34 float
35 FloatValueHandler::SupportsValue(Value* value)
37 return dynamic_cast<FloatValue*>(value) != NULL ? 0.5f : 0;
41 status_t
42 FloatValueHandler::GetValueFormatter(Value* value,
43 ValueFormatter*& _formatter)
45 if (dynamic_cast<FloatValue*>(value) == NULL)
46 return B_BAD_VALUE;
48 FloatValueFormatter* formatter = new(std::nothrow) FloatValueFormatter;
49 if (formatter == NULL)
50 return B_NO_MEMORY;
52 _formatter = formatter;
53 return B_OK;
57 status_t
58 FloatValueHandler::GetTableCellValueRenderer(Value* value,
59 TableCellValueRenderer*& _renderer)
61 if (dynamic_cast<FloatValue*>(value) == NULL)
62 return B_BAD_VALUE;
64 ValueFormatter* formatter = NULL;
65 status_t error = GetValueFormatter(value, formatter);
66 if (error != B_OK)
67 return error;
68 BReference<ValueFormatter> formatterReference(formatter, true);
70 // create the renderer
71 TableCellValueRenderer* renderer
72 = new(std::nothrow) TableCellFormattedValueRenderer(formatter);
73 if (renderer == NULL)
74 return B_NO_MEMORY;
76 _renderer = renderer;
77 return B_OK;
81 status_t
82 FloatValueHandler::GetTableCellValueEditor(Value* _value, Settings* settings,
83 TableCellValueEditor*& _editor)
85 FloatValue* value = dynamic_cast<FloatValue*>(_value);
86 if (value == NULL)
87 return B_BAD_VALUE;
89 ValueFormatter* formatter;
90 status_t error = GetValueFormatter(value, formatter);
91 if (error != B_OK)
92 return error;
93 BReference<ValueFormatter> formatterReference(formatter, true);
95 TableCellFloatEditor* editor = new(std::nothrow)
96 TableCellFloatEditor(value, formatter);
97 if (editor == NULL)
98 return B_NO_MEMORY;
100 BReference<TableCellFloatEditor> editorReference(editor, true);
101 error = editor->Init();
102 if (error != B_OK)
103 return error;
105 editorReference.Detach();
106 _editor = editor;
107 return B_OK;