include/SDL_rect.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 19 Oct 2009 13:31:58 +0000
changeset 3407 d3baf5ac4e37
parent 2909 3da0bb421d83
child 3536 0267b8b1595c
permissions -rw-r--r--
Partial fix for bug #859

Header file update from Ken for improved doxygen output
     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  *  \brief A rectangle, with the origin at the upper left.
    47  *  
    48  *  \sa SDL_RectEmpty
    49  *  \sa SDL_RectEquals
    50  *  \sa SDL_HasIntersection
    51  *  \sa SDL_IntersectRect
    52  *  \sa SDL_UnionRect
    53  */
    54 typedef struct SDL_Rect
    55 {
    56     int x, y;
    57     int w, h;
    58 } SDL_Rect;
    59 
    60 /**
    61  *  \brief Returns true if the rectangle has no area.
    62  */
    63 #define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
    64 
    65 /**
    66  *  \brief Returns true if the two rectangles are equal.
    67  */
    68 #define SDL_RectEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
    69                                 ((A)->w == (B)->w) && ((A)->h == (B)->h))
    70 
    71 /**
    72  *  \brief Determine whether two rectangles intersect.
    73  *  
    74  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    75  */
    76 extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
    77                                                      const SDL_Rect * B);
    78 
    79 /**
    80  *  \brief Calculate the intersection of two rectangles.
    81  *  
    82  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    83  */
    84 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
    85                                                    const SDL_Rect * B,
    86                                                    SDL_Rect * result);
    87 
    88 /**
    89  *  \brief Calculate the union of two rectangles.
    90  */
    91 extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
    92                                            const SDL_Rect * B,
    93                                            SDL_Rect * result);
    94 
    95 /**
    96  *  \brief Calculate the intersection of a rectangle and line segment.
    97  *  
    98  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    99  */
   100 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
   101                                                           rect, int *X1,
   102                                                           int *Y1, int *X2,
   103                                                           int *Y2);
   104 
   105 /* Ends C function definitions when using C++ */
   106 #ifdef __cplusplus
   107 /* *INDENT-OFF* */
   108 }
   109 /* *INDENT-ON* */
   110 #endif
   111 #include "close_code.h"
   112 
   113 #endif /* _SDL_rect_h */
   114 
   115 /* vi: set ts=4 sw=4 expandtab: */