include/SDL_shape.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 17 Jan 2011 09:09:15 -0800
changeset 5009 b21ad135d86b
parent 4849 0b918c186938
child 5535 96594ac5fd1a
permissions -rw-r--r--
Minor documentation consistency cleanup
eligottlieb@4766
     1
/*
eligottlieb@4766
     2
    SDL - Simple DirectMedia Layer
eligottlieb@4766
     3
    Copyright (C) 2010 Eli Gottlieb
eligottlieb@4766
     4
eligottlieb@4766
     5
    This library is free software; you can redistribute it and/or
eligottlieb@4766
     6
    modify it under the terms of the GNU Lesser General Public
eligottlieb@4766
     7
    License as published by the Free Software Foundation; either
eligottlieb@4766
     8
    version 2.1 of the License, or (at your option) any later version.
eligottlieb@4766
     9
eligottlieb@4766
    10
    This library is distributed in the hope that it will be useful,
eligottlieb@4766
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
eligottlieb@4766
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
eligottlieb@4766
    13
    Lesser General Public License for more details.
eligottlieb@4766
    14
eligottlieb@4766
    15
    You should have received a copy of the GNU Lesser General Public
eligottlieb@4766
    16
    License along with this library; if not, write to the Free Software
eligottlieb@4766
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
eligottlieb@4766
    18
eligottlieb@4766
    19
    Eli Gottlieb
eligottlieb@4766
    20
    eligottlieb@gmail.com
eligottlieb@4766
    21
*/
eligottlieb@4766
    22
eligottlieb@4769
    23
#ifndef _SDL_shape_h
eligottlieb@4769
    24
#define _SDL_shape_h
eligottlieb@4769
    25
eligottlieb@4769
    26
#include "SDL_stdinc.h"
eligottlieb@4769
    27
#include "SDL_pixels.h"
eligottlieb@4769
    28
#include "SDL_rect.h"
eligottlieb@4769
    29
#include "SDL_surface.h"
eligottlieb@4769
    30
#include "SDL_video.h"
eligottlieb@4769
    31
eligottlieb@4769
    32
#include "begin_code.h"
eligottlieb@4769
    33
/* Set up for C function definitions, even when using C++ */
eligottlieb@4769
    34
#ifdef __cplusplus
eligottlieb@4769
    35
/* *INDENT-OFF* */
eligottlieb@4769
    36
