src/video/win32/SDL_win32video.h
author dewyatt
Tue, 03 Aug 2010 16:57:49 -0400
changeset 4759 863ba7d1f029
parent 4755 436183eb30c8
child 4763 518d1679d2d0
permissions -rw-r--r--
Large commit with initial reading string support, TSF UILess code, etc.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 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 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_win32video_h
    25 #define _SDL_win32video_h
    26 
    27 #include "../SDL_sysvideo.h"
    28 
    29 #define WIN32_LEAN_AND_MEAN
    30 #define STRICT
    31 #define UNICODE
    32 #undef WINVER
    33 #define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
    34 #include <windows.h>
    35 
    36 #include <msctf.h>
    37 
    38 #if SDL_VIDEO_RENDER_D3D
    39 //#include <d3d9.h>
    40 #define D3D_DEBUG_INFO
    41 #include "d3d9.h"
    42 #endif
    43 
    44 #if SDL_VIDEO_RENDER_DDRAW
    45 /* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
    46 #include <objbase.h>
    47 #include "ddraw.h"
    48 #endif
    49 
    50 #include "SDL_win32clipboard.h"
    51 #include "SDL_win32events.h"
    52 #include "SDL_win32gamma.h"
    53 #include "SDL_win32keyboard.h"
    54 #include "SDL_win32modes.h"
    55 #include "SDL_win32mouse.h"
    56 #include "SDL_win32opengl.h"
    57 #include "SDL_win32window.h"
    58 #include "SDL_events.h"
    59 
    60 #ifdef UNICODE
    61 #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
    62 #define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
    63 #else
    64 #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
    65 #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
    66 #endif
    67 extern void WIN_SetError(const char *prefix);
    68 
    69 typedef struct  
    70 {
    71     void **lpVtbl;
    72     int refcount;
    73     void *data;
    74 } TSFSink;
    75 
    76 // Definition from Win98DDK version of IMM.H
    77 typedef struct tagINPUTCONTEXT2 {
    78     HWND                hWnd;                           
    79     BOOL                fOpen;                          
    80     POINT               ptStatusWndPos;                 
    81     POINT               ptSoftKbdPos;                   
    82     DWORD               fdwConversion;                  
    83     DWORD               fdwSentence;                    
    84     union   {                                           
    85         LOGFONTA        A;                              
    86         LOGFONTW        W;                              
    87     } lfFont;                                           
    88     COMPOSITIONFORM     cfCompForm;                     
    89     CANDIDATEFORM       cfCandForm[4];                  
    90     HIMCC               hCompStr;                       
    91     HIMCC               hCandInfo;                      
    92     HIMCC               hGuideLine;                     
    93     HIMCC               hPrivate;                       
    94     DWORD               dwNumMsgBuf;                    
    95     HIMCC               hMsgBuf;                        
    96     DWORD               fdwInit;                        
    97     DWORD               dwReserve[3];                   
    98 } INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;  
    99 
   100 /* Private display data */
   101 
   102 typedef struct SDL_VideoData
   103 {
   104 #if SDL_VIDEO_RENDER_D3D
   105     HANDLE d3dDLL;
   106     IDirect3D9 *d3d;
   107 #endif
   108 #if SDL_VIDEO_RENDER_DDRAW
   109     HANDLE ddrawDLL;
   110     IDirectDraw *ddraw;
   111 #endif
   112 
   113     const SDL_scancode *key_layout;
   114     DWORD clipboard_count;
   115 
   116     SDL_bool ime_com_initialized;
   117     struct ITfThreadMgr *ime_threadmgr;
   118     SDL_bool ime_initialized;
   119     SDL_bool ime_enabled;
   120     SDL_bool ime_available;
   121     HWND ime_hwnd_main;
   122     HWND ime_hwnd_current;
   123     HIMC ime_himc;
   124 
   125     WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
   126     WCHAR ime_readingstring[16];
   127     int ime_cursor;
   128 
   129     HKL ime_hkl;
   130     HMODULE ime_himm32;
   131     UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
   132     BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
   133     LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
   134     BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
   135     LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
   136     BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
   137 
   138     SDL_bool ime_uiless;
   139     struct ITfThreadMgrEx *ime_threadmgrex;
   140     DWORD ime_uielemsinkcookie;
   141     DWORD ime_alpnsinkcookie;
   142     DWORD ime_openmodesinkcookie;
   143     DWORD ime_convmodesinkcookie;
   144     TSFSink *ime_uielemsink;
   145     TSFSink *ime_ippasink;
   146 } SDL_VideoData;
   147 
   148 #endif /* _SDL_win32video_h */
   149 
   150 /* vi: set ts=4 sw=4 expandtab: */