include/SDL_rect.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 17 Nov 2009 04:53:15 +0000
changeset 3438 ca5663493497
parent 3407 d3baf5ac4e37
child 3536 0267b8b1595c
permissions -rw-r--r--
Scott to slouken Heres the wiz patch and additional files. (I think I got everything)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2275
diff changeset
     3
    Copyright (C) 1997-2009 Sam Lantinga
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    24
 *  \file SDL_rect.h
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    25
 *  
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    26
 *  Header file for SDL_rect definition and management functions.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#ifndef _SDL_rect_h
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#define _SDL_rect_h
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#include "SDL_stdinc.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#include "SDL_error.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include "SDL_pixels.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#include "SDL_rwops.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#include "begin_code.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
/* Set up for C function definitions, even when using C++ */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
#ifdef __cplusplus
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
/* *INDENT-OFF* */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
extern "C" {
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
/* *INDENT-ON* */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
#endif
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    46
 *  \brief A rectangle, with the origin at the upper left.
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    47
 *  
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    48
 *  \sa SDL_RectEmpty
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    49
 *  \sa SDL_RectEquals
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    50
 *  \sa SDL_HasIntersection
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    51
 *  \sa SDL_IntersectRect
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    52
 *  \sa SDL_UnionRect
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
typedef struct SDL_Rect
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
{
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
    int x, y;
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    int w, h;
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
} SDL_Rect;
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    61
 *  \brief Returns true if the rectangle has no area.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
#define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    66
 *  \brief Returns true if the two rectangles are equal.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
#define SDL_RectEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
                                ((A)->w == (B)->w) && ((A)->h == (B)->h))
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    72
 *  \brief Determine whether two rectangles intersect.
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    73
 *  
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    74
 *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
                                                     const SDL_Rect * B);
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    80
 *  \brief Calculate the intersection of two rectangles.
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    81
 *  
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    82
 *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
                                                   const SDL_Rect * B,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
                                                   SDL_Rect * result);
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    89
 *  \brief Calculate the union of two rectangles.
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
 */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
                                           const SDL_Rect * B,
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
                                           SDL_Rect * result);
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
2909
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    95
/**
3407
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    96
 *  \brief Calculate the intersection of a rectangle and line segment.
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    97
 *  
d3baf5ac4e37 Partial fix for bug #859
Sam Lantinga <slouken@libsdl.org>
parents: 2909
diff changeset
    98
 *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
2909
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    99
 */
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   100
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   101
                                                          rect, int *X1,
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   102
                                                          int *Y1, int *X2,
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   103
                                                          int *Y2);
3da0bb421d83 Added line clipping
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   104
2275
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
/* Ends C function definitions when using C++ */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
#ifdef __cplusplus
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
/* *INDENT-OFF* */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
}
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
/* *INDENT-ON* */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
#endif
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
#include "close_code.h"
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
#endif /* _SDL_rect_h */
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
12ea0fdc0df2 Split out the SDL_rect and SDL_surface functions into their own headers.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
/* vi: set ts=4 sw=4 expandtab: */