src/video/win32/SDL_win32video.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 22 Aug 2010 12:39:27 -0700
changeset 4763 518d1679d2d0
parent 4694 c24ba2cc9583
parent 4759 863ba7d1f029
child 4868 d6adaafcfb10
permissions -rw-r--r--
Merged Daniel's Google Summer of Code work from SDL-gsoc2010_IME
dewyatt@4759
     1
/*
dewyatt@4759
     2
    SDL - Simple DirectMedia Layer
dewyatt@4759
     3
    Copyright (C) 1997-2010 Sam Lantinga
dewyatt@4759
     4
dewyatt@4759
     5
    This library is free software; you can redistribute it and/or
dewyatt@4759
     6
    modify it under the terms of the GNU Lesser General Public
dewyatt@4759
     7
    License as published by the Free Software Foundation; either
dewyatt@4759
     8
    version 2.1 of the License, or (at your option) any later version.
dewyatt@4759
     9
dewyatt@4759
    10
    This library is distributed in the hope that it will be useful,
dewyatt@4759
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
dewyatt@4759
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dewyatt@4759
    13
    Lesser General Public License for more details.
dewyatt@4759
    14
dewyatt@4759
    15
    You should have received a copy of the GNU Lesser General Public
dewyatt@4759
    16
    License along with this library; if not, write to the Free Software
dewyatt@4759
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
dewyatt@4759
    18
dewyatt@4759
    19
    Sam Lantinga
dewyatt@4759
    20
    slouken@libsdl.org
dewyatt@4759
    21
*/
dewyatt@4759
    22
#include "SDL_config.h"
dewyatt@4759
    23
dewyatt@4759
    24
#ifndef _SDL_win32video_h
dewyatt@4759
    25
#define _SDL_win32video_h
dewyatt@4759
    26
dewyatt@4759
    27
#include "../SDL_sysvideo.h"
dewyatt@4759
    28
dewyatt@4759
    29
#define WIN32_LEAN_AND_MEAN
dewyatt@4759
    30
#define STRICT
slouken@4569
    31
#ifndef UNICODE
dewyatt@4759
    32
#define UNICODE
slouken@4569
    33
#endif
dewyatt@4759
    34
#undef WINVER
jimtla@4650
    35
//#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
jimtla@4650
    36
#define WINVER 0x601  /* Need 0x600 (_WIN32_WINNT_WIN7) for WM_Touch */
jimtla@4650
    37
#if (_WIN32_WINNT < 0x601)
jimtla@4650
    38
#undef _WIN32_WINNT
jimtla@4650
    39
#define _WIN32_WINNT 0x601
jimtla@4650
    40
#endif
jimtla@4650
    41
jimtla@4650
    42
dewyatt@4759
    43
#include <windows.h>
dewyatt@4759
    44
dewyatt@4759
    45
#include <msctf.h>
dewyatt@4759
    46
dewyatt@4759
    47
#if SDL_VIDEO_RENDER_D3D
dewyatt@4759
    48
//#include <d3d9.h>
dewyatt@4759
    49
#define D3D_DEBUG_INFO
dewyatt@4759
    50
#include "d3d9.h"
dewyatt@4759
    51
#endif
dewyatt@4759
    52
dewyatt@4759
    53
#if SDL_VIDEO_RENDER_DDRAW
dewyatt@4759
    54
/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
dewyatt@4759
    55
#include <objbase.h>
dewyatt@4759
    56
#include "ddraw.h"
dewyatt@4759
    57
#endif
dewyatt@4759
    58
dewyatt@4759
    59
#include "SDL_win32clipboard.h"
dewyatt@4759
    60
#include "SDL_win32events.h"
dewyatt@4759
    61
#include "SDL_win32gamma.h"
dewyatt@4759
    62
#include "SDL_win32keyboard.h"
dewyatt@4759
    63
#include "SDL_win32modes.h"
dewyatt@4759
    64
#include "SDL_win32mouse.h"
dewyatt@4759
    65
#include "SDL_win32opengl.h"
dewyatt@4759
    66
#include "SDL_win32window.h"
dewyatt@4759
    67
#include "SDL_events.h"
dewyatt@4759
    68
dewyatt@4759
    69
#ifdef UNICODE
dewyatt@4759
    70
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
dewyatt@4759
    71
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
dewyatt@4759
    72
#else
dewyatt@4759
    73
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
dewyatt@4759
    74
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
dewyatt@4759
    75
#endif
dewyatt@4759
    76
extern void WIN_SetError(const char *prefix);
dewyatt@4759
    77
slouken@4569
    78
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
slouken@4569
    79
slouken@4569
    80
typedef BOOL  (*PFNSHFullScreen)(HWND, DWORD);
slouken@4569
    81
typedef void  (*PFCoordTransform)(SDL_Window*, POINT*);
slouken@4569
    82
dewyatt@4759
    83
typedef struct  
dewyatt@4759
    84
{
dewyatt@4759
    85
    void **lpVtbl;
dewyatt@4759
    86
    int refcount;
dewyatt@4759
    87
    void *data;
dewyatt@4759
    88
} TSFSink;
dewyatt@4759
    89
