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