1/*
2 Project: Graphos
3 GRObjectEditor.m
4
5 Copyright (C) 2008-2013 GNUstep Application Project
6
7 Author: Ing. Riccardo Mottola
8
9 Created: 2008-02-25
10
11 This application is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
15
16 This application is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 Library General Public License for more details.
20
21 You should have received a copy of the GNU General Public
22 License along with this library; if not, write to the Free
23 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24 */
25
26
27#import "GRObjectEditor.h"
28#import "GRDocView.h"
29
30@implementation GRObjectEditor
31
32- (id)initEditor:(GRDrawableObject *)anObject
33{
34    self = [super init];
35    if(self != nil)
36    {
37        object = anObject;
38        groupSelected = NO;
39        editSelected = NO;
40        isDone = NO;
41        isValid = NO;
42    }
43    return self;
44}
45
46- (id)copyWithZone:(NSZone *)zone
47{
48    GRObjectEditor *objCopy;
49
50    objCopy = [[[self class] allocWithZone:zone] init];
51    objCopy->groupSelected = groupSelected;
52    objCopy->editSelected = editSelected;
53    objCopy->isDone = isDone;
54    objCopy->isValid = isValid;
55
56    objCopy->object = nil;
57
58    return objCopy;
59}
60
61
62- (void)setObject:(GRDrawableObject *)anObject
63{
64    object = anObject;
65}
66
67- (void)select
68{
69    [self selectAsGroup];
70}
71
72- (void)selectAsGroup
73{
74    if([object locked])
75        return;
76
77    if(!groupSelected)
78    {
79        groupSelected = YES;
80        editSelected = NO;
81        isValid = NO;
82
83	[[object view] unselectOtherObjects: (GRDrawableObject *)object];
84    }
85}
86
87- (void)selectForEditing
88{
89    if([object locked])
90        return;
91    editSelected = YES;
92    groupSelected = NO;
93    isValid = NO;
94    isDone = NO;
95    [[object view] unselectOtherObjects: (GRDrawableObject *)object];
96}
97
98
99- (void)unselect
100{
101    groupSelected = NO;
102    editSelected = NO;
103    isValid = YES;
104    isDone = YES;
105}
106
107- (BOOL)isSelected
108{
109    if(editSelected || groupSelected)
110        return YES;
111    return NO;
112}
113
114- (BOOL)isGroupSelected
115{
116    return groupSelected;
117}
118
119- (BOOL)isEditSelected
120{
121    return editSelected;
122}
123
124- (BOOL)isDone
125{
126  return isDone;
127}
128
129- (void)setIsDone:(BOOL)status
130{
131  isDone = status;
132}
133
134
135- (void)setIsValid:(BOOL)value
136{
137  isValid = value;
138}
139
140- (BOOL)isValid
141{
142  return isValid;
143}
144
145- (void)draw
146{
147}
148
149@end
150