include/SDL_shape.h
author David Ludwig <dludwig@pobox.com>
Mon, 01 Apr 2013 21:33:06 -0400
changeset 8453 499aa167ea79
parent 6885 700f1b25f77f
child 7191 75360622e65f
permissions -rw-r--r--
WinRT: made WinRT path retrieval be available in both UCS-2 and UTF-8 flavors
eligottlieb@4766
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
eligottlieb@4766
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
eligottlieb@4766
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
eligottlieb@4766
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
eligottlieb@4766
    20
*/
eligottlieb@4766
    21
eligottlieb@4769
    22
#ifndef _SDL_shape_h
eligottlieb@4769
    23
#define _SDL_shape_h
eligottlieb@4769
    24
eligottlieb@4769
    25
#include "SDL_stdinc.h"
eligottlieb@4769
    26
#include "SDL_pixels.h"
eligottlieb@4769
    27
#include "SDL_rect.h"
eligottlieb@4769
    28
#include "SDL_surface.h"
eligottlieb@4769
    29
#include "SDL_video.h"
eligottlieb@4769
    30
eligottlieb@4769
    31
#include "begin_code.h"
eligottlieb@4769
    32
/* Set up for C function definitions, even when using C++ */
eligottlieb@4769
    33
#ifdef __cplusplus
eligottlieb@4769
    34
/* *INDENT-OFF* */
eligottlieb@4769
    35
