xref: /haiku/src/kits/storage/disk_device/PartitionParameterEditor.cpp (revision d25503d3dbd8e3f526fd0a9bdd884b8e43c1b794)
1 /*
2  * Copyright 2009, Bryce Groff, brycegroff@gmail.com.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <PartitionParameterEditor.h>
7 
8 #include <String.h>
9 #include <View.h>
10 
11 
12 BPartitionParameterEditor::BPartitionParameterEditor()
13 {
14 }
15 
16 
17 BPartitionParameterEditor::~BPartitionParameterEditor()
18 {
19 }
20 
21 
22 /*!	\brief Returns a view containing the controls needed for editing the
23 		   parameters.
24 
25 	To be overridden by derived classes.
26 	The base class version returns \c NULL.
27 
28 	The returned BView is added to a window occasionally and removed, when
29 	editing is done. The view belongs to the editor and needs to be deleted
30 	by it. Subsequent calls to this method may return the same view, or each
31 	time delete the old one and return a new one.
32 
33 	\return A view containing the controls needed for editing the parameters.
34 			\c NULL can be returned, if no parameters are needed.
35 */
36 BView*
37 BPartitionParameterEditor::View()
38 {
39 	return NULL;
40 }
41 
42 
43 // FinishedEditing
44 /*!	\brief Called when the user finishes editing the parameters.
45 
46 	To be overridden by derived classes.
47 	The base class version returns \c true.
48 
49 	The method is supposed to check whether the parameters the user set,
50 	are valid, and, if so, return \c true. Otherwise return \c false.
51 
52 	\return \c true, if the current parameters are valid, \c false otherwise.
53 */
54 bool
55 BPartitionParameterEditor::FinishedEditing()
56 {
57 	return true;
58 }
59 
60 
61 /*!	\brief Returns the edited parameters.
62 
63 	To be overridden by derived classes.
64 	The base class version returns an empty string.
65 
66 	\param parameters A BString to be set to the edited parameters.
67 
68 	\return \c B_OK, if everything went fine, another error code otherwise.
69 */
70 status_t
71 BPartitionParameterEditor::GetParameters(BString* parameters)
72 {
73 	status_t error = (parameters ? B_OK : B_BAD_VALUE);
74 	if (error == B_OK)
75 		parameters->SetTo("");
76 	return error;
77 }
78 
79 
80 /*!	\brief Called when type information has changed.
81 
82 	To be overridden by derived classes.
83 	The base class version returns B_OK.
84 
85 	\param type A string that is the new type.
86 
87 	\return \c B_OK, if everything went fine, another error code otherwise.
88 */
89 status_t
90 BPartitionParameterEditor::PartitionTypeChanged(const char* type)
91 {
92 	return B_OK;
93 }
94 
95 
96 /*!	\brief Called when name information has changed.
97 
98 	To be overridden by derived classes.
99 	The base class version returns B_OK.
100 
101 	\param name A string that is the new name.
102 
103 	\return \c B_OK, if everything went fine, another error code otherwise.
104 */
105 status_t
106 BPartitionParameterEditor::PartitionNameChanged(const char* name)
107 {
108 	return B_OK;
109 }
110