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