1 /* 2 * Copyright 2005, Jérôme DUVAL. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <View.h> 7 #include <stdlib.h> 8 #include <string.h> 9 10 #include "PartitionMenuItem.h" 11 12 PartitionMenuItem::PartitionMenuItem(const char* name, const char* label, 13 const char* menuLabel, BMessage* message, partition_id id) 14 : 15 BMenuItem(label, message), 16 fID(id), 17 fMenuLabel(strdup(menuLabel)), 18 fName(strdup(name)), 19 fIsValidTarget(true) 20 { 21 } 22 23 24 PartitionMenuItem::~PartitionMenuItem() 25 { 26 free(fMenuLabel); 27 free(fName); 28 } 29 30 31 partition_id 32 PartitionMenuItem::ID() const 33 { 34 return fID; 35 } 36 37 38 const char* 39 PartitionMenuItem::MenuLabel() const 40 { 41 return fMenuLabel != NULL ? fMenuLabel : Label(); 42 } 43 44 45 const char* 46 PartitionMenuItem::Name() const 47 { 48 return fName != NULL ? fName : Label(); 49 } 50 51 52 void 53 PartitionMenuItem::SetIsValidTarget(bool isValidTarget) 54 { 55 fIsValidTarget = isValidTarget; 56 } 57 58 59 bool 60 PartitionMenuItem::IsValidTarget() const 61 { 62 return fIsValidTarget; 63 } 64 65