mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
Added initial Rectangle implementation.
git-svn-id: http://xni.googlecode.com/svn/XNI@6 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
cc255d1616
commit
43c1f445db
34
Classes/Retronator/Xni/Framework/Rectangle.h
Normal file
34
Classes/Retronator/Xni/Framework/Rectangle.h
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Rectangle.h
|
||||
// XNI
|
||||
//
|
||||
// Created by Matej Jan on 22.7.10.
|
||||
// Copyright 2010 Retronator, Razum. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Rectangle : NSObject {
|
||||
RectangleStruct data;
|
||||
}
|
||||
|
||||
- (id) initWithX:(int)x Y:(int)y Width:(int)width Height:(int)height;
|
||||
- (id) initWithStruct:(RectangleStruct*) rectangleStruct;
|
||||
- (id) initWithRectangle:(Rectangle*) rectangle;
|
||||
|
||||
+ (Rectangle*) rectangleWithX:(int)x Y:(int)y Width:(int)width Height:(int)height;
|
||||
+ (Rectangle*) rectangleWithStruct:(RectangleStruct*) rectangleStruct;
|
||||
+ (Rectangle*) rectangleWithRectangle:(Rectangle*) rectangle;
|
||||
|
||||
@property (nonatomic) int x;
|
||||
@property (nonatomic) int y;
|
||||
@property (nonatomic) int width;
|
||||
@property (nonatomic) int height;
|
||||
|
||||
@property (nonatomic, readonly) RectangleStruct *data;
|
||||
|
||||
+ (Rectangle*) empty;
|
||||
|
||||
@end
|
60
Classes/Retronator/Xni/Framework/Rectangle.m
Normal file
60
Classes/Retronator/Xni/Framework/Rectangle.m
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// Rectangle.m
|
||||
// XNI
|
||||
//
|
||||
// Created by Matej Jan on 22.7.10.
|
||||
// Copyright 2010 Retronator, Razum. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Rectangle.h"
|
||||
|
||||
|
||||
@implementation Rectangle
|
||||
|
||||
- (id) initWithX:(int)x Y:(int)y Width:(int)width Height:(int)height {
|
||||
if (self = [super init]) {
|
||||
data = RectangleMake(x, y, width, height);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithStruct:(RectangleStruct*) rectangleStruct {
|
||||
if (self = [super init]) {
|
||||
data = *rectangleStruct;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithRectangle:(Rectangle*) rectangle {
|
||||
return [self initWithStruct:rectangle.data];
|
||||
}
|
||||
|
||||
+ (Rectangle*) rectangleWithX:(int)x Y:(int)y Width:(int)width Height:(int)height {
|
||||
return [[[Rectangle alloc] initWithX:x Y:y Width:width Height:height] autorelease];
|
||||
}
|
||||
|
||||
+ (Rectangle*) rectangleWithStruct:(RectangleStruct*) rectangleStruct {
|
||||
return [[[Rectangle alloc] initWithStruct:rectangleStruct] autorelease];
|
||||
}
|
||||
|
||||
+ (Rectangle*) rectangleWithRectangle:(Rectangle*) rectangle {
|
||||
return [[[Rectangle alloc] initWithRectangle:rectangle] autorelease];
|
||||
}
|
||||
|
||||
- (int) x {return data.x;}
|
||||
- (void) setX:(int)value {data.x = value;}
|
||||
|
||||
- (int) y {return data.y;}
|
||||
- (void) setY:(int)value {data.y = value;}
|
||||
|
||||
- (int) width {return data.width;}
|
||||
- (void) setWidth:(int)value {data.width = value;}
|
||||
|
||||
- (int) height {return data.height;}
|
||||
- (void) setHeight:(int)value {data.height = value;}
|
||||
|
||||
- (RectangleStruct*) data {return &data;}
|
||||
|
||||
+ (Rectangle*) empty {return [Rectangle rectangleWithX:0 Y:0 Width:0 Height:0];}
|
||||
|
||||
@end
|
22
Classes/Retronator/Xni/Framework/RectangleStruct.h
Normal file
22
Classes/Retronator/Xni/Framework/RectangleStruct.h
Normal file
@ -0,0 +1,22 @@
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} RectangleStruct;
|
||||
|
||||
static inline RectangleStruct RectangleMake(int x, int y, int width, int height) {
|
||||
RectangleStruct rectangle;
|
||||
rectangle.x = x;
|
||||
rectangle.y = y;
|
||||
rectangle.width = width;
|
||||
rectangle.height = height;
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
static inline void RectangleSet(RectangleStruct *rectangle, int x, int y, int width, int height) {
|
||||
rectangle->x = x;
|
||||
rectangle->y = y;
|
||||
rectangle->width = width;
|
||||
rectangle->height = height;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
// Data structures
|
||||
#import "RectangleStruct.h"
|
||||
@class Rectangle;
|
@ -0,0 +1,2 @@
|
||||
// Data structures
|
||||
#import "Rectangle.h"
|
@ -18,6 +18,14 @@
|
||||
B5DE18A111F8888B00BF3275 /* Retronator.Xni.Framework.classes.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE189F11F8888B00BF3275 /* Retronator.Xni.Framework.classes.h */; };
|
||||
B5DE18A211F8888B00BF3275 /* Retronator.Xni.Framework.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE18A011F8888B00BF3275 /* Retronator.Xni.Framework.h */; };
|
||||
B5DE18A411F888BC00BF3275 /* System.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE18A311F888BC00BF3275 /* System.h */; };
|
||||
B5DE18FE11F88AD900BF3275 /* GameHost.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE18FA11F88AD900BF3275 /* GameHost.h */; };
|
||||
B5DE18FF11F88AD900BF3275 /* GameHost.m in Sources */ = {isa = PBXBuildFile; fileRef = B5DE18FB11F88AD900BF3275 /* GameHost.m */; };
|
||||
B5DE190011F88AD900BF3275 /* GameWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE18FC11F88AD900BF3275 /* GameWindow.h */; };
|
||||
B5DE190111F88AD900BF3275 /* GameWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = B5DE18FD11F88AD900BF3275 /* GameWindow.m */; };
|
||||
B5DE190411F88AF500BF3275 /* Rectangle.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE190211F88AF500BF3275 /* Rectangle.h */; };
|
||||
B5DE190511F88AF500BF3275 /* Rectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = B5DE190311F88AF500BF3275 /* Rectangle.m */; };
|
||||
B5DE190711F88B5D00BF3275 /* RectangleStruct.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE190611F88B5D00BF3275 /* RectangleStruct.h */; };
|
||||
B5DE193111F898AE00BF3275 /* DisplayOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = B5DE193011F898AE00BF3275 /* DisplayOrientation.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -33,6 +41,14 @@
|
||||
B5DE189F11F8888B00BF3275 /* Retronator.Xni.Framework.classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Retronator.Xni.Framework.classes.h; sourceTree = "<group>"; };
|
||||
B5DE18A011F8888B00BF3275 /* Retronator.Xni.Framework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Retronator.Xni.Framework.h; sourceTree = "<group>"; };
|
||||
B5DE18A311F888BC00BF3275 /* System.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = System.h; sourceTree = "<group>"; };
|
||||
B5DE18FA11F88AD900BF3275 /* GameHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameHost.h; sourceTree = "<group>"; };
|
||||
B5DE18FB11F88AD900BF3275 /* GameHost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameHost.m; sourceTree = "<group>"; };
|
||||
B5DE18FC11F88AD900BF3275 /* GameWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameWindow.h; sourceTree = "<group>"; };
|
||||
B5DE18FD11F88AD900BF3275 /* GameWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameWindow.m; sourceTree = "<group>"; };
|
||||
B5DE190211F88AF500BF3275 /* Rectangle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rectangle.h; sourceTree = "<group>"; };
|
||||
B5DE190311F88AF500BF3275 /* Rectangle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Rectangle.m; sourceTree = "<group>"; };
|
||||
B5DE190611F88B5D00BF3275 /* RectangleStruct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RectangleStruct.h; sourceTree = "<group>"; };
|
||||
B5DE193011F898AE00BF3275 /* DisplayOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayOrientation.h; sourceTree = "<group>"; };
|
||||
D2AAC07E0554694100DB518D /* libXNI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libXNI.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -113,6 +129,14 @@
|
||||
children = (
|
||||
B5DE189F11F8888B00BF3275 /* Retronator.Xni.Framework.classes.h */,
|
||||
B5DE18A011F8888B00BF3275 /* Retronator.Xni.Framework.h */,
|
||||
B5DE18FA11F88AD900BF3275 /* GameHost.h */,
|
||||
B5DE18FB11F88AD900BF3275 /* GameHost.m */,
|
||||
B5DE18FC11F88AD900BF3275 /* GameWindow.h */,
|
||||
B5DE18FD11F88AD900BF3275 /* GameWindow.m */,
|
||||
B5DE190611F88B5D00BF3275 /* RectangleStruct.h */,
|
||||
B5DE190211F88AF500BF3275 /* Rectangle.h */,
|
||||
B5DE190311F88AF500BF3275 /* Rectangle.m */,
|
||||
B5DE193011F898AE00BF3275 /* DisplayOrientation.h */,
|
||||
);
|
||||
path = Framework;
|
||||
sourceTree = "<group>";
|
||||
@ -146,6 +170,11 @@
|
||||
B5DE18A111F8888B00BF3275 /* Retronator.Xni.Framework.classes.h in Headers */,
|
||||
B5DE18A211F8888B00BF3275 /* Retronator.Xni.Framework.h in Headers */,
|
||||
B5DE18A411F888BC00BF3275 /* System.h in Headers */,
|
||||
B5DE18FE11F88AD900BF3275 /* GameHost.h in Headers */,
|
||||
B5DE190011F88AD900BF3275 /* GameWindow.h in Headers */,
|
||||
B5DE190411F88AF500BF3275 /* Rectangle.h in Headers */,
|
||||
B5DE190711F88B5D00BF3275 /* RectangleStruct.h in Headers */,
|
||||
B5DE193111F898AE00BF3275 /* DisplayOrientation.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -195,6 +224,9 @@
|
||||
B5DE189911F8884A00BF3275 /* Delegate.m in Sources */,
|
||||
B5DE189B11F8884A00BF3275 /* Event.m in Sources */,
|
||||
B5DE189D11F8884A00BF3275 /* EventArgs.m in Sources */,
|
||||
B5DE18FF11F88AD900BF3275 /* GameHost.m in Sources */,
|
||||
B5DE190111F88AD900BF3275 /* GameWindow.m in Sources */,
|
||||
B5DE190511F88AF500BF3275 /* Rectangle.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user