1/*
2 * Copyright 2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus <superstippi@gmx.de>
7 */
8
9#include "Util.h"
10
11#include <new>
12
13#include "AddPathsCommand.h"
14#include "AddStylesCommand.h"
15#include "Container.h"
16#include "Style.h"
17#include "VectorPath.h"
18
19using std::nothrow;
20
21// new_style
22void
23new_style(rgb_color color, Container<Style>* container,
24		  Style** style, AddStylesCommand** command)
25{
26	*style = new (nothrow) Style(color);
27	if (*style) {
28		Style* styles[1];
29		styles[0] = *style;
30		*command = new (nothrow) AddStylesCommand(
31			container, styles, 1,
32			container->CountItems());
33		if (*command == NULL) {
34			delete *style;
35			*style = NULL;
36		}
37	} else {
38		*command = NULL;
39	}
40}
41
42// new_path
43void
44new_path(Container<VectorPath>* container, VectorPath** path,
45		 AddPathsCommand** command, VectorPath* other)
46{
47	if (other)
48		*path = new (nothrow) VectorPath(*other);
49	else
50		*path = new (nothrow) VectorPath();
51
52	if (*path) {
53		VectorPath* paths[1];
54		paths[0] = *path;
55		int32 insertIndex = other ? container->IndexOf(other) + 1
56								  : container->CountItems();
57		*command = new (nothrow) AddPathsCommand(
58			container, paths, 1, true, insertIndex);
59		if (*command == NULL) {
60			delete *path;
61			*path = NULL;
62		}
63	} else {
64		*command = NULL;
65	}
66}
67
68
69
70
71