extern "C" {
eligottlieb@4769
    37
/* *INDENT-ON* */
eligottlieb@4769
    38
#endif
eligottlieb@4766
    39
eligottlieb@4779
    40
/** \file SDL_shape.h
eligottlieb@4779
    41
 *
eligottlieb@4781
    42
 * Header file for the shaped window API.
eligottlieb@4779
    43
 */
eligottlieb@4779
    44
eligottlieb@4801
    45
#define SDL_NONSHAPEABLE_WINDOW -1
eligottlieb@4801
    46
#define SDL_INVALID_SHAPE_ARGUMENT -2
eligottlieb@4801
    47
#define SDL_WINDOW_LACKS_SHAPE -3
eligottlieb@4801
    48
eligottlieb@4766
    49
/**
eligottlieb@4781
    50
 *  \brief Create a window that can be shaped with the specified position, dimensions, and flags.
eligottlieb@4766
    51
 *  
eligottlieb@4766
    52
 *  \param title The title of the window, in UTF-8 encoding.
eligottlieb@4766
    53
 *  \param x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 
eligottlieb@4766
    54
 *               ::SDL_WINDOWPOS_UNDEFINED.
eligottlieb@4766
    55
 *  \param y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 
eligottlieb@4766
    56
 *               ::SDL_WINDOWPOS_UNDEFINED.
eligottlieb@4766
    57
 *  \param w     The width of the window.
eligottlieb@4766
    58
 *  \param h     The height of the window.
eligottlieb@4766
    59
 *  \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 
eligottlieb@4767
    60
 *               ::SDL_WINDOW_OPENGL,     ::SDL_WINDOW_INPUT_GRABBED,
eligottlieb@4766
    61
 *               ::SDL_WINDOW_SHOWN,      ::SDL_WINDOW_RESIZABLE,
eligottlieb@4766
    62
 *               ::SDL_WINDOW_MAXIMIZED,  ::SDL_WINDOW_MINIMIZED,
eligottlieb@4767
    63
 *		 ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
eligottlieb@4766
    64
 *  
eligottlieb@4801
    65
 *  \return The window created, or NULL if window creation failed.
eligottlieb@4766
    66
 *  
eligottlieb@4766
    67
 *  \sa SDL_DestroyWindow()
eligottlieb@4766
    68
 */
eligottlieb@4768
    69
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
eligottlieb@4766
    70
eligottlieb@4778
    71
/**
eligottlieb@4778
    72
 * \brief Return whether the given window is a shaped window. 
eligottlieb@4778
    73
 *
eligottlieb@4778
    74
 * \param window The window to query for being shaped.
eligottlieb@4778
    75
 *
eligottlieb@4781
    76
 * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
eligottlieb@4778
    77
 * \sa SDL_CreateShapedWindow
eligottlieb@4778
    78
 */
eligottlieb@4781
    79
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
eligottlieb@4778
    80
eligottlieb@4778
    81
/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
eligottlieb@4781
    82
typedef enum {
eligottlieb@4781
    83
	/** \brief The default mode, a binarized alpha cutoff of 1. */
eligottlieb@4781
    84
	ShapeModeDefault,
eligottlieb@4781
    85
	/** \brief A binarized alpha cutoff with a given integer value. */
eligottlieb@4807
    86
	ShapeModeBinarizeAlpha,
eligottlieb@4807
    87
	/** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
eligottlieb@4807
    88
	ShapeModeReverseBinarizeAlpha,
eligottlieb@4807
    89
	/** \brief A color key is applied. */
eligottlieb@4807
    90
	ShapeModeColorKey
eligottlieb@4781
    91
} WindowShapeMode;
eligottlieb@4846
    92
eligottlieb@4846
    93
#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
eligottlieb@4846
    94
eligottlieb@4778
    95
/** \brief A union containing parameters for shaped windows. */
eligottlieb@4778
    96
typedef union {
eligottlieb@4778
    97
	/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
eligottlieb@4778
    98
	Uint8 binarizationCutoff;
eligottlieb@4807
    99
	SDL_Color colorKey;
eligottlieb@4778
   100
} SDL_WindowShapeParams;
eligottlieb@4778
   101
eligottlieb@4778
   102
/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
eligottlieb@4778
   103
typedef struct SDL_WindowShapeMode {
eligottlieb@4779
   104
	/** \brief The mode of these window-shape parameters. */
eligottlieb@4778
   105
	WindowShapeMode mode;
eligottlieb@4779
   106
	/** \brief Window-shape parameters. */
eligottlieb@4778
   107
	SDL_WindowShapeParams parameters;
eligottlieb@4778
   108
} SDL_WindowShapeMode;
eligottlieb@4778
   109
eligottlieb@4778
   110
/**
eligottlieb@4780
   111
 * \brief Set the shape and parameters of a shaped window.
eligottlieb@4778
   112
 *
eligottlieb@4778
   113
 * \param window The shaped window whose parameters should be set.
eligottlieb@4781
   114
 * \param shape A surface encoding the desired shape for the window.
egottlieb@4849
   115
 * \param shape_mode The parameters to set for the shaped window.
eligottlieb@4778
   116
 *
eligottlieb@4801
   117
 * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
eligottlieb@4801
   118
 *           if the SDL_Window* given does not reference a valid shaped window.
eligottlieb@4778
   119
 *
eligottlieb@4778
   120
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   121
 * \sa SDL_GetShapedWindowMode.
eligottlieb@4778
   122
 */
egottlieb@4849
   123
extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   124
eligottlieb@4778
   125
/**
eligottlieb@4781
   126
 * \brief Get the shape parameters of a shaped window.
eligottlieb@4778
   127
 *
eligottlieb@4778
   128
 * \param window The shaped window whose parameters should be retrieved.
egottlieb@4849
   129
 * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
eligottlieb@4778
   130
 *
egottlieb@4849
   131
 * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
eligottlieb@4801
   132
 *           data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
eligottlieb@4801
   133
 *           the SDL_Window* given is a shapeable window currently lacking a shape.
eligottlieb@4778
   134
 *
eligottlieb@4778
   135
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   136
 * \sa SDL_SetWindowShape
eligottlieb@4778
   137
 */
egottlieb@4849
   138
extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   139
eligottlieb@4769
   140
/* Ends C function definitions when using C++ */
eligottlieb@4769
   141
#ifdef __cplusplus
eligottlieb@4769
   142
/* *INDENT-OFF* */
eligottlieb@4769
   143
}
eligottlieb@4769
   144
/* *INDENT-ON* */
eligottlieb@4769
   145
#endif
eligottlieb@4769
   146
#include "close_code.h"
eligottlieb@4769
   147
eligottlieb@4769
   148
#endif /* _SDL_shape_h */