extern "C" {
eligottlieb@4769
    36
/* *INDENT-ON* */
eligottlieb@4769
    37
#endif
eligottlieb@4766
    38
eligottlieb@4779
    39
/** \file SDL_shape.h
eligottlieb@4779
    40
 *
eligottlieb@4781
    41
 * Header file for the shaped window API.
eligottlieb@4779
    42
 */
eligottlieb@4779
    43
eligottlieb@4801
    44
#define SDL_NONSHAPEABLE_WINDOW -1
eligottlieb@4801
    45
#define SDL_INVALID_SHAPE_ARGUMENT -2
eligottlieb@4801
    46
#define SDL_WINDOW_LACKS_SHAPE -3
eligottlieb@4801
    47
eligottlieb@4766
    48
/**
eligottlieb@4781
    49
 *  \brief Create a window that can be shaped with the specified position, dimensions, and flags.
eligottlieb@4766
    50
 *  
eligottlieb@4766
    51
 *  \param title The title of the window, in UTF-8 encoding.
eligottlieb@4766
    52
 *  \param x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 
eligottlieb@4766
    53
 *               ::SDL_WINDOWPOS_UNDEFINED.
eligottlieb@4766
    54
 *  \param y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 
eligottlieb@4766
    55
 *               ::SDL_WINDOWPOS_UNDEFINED.
eligottlieb@4766
    56
 *  \param w     The width of the window.
eligottlieb@4766
    57
 *  \param h     The height of the window.
eligottlieb@4766
    58
 *  \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 
eligottlieb@4767
    59
 *               ::SDL_WINDOW_OPENGL,     ::SDL_WINDOW_INPUT_GRABBED,
eligottlieb@4766
    60
 *               ::SDL_WINDOW_SHOWN,      ::SDL_WINDOW_RESIZABLE,
eligottlieb@4766
    61
 *               ::SDL_WINDOW_MAXIMIZED,  ::SDL_WINDOW_MINIMIZED,
eligottlieb@4767
    62
 *		 ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
eligottlieb@4766
    63
 *  
eligottlieb@4801
    64
 *  \return The window created, or NULL if window creation failed.
eligottlieb@4766
    65
 *  
eligottlieb@4766
    66
 *  \sa SDL_DestroyWindow()
eligottlieb@4766
    67
 */
eligottlieb@4768
    68
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
    69
eligottlieb@4778
    70
/**
eligottlieb@4778
    71
 * \brief Return whether the given window is a shaped window. 
eligottlieb@4778
    72
 *
eligottlieb@4778
    73
 * \param window The window to query for being shaped.
eligottlieb@4778
    74
 *
eligottlieb@4781
    75
 * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
eligottlieb@4778
    76
 * \sa SDL_CreateShapedWindow
eligottlieb@4778
    77
 */
eligottlieb@4781
    78
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
eligottlieb@4778
    79
eligottlieb@4778
    80
/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
eligottlieb@4781
    81
typedef enum {
eligottlieb@4781
    82
	/** \brief The default mode, a binarized alpha cutoff of 1. */
eligottlieb@4781
    83
	ShapeModeDefault,
eligottlieb@4781
    84
	/** \brief A binarized alpha cutoff with a given integer value. */
eligottlieb@4807
    85
	ShapeModeBinarizeAlpha,
eligottlieb@4807
    86
	/** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
eligottlieb@4807
    87
	ShapeModeReverseBinarizeAlpha,
eligottlieb@4807
    88
	/** \brief A color key is applied. */
eligottlieb@4807
    89
	ShapeModeColorKey
eligottlieb@4781
    90
} WindowShapeMode;
eligottlieb@4846
    91
eligottlieb@4846
    92
#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
eligottlieb@4846
    93
eligottlieb@4778
    94
/** \brief A union containing parameters for shaped windows. */
eligottlieb@4778
    95
typedef union {
eligottlieb@4778
    96
	/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
eligottlieb@4778
    97
	Uint8 binarizationCutoff;
eligottlieb@4807
    98
	SDL_Color colorKey;
eligottlieb@4778
    99
} SDL_WindowShapeParams;
eligottlieb@4778
   100
eligottlieb@4778
   101
/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
eligottlieb@4778
   102
typedef struct SDL_WindowShapeMode {
eligottlieb@4779
   103
	/** \brief The mode of these window-shape parameters. */
eligottlieb@4778
   104
	WindowShapeMode mode;
eligottlieb@4779
   105
	/** \brief Window-shape parameters. */
eligottlieb@4778
   106
	SDL_WindowShapeParams parameters;
eligottlieb@4778
   107
} SDL_WindowShapeMode;
eligottlieb@4778
   108
eligottlieb@4778
   109
/**
eligottlieb@4780
   110
 * \brief Set the shape and parameters of a shaped window.
eligottlieb@4778
   111
 *
eligottlieb@4778
   112
 * \param window The shaped window whose parameters should be set.
eligottlieb@4781
   113
 * \param shape A surface encoding the desired shape for the window.
egottlieb@4849
   114
 * \param shape_mode The parameters to set for the shaped window.
eligottlieb@4778
   115
 *
eligottlieb@4801
   116
 * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
eligottlieb@4801
   117
 *           if the SDL_Window* given does not reference a valid shaped window.
eligottlieb@4778
   118
 *
eligottlieb@4778
   119
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   120
 * \sa SDL_GetShapedWindowMode.
eligottlieb@4778
   121
 */
egottlieb@4849
   122
extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   123
eligottlieb@4778
   124
/**
eligottlieb@4781
   125
 * \brief Get the shape parameters of a shaped window.
eligottlieb@4778
   126
 *
eligottlieb@4778
   127
 * \param window The shaped window whose parameters should be retrieved.
egottlieb@4849
   128
 * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
eligottlieb@4778
   129
 *
egottlieb@4849
   130
 * \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
   131
 *           data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
eligottlieb@4801
   132
 *           the SDL_Window* given is a shapeable window currently lacking a shape.
eligottlieb@4778
   133
 *
eligottlieb@4778
   134
 * \sa SDL_WindowShapeMode
eligottlieb@4781
   135
 * \sa SDL_SetWindowShape
eligottlieb@4778
   136
 */
egottlieb@4849
   137
extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
eligottlieb@4778
   138
eligottlieb@4769
   139
/* Ends C function definitions when using C++ */
eligottlieb@4769
   140
#ifdef __cplusplus
eligottlieb@4769
   141
/* *INDENT-OFF* */
eligottlieb@4769
   142
}
eligottlieb@4769
   143
/* *INDENT-ON* */
eligottlieb@4769
   144
#endif
eligottlieb@4769
   145
#include "close_code.h"
eligottlieb@4769
   146
eligottlieb@4769
   147
#endif /* _SDL_shape_h */