1 /***************************************************************************
3 * Copyright 2010 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #ifndef _GRAPHICALSURFACE_H_
21 #define _GRAPHICALSURFACE_H_
23 #include "LogicalGraphicsObject.h"
24 #include "Rectangle.h"
26 #include "Orientation.h"
29 * Abstract Type representing a graphical surface.
31 class GraphicalSurface : public GraphicalObject{
33 GraphicalSurface(ObjectType type) : GraphicalObject(type,1,true),orientation(Zero),SourceViewport(0,0,0,0),DestinationViewport(0,0,0,0) {
37 * Set Orientation value
38 * @param orientation the new value. Multiples of 90 degrees. (0->0°, 1->90°, 2->180°,3->279°)
40 void setOrientation(OrientationType newOrientation){orientation = newOrientation;};
41 const OrientationType getOrientation(){return orientation;};
44 * Set Source Viewport (only use portion of source graphics)
45 * @param x Horizontal x position within source (clip from the left)
46 * @param y Vertical y position within source (clip from the top)
47 * @param width Width within source (can be used to clip from the right)
48 * @param height Height within source (can be used to clip fromt he bottom)
50 void setSourceRegion(const Rectangle& newSource){SourceViewport = newSource;};
51 const Rectangle& getSourceRegion(){ return SourceViewport;};
54 * Set Destination Viewport (Scale output)
55 * @param x Horizontal x position of destination
56 * @param y Vertical y position of destination
57 * @param width Width of destination
58 * @param height Height of destination
60 void setDestinationRegion(const Rectangle& newDestination){DestinationViewport = newDestination;};
62 void setPosition(const int& x, const int& y){DestinationViewport.x = x; DestinationViewport.y = y;};
63 Vector2 getPosition(){ return Vector2(DestinationViewport.x,DestinationViewport.y);}
64 void setDimension(const int& width, const int& height){DestinationViewport.width = width; DestinationViewport.height = height;};
65 const Rectangle& getDestinationRegion(){ return DestinationViewport;};
66 Vector2 getDimension(){ return Vector2(DestinationViewport.width, DestinationViewport.height);};
68 OrientationType orientation; // Rotation of the graphical content
69 Rectangle SourceViewport;
70 Rectangle DestinationViewport;
74 #endif /* _GRAPHICALSURFACE_H_ */