headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / storage / disk_device / PartitionParameterEditor.cpp
blobf1dfde69afdc381d7a3a762e326fb2f6e2207ad6
1 /*
2 * Copyright 2013, Axel Dörfler, axeld@pinc-software.de.
3 * Copyright 2009, Bryce Groff, brycegroff@gmail.com.
4 * Distributed under the terms of the MIT License.
5 */
7 #include <PartitionParameterEditor.h>
9 #include <String.h>
10 #include <View.h>
13 BPartitionParameterEditor::BPartitionParameterEditor()
15 fModificationMessage(NULL)
20 BPartitionParameterEditor::~BPartitionParameterEditor()
22 delete fModificationMessage;
26 /*! \brief Sets the controls of the editor to match the parameters
27 of the given \a partition.
29 For \c B_CREATE_PARAMETER_EDITOR editors, this will be the parent
30 partition.
32 void
33 BPartitionParameterEditor::SetTo(BPartition* partition)
38 /*! \brief Sets the modification message.
40 This message needs to be sent whenever an internal parameter changed.
41 This call takes over ownership of the provided message.
43 The message may contain a string field "parameter" with the value set
44 to the name of the changed parameter.
46 void
47 BPartitionParameterEditor::SetModificationMessage(BMessage* message)
49 delete fModificationMessage;
50 fModificationMessage = message;
54 /*! \brief The currently set modification message, if any.
56 BMessage*
57 BPartitionParameterEditor::ModificationMessage() const
59 return fModificationMessage;
63 /*! \brief Returns a view containing the controls needed for editing the
64 parameters.
66 To be overridden by derived classes.
67 The base class version returns \c NULL.
69 The returned BView is added to a window occasionally and removed, when
70 editing is done. The view belongs to the editor and needs to be deleted
71 by it. Subsequent calls to this method may return the same view, or each
72 time delete the old one and return a new one.
74 \return A view containing the controls needed for editing the parameters.
75 \c NULL can be returned, if no parameters are needed.
77 BView*
78 BPartitionParameterEditor::View()
80 return NULL;
84 /*! \brief Called when the user finishes editing the parameters.
86 To be overridden by derived classes.
87 The base class version returns \c true.
89 The method is supposed to check whether the parameters the user set,
90 are valid, and, if so, return \c true. Otherwise return \c false.
92 \return \c true, if the current parameters are valid, \c false otherwise.
94 bool
95 BPartitionParameterEditor::ValidateParameters() const
97 return true;
101 /*! \brief Called when a parameter has changed.
103 Each editor type comes with a number of predefined parameters that
104 may be changed from the outside while the editor is open. You can
105 either accept the changes, and update your controls correspondingly,
106 or else reject the change by returning an appropriate error code.
108 To be overridden by derived classes.
109 The base class version returns B_OK.
111 \param name The name of the changed parameter.
112 \param variant The new value of the parameter.
113 \return \c B_OK, if everything went fine, another error code otherwise.
115 status_t
116 BPartitionParameterEditor::ParameterChanged(const char* name,
117 const BVariant& variant)
119 return B_NOT_SUPPORTED;
123 /*! \brief Returns the edited parameters.
125 To be overridden by derived classes.
126 The base class version returns an empty string.
128 \param parameters A BString to be set to the edited parameters.
130 \return \c B_OK, if everything went fine, another error code otherwise.
132 status_t
133 BPartitionParameterEditor::GetParameters(BString& parameters)
135 parameters.SetTo("");
136 return B_OK;