1/* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9#include "UnassignPathCommand.h" 10 11#include <Catalog.h> 12#include <Locale.h> 13 14#include "PathContainer.h" 15#include "Shape.h" 16#include "VectorPath.h" 17 18 19#undef B_TRANSLATION_CONTEXT 20#define B_TRANSLATION_CONTEXT "Icon-O-Matic-UnassignPathCmd" 21 22 23// constructor 24UnassignPathCommand::UnassignPathCommand(Shape* shape, 25 VectorPath* path) 26 : Command(), 27 fShape(shape), 28 fPath(path), 29 fPathRemoved(false) 30{ 31} 32 33// destructor 34UnassignPathCommand::~UnassignPathCommand() 35{ 36 if (fPathRemoved && fPath) 37 fPath->Release(); 38} 39 40// InitCheck 41status_t 42UnassignPathCommand::InitCheck() 43{ 44 return fShape && fPath ? B_OK : B_NO_INIT; 45} 46 47// Perform 48status_t 49UnassignPathCommand::Perform() 50{ 51 // remove path from shape 52 fShape->Paths()->RemovePath(fPath); 53 fPathRemoved = true; 54 55 return B_OK; 56} 57 58// Undo 59status_t 60UnassignPathCommand::Undo() 61{ 62 // add path to shape 63 fShape->Paths()->AddPath(fPath); 64 fPathRemoved = false; 65 66 return B_OK; 67} 68 69// GetName 70void 71UnassignPathCommand::GetName(BString& name) 72{ 73 name << B_TRANSLATE("Unassign Path"); 74} 75