15b9ea6c3SJérôme Duval /*
25b9ea6c3SJérôme Duval * Copyright 2005, Jérôme DUVAL. All rights reserved.
35b9ea6c3SJérôme Duval * Distributed under the terms of the MIT License.
45b9ea6c3SJérôme Duval */
55b9ea6c3SJérôme Duval
65b9ea6c3SJérôme Duval #include <View.h>
75b9ea6c3SJérôme Duval #include <stdlib.h>
85b9ea6c3SJérôme Duval #include <string.h>
95b9ea6c3SJérôme Duval
105b9ea6c3SJérôme Duval #include "PartitionMenuItem.h"
115b9ea6c3SJérôme Duval
PartitionMenuItem(const char * name,const char * label,const char * menuLabel,BMessage * message,partition_id id)122e80f194SStephan Aßmus PartitionMenuItem::PartitionMenuItem(const char* name, const char* label,
132e80f194SStephan Aßmus const char* menuLabel, BMessage* message, partition_id id)
142e80f194SStephan Aßmus :
15*fab3e4a5SStephan Aßmus BMenuItem(label, message),
16*fab3e4a5SStephan Aßmus fID(id),
17*fab3e4a5SStephan Aßmus fMenuLabel(strdup(menuLabel)),
18*fab3e4a5SStephan Aßmus fName(strdup(name)),
19*fab3e4a5SStephan Aßmus fIsValidTarget(true)
205b9ea6c3SJérôme Duval {
215b9ea6c3SJérôme Duval }
225b9ea6c3SJérôme Duval
235b9ea6c3SJérôme Duval
~PartitionMenuItem()245b9ea6c3SJérôme Duval PartitionMenuItem::~PartitionMenuItem()
255b9ea6c3SJérôme Duval {
261eedf230SJérôme Duval free(fMenuLabel);
271eedf230SJérôme Duval free(fName);
285b9ea6c3SJérôme Duval }
292e80f194SStephan Aßmus
302e80f194SStephan Aßmus
312e80f194SStephan Aßmus partition_id
ID() const322e80f194SStephan Aßmus PartitionMenuItem::ID() const
332e80f194SStephan Aßmus {
342e80f194SStephan Aßmus return fID;
352e80f194SStephan Aßmus }
362e80f194SStephan Aßmus
372e80f194SStephan Aßmus
382e80f194SStephan Aßmus const char*
MenuLabel() const392e80f194SStephan Aßmus PartitionMenuItem::MenuLabel() const
402e80f194SStephan Aßmus {
41*fab3e4a5SStephan Aßmus return fMenuLabel != NULL ? fMenuLabel : Label();
422e80f194SStephan Aßmus }
432e80f194SStephan Aßmus
442e80f194SStephan Aßmus
452e80f194SStephan Aßmus const char*
Name() const462e80f194SStephan Aßmus PartitionMenuItem::Name() const
472e80f194SStephan Aßmus {
48*fab3e4a5SStephan Aßmus return fName != NULL ? fName : Label();
49*fab3e4a5SStephan Aßmus }
50*fab3e4a5SStephan Aßmus
51*fab3e4a5SStephan Aßmus
52*fab3e4a5SStephan Aßmus void
SetIsValidTarget(bool isValidTarget)53*fab3e4a5SStephan Aßmus PartitionMenuItem::SetIsValidTarget(bool isValidTarget)
54*fab3e4a5SStephan Aßmus {
55*fab3e4a5SStephan Aßmus fIsValidTarget = isValidTarget;
56*fab3e4a5SStephan Aßmus }
57*fab3e4a5SStephan Aßmus
58*fab3e4a5SStephan Aßmus
59*fab3e4a5SStephan Aßmus bool
IsValidTarget() const60*fab3e4a5SStephan Aßmus PartitionMenuItem::IsValidTarget() const
61*fab3e4a5SStephan Aßmus {
62*fab3e4a5SStephan Aßmus return fIsValidTarget;
632e80f194SStephan Aßmus }
642e80f194SStephan Aßmus
65