libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / icon-o-matic / style / AssignStyleCommand.cpp
blob90f2a928beafb3367b4c17d9cc4c1c98280b64a5
1 /*
2 * Copyright 2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
9 #include "AssignStyleCommand.h"
11 #include <Catalog.h>
12 #include <Locale.h>
14 #include "Shape.h"
15 #include "Style.h"
18 #undef B_TRANSLATION_CONTEXT
19 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-AssignStyleCmd"
22 // constructor
23 AssignStyleCommand::AssignStyleCommand(Shape* shape,
24 Style* style)
25 : Command(),
26 fShape(shape),
27 fOldStyle(shape ? shape->Style() : NULL),
28 fNewStyle(style)
30 if (fOldStyle)
31 fOldStyle->AcquireReference();
32 if (fNewStyle)
33 fNewStyle->AcquireReference();
36 // destructor
37 AssignStyleCommand::~AssignStyleCommand()
39 if (fOldStyle)
40 fOldStyle->ReleaseReference();
41 if (fNewStyle)
42 fNewStyle->ReleaseReference();
45 // InitCheck
46 status_t
47 AssignStyleCommand::InitCheck()
49 return fShape && fNewStyle ? B_OK : B_NO_INIT;
52 // Perform
53 status_t
54 AssignStyleCommand::Perform()
56 fShape->SetStyle(fNewStyle);
58 return B_OK;
61 // Undo
62 status_t
63 AssignStyleCommand::Undo()
65 fShape->SetStyle(fOldStyle);
67 return B_OK;
70 // GetName
71 void
72 AssignStyleCommand::GetName(BString& name)
74 name << B_TRANSLATE("Assign Style");
75 if (fNewStyle)
76 name << " \"" << fNewStyle->Name() << "\"";