dewyatt@4759
    90
// Definition from Win98DDK version of IMM.H
dewyatt@4759
    91
typedef struct tagINPUTCONTEXT2 {
dewyatt@4759
    92
    HWND                hWnd;                           
dewyatt@4759
    93
    BOOL                fOpen;                          
dewyatt@4759
    94
    POINT               ptStatusWndPos;                 
dewyatt@4759
    95
    POINT               ptSoftKbdPos;                   
dewyatt@4759
    96
    DWORD               fdwConversion;                  
dewyatt@4759
    97
    DWORD               fdwSentence;                    
dewyatt@4759
    98
    union   {                                           
dewyatt@4759
    99
        LOGFONTA        A;                              
dewyatt@4759
   100
        LOGFONTW        W;                              
dewyatt@4759
   101
    } lfFont;                                           
dewyatt@4759
   102
    COMPOSITIONFORM     cfCompForm;                     
dewyatt@4759
   103
    CANDIDATEFORM       cfCandForm[4];                  
dewyatt@4759
   104
    HIMCC               hCompStr;                       
dewyatt@4759
   105
    HIMCC               hCandInfo;                      
dewyatt@4759
   106
    HIMCC               hGuideLine;                     
dewyatt@4759
   107
    HIMCC               hPrivate;                       
dewyatt@4759
   108
    DWORD               dwNumMsgBuf;                    
dewyatt@4759
   109
    HIMCC               hMsgBuf;                        
dewyatt@4759
   110
    DWORD               fdwInit;                        
dewyatt@4759
   111
    DWORD               dwReserve[3];                   
dewyatt@4759
   112
} INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;  
dewyatt@4759
   113
dewyatt@4759
   114
/* Private display data */
dewyatt@4759
   115
dewyatt@4759
   116
typedef struct SDL_VideoData
dewyatt@4759
   117
{
slouken@4569
   118
    int render;
slouken@4569
   119
dewyatt@4759
   120
#if SDL_VIDEO_RENDER_D3D
dewyatt@4759
   121
    HANDLE d3dDLL;
dewyatt@4759
   122
    IDirect3D9 *d3d;
dewyatt@4759
   123
#endif
dewyatt@4759
   124
#if SDL_VIDEO_RENDER_DDRAW
dewyatt@4759
   125
    HANDLE ddrawDLL;
dewyatt@4759
   126
    IDirectDraw *ddraw;
dewyatt@4759
   127
#endif
slouken@4569
   128
#ifdef _WIN32_WCE
slouken@4569
   129
    HMODULE hAygShell;
slouken@4569
   130
    PFNSHFullScreen SHFullScreen;
slouken@4569
   131
    PFCoordTransform CoordTransform;
slouken@4569
   132
#endif
dewyatt@4759
   133
dewyatt@4759
   134
    const SDL_scancode *key_layout;
dewyatt@4759
   135
    DWORD clipboard_count;
dewyatt@4759
   136
dewyatt@4759
   137
    SDL_bool ime_com_initialized;
dewyatt@4759
   138
    struct ITfThreadMgr *ime_threadmgr;
dewyatt@4759
   139
    SDL_bool ime_initialized;
dewyatt@4759
   140
    SDL_bool ime_enabled;
dewyatt@4759
   141
    SDL_bool ime_available;
dewyatt@4759
   142
    HWND ime_hwnd_main;
dewyatt@4759
   143
    HWND ime_hwnd_current;
dewyatt@4759
   144
    HIMC ime_himc;
dewyatt@4759
   145
dewyatt@4759
   146
    WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
dewyatt@4759
   147
    WCHAR ime_readingstring[16];
dewyatt@4759
   148
    int ime_cursor;
dewyatt@4759
   149
dewyatt@4759
   150
    HKL ime_hkl;
dewyatt@4759
   151
    HMODULE ime_himm32;
dewyatt@4759
   152
    UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
dewyatt@4759
   153
    BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
dewyatt@4759
   154
    LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
dewyatt@4759
   155
    BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
dewyatt@4759
   156
    LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
dewyatt@4759
   157
    BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
dewyatt@4759
   158
dewyatt@4759
   159
    SDL_bool ime_uiless;
dewyatt@4759
   160
    struct ITfThreadMgrEx *ime_threadmgrex;
dewyatt@4759
   161
    DWORD ime_uielemsinkcookie;
dewyatt@4759
   162
    DWORD ime_alpnsinkcookie;
dewyatt@4759
   163
    DWORD ime_openmodesinkcookie;
dewyatt@4759
   164
    DWORD ime_convmodesinkcookie;
dewyatt@4759
   165
    TSFSink *ime_uielemsink;
dewyatt@4759
   166
    TSFSink *ime_ippasink;
dewyatt@4759
   167
} SDL_VideoData;
dewyatt@4759
   168
dewyatt@4759
   169
#endif /* _SDL_win32video_h */
dewyatt@4759
   170
dewyatt@4759
   171
/* vi: set ts=4 sw=4 expandtab: */