Code style updates.
authorDaniel Wyatt
Tue, 23 Nov 2010 20:29:45 -0500
changeset 4914cc7ac6aaac5d
parent 4913 6b89d83b0b5a
child 4915 834ce48a19c2
Code style updates.
src/video/win32/SDL_win32keyboard.c
     1.1 --- a/src/video/win32/SDL_win32keyboard.c	Tue Nov 23 17:46:47 2010 -0500
     1.2 +++ b/src/video/win32/SDL_win32keyboard.c	Tue Nov 23 20:29:45 2010 -0500
     1.3 @@ -630,8 +630,7 @@
     1.4          return;
     1.5  
     1.6      hklprev = videodata->ime_hkl;
     1.7 -    switch (PRIMLANG())
     1.8 -    {
     1.9 +    switch (PRIMLANG()) {
    1.10      case LANG_CHINESE:
    1.11          videodata->ime_candvertical = SDL_TRUE;
    1.12          if (SUBLANG() == SUBLANG_CHINESE_SIMPLIFIED)
    1.13 @@ -738,52 +737,43 @@
    1.14  {
    1.15      LPCANDIDATELIST cand_list = 0;
    1.16      DWORD size = ImmGetCandidateListW(himc, 0, 0, 0);
    1.17 -    if (size)
    1.18 -    {
    1.19 +    if (size) {
    1.20          cand_list = (LPCANDIDATELIST)SDL_malloc(size);
    1.21 -        if (cand_list)
    1.22 -        {
    1.23 +        if (cand_list) {
    1.24              size = ImmGetCandidateListW(himc, 0, cand_list, size);
    1.25 -            if (size)
    1.26 -            {
    1.27 +            if (size) {
    1.28                  int i = 0;
    1.29                  int j = 0;
    1.30                  int page_start = 0;
    1.31                  videodata->ime_candsel = cand_list->dwSelection;
    1.32                  videodata->ime_candcount = cand_list->dwCount;
    1.33  
    1.34 -                if (LANG() == LANG_CHS && IME_GetId(videodata, 0))
    1.35 -                {
    1.36 +                if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
    1.37                      const UINT maxcandchar = 18;
    1.38                      UINT i = 0;
    1.39                      UINT cchars = 0;
    1.40  
    1.41 -                    for (; i < videodata->ime_candcount; ++i)
    1.42 -                    {
    1.43 +                    for (; i < videodata->ime_candcount; ++i) {
    1.44                          UINT len = SDL_wcslen((LPWSTR)((DWORD)cand_list + cand_list->dwOffset[i])) + 1;
    1.45 -                        if (len + cchars > maxcandchar)
    1.46 -                        {
    1.47 +                        if (len + cchars > maxcandchar) {
    1.48                              if (i > cand_list->dwSelection)
    1.49                                  break;
    1.50  
    1.51                              page_start = i;
    1.52                              cchars = len;
    1.53                          }
    1.54 -                        else
    1.55 -                        {
    1.56 +                        else {
    1.57                              cchars += len;
    1.58                          }
    1.59                      }
    1.60                      videodata->ime_candpgsize = i - page_start;
    1.61                  }
    1.62 -                else
    1.63 -                {
    1.64 +                else {
    1.65                      videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
    1.66                      page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
    1.67                  }
    1.68                  SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
    1.69 -                for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++)
    1.70 -                {
    1.71 +                for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
    1.72                      LPCWSTR candidate = (LPCWSTR)((DWORD)cand_list + cand_list->dwOffset[i]);
    1.73                      IME_AddCandidate(videodata, j, candidate);
    1.74                  }
    1.75 @@ -822,8 +812,7 @@
    1.76      if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
    1.77          return SDL_FALSE;
    1.78  
    1.79 -    switch (msg)
    1.80 -    {
    1.81 +    switch (msg) {
    1.82      case WM_INPUTLANGCHANGE:
    1.83          IME_InputLangChanged(videodata);
    1.84          break;
    1.85 @@ -856,8 +845,7 @@
    1.86          SDL_SendEditingText("", 0, 0);
    1.87          break;
    1.88      case WM_IME_NOTIFY:
    1.89 -        switch (wParam)
    1.90 -        {
    1.91 +        switch (wParam) {
    1.92          case IMN_SETCONVERSIONMODE:
    1.93          case IMN_SETOPENSTATUS:
    1.94              IME_UpdateInputLocale(videodata);
    1.95 @@ -946,11 +934,9 @@
    1.96      IME_ShowCandidateList(videodata);
    1.97  
    1.98      pcandlist->lpVtbl->GetPageIndex(pcandlist, 0, 0, &pgcount);
    1.99 -    if (pgcount > 0)
   1.100 -    {
   1.101 +    if (pgcount > 0) {
   1.102          UINT *idxlist = SDL_malloc(sizeof(UINT) * pgcount);
   1.103 -        if (idxlist)
   1.104 -        {
   1.105 +        if (idxlist) {
   1.106              pcandlist->lpVtbl->GetPageIndex(pcandlist, idxlist, pgcount, &pgcount);
   1.107              pgstart = idxlist[page];
   1.108              if (page < pgcount - 1)
   1.109 @@ -965,13 +951,10 @@
   1.110      videodata->ime_candsel = videodata->ime_candsel - pgstart;
   1.111  
   1.112      SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
   1.113 -    for (i = pgstart, j = 0; (DWORD)i < count && j < videodata->ime_candpgsize; i++, j++)
   1.114 -    {
   1.115 +    for (i = pgstart, j = 0; (DWORD)i < count && j < videodata->ime_candpgsize; i++, j++) {
   1.116          BSTR bstr;
   1.117 -        if (SUCCEEDED(pcandlist->lpVtbl->GetString(pcandlist, i, &bstr)))
   1.118 -        {
   1.119 -            if (bstr)
   1.120 -            {
   1.121 +        if (SUCCEEDED(pcandlist->lpVtbl->GetString(pcandlist, i, &bstr))) {
   1.122 +            if (bstr) {
   1.123                  IME_AddCandidate(videodata, j, bstr);
   1.124                  SysFreeString(bstr);
   1.125              }
   1.126 @@ -989,8 +972,7 @@
   1.127  STDMETHODIMP_(ULONG)TSFSink_Release(TSFSink *sink)
   1.128  {
   1.129      --sink->refcount;
   1.130 -    if (sink->refcount == 0)
   1.131 -    {
   1.132 +    if (sink->refcount == 0) {
   1.133          SDL_free(sink);
   1.134          return 0;
   1.135      }
   1.136 @@ -1242,8 +1224,7 @@
   1.137      BITMAPINFO info = {0};
   1.138      BITMAPINFOHEADER *infoHeader = &info.bmiHeader;
   1.139      BYTE *bits = NULL;
   1.140 -    if (hhbm)
   1.141 -    {
   1.142 +    if (hhbm) {
   1.143          infoHeader->biSize = sizeof(BITMAPINFOHEADER);
   1.144          infoHeader->biWidth = width;
   1.145          infoHeader->biHeight = -1 * SDL_abs(height);
   1.146 @@ -1260,8 +1241,7 @@
   1.147  static void
   1.148  StopDrawToBitmap(HDC hdc, HBITMAP *hhbm)
   1.149  {
   1.150 -    if (hhbm && *hhbm)
   1.151 -    {
   1.152 +    if (hhbm && *hhbm) {
   1.153          DeleteObject(*hhbm);
   1.154          *hhbm = NULL;
   1.155      }
   1.156 @@ -1276,24 +1256,21 @@
   1.157      if (GetObject(hbm, sizeof(bm), &bm) == 0)
   1.158          return;
   1.159  
   1.160 -    if (bits && texture)
   1.161 -    {
   1.162 +    if (bits && texture) {
   1.163          /*
   1.164              For transparency:
   1.165  
   1.166              const Uint8 alpha = 130;
   1.167              unsigned long *p = (unsigned long *)bits;
   1.168              unsigned long *end = (unsigned long *)(bits + (bm.bmWidthBytes * bm.bmHeight));
   1.169 -            while (p < end)
   1.170 -            {
   1.171 +            while (p < end) {
   1.172                  *p = RGB(GetRValue(*p), GetGValue(*p), GetBValue(*p)) | (alpha << 24);
   1.173                  ++p;
   1.174              }
   1.175              surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
   1.176          */
   1.177          surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
   1.178 -        if (surface)
   1.179 -        {
   1.180 +        if (surface) {
   1.181              *texture = SDL_CreateTextureFromSurface(0, surface);
   1.182              SDL_FreeSurface(surface);
   1.183          }
   1.184 @@ -1316,8 +1293,7 @@
   1.185  static void
   1.186  DestroyTexture(SDL_Texture **texture)
   1.187  {
   1.188 -    if (texture && *texture)
   1.189 -    {
   1.190 +    if (texture && *texture) {
   1.191          SDL_DestroyTexture(*texture);
   1.192          *texture = NULL;
   1.193      }
   1.194 @@ -1348,8 +1324,7 @@
   1.195      top = videodata->ime_rect.y + videodata->ime_rect.h;
   1.196      right = left + size.cx;
   1.197      bottom = top + size.cy;
   1.198 -    if (right >= winw)
   1.199 -    {
   1.200 +    if (right >= winw) {
   1.201          left -= right - winw;
   1.202          right = winw;
   1.203      }
   1.204 @@ -1357,14 +1332,12 @@
   1.205          ok = SDL_TRUE;
   1.206  
   1.207      /* Top */
   1.208 -    if (!ok)
   1.209 -    {
   1.210 +    if (!ok) {
   1.211          left = videodata->ime_rect.x;
   1.212          top = videodata->ime_rect.y - size.cy;
   1.213          right = left + size.cx;
   1.214          bottom = videodata->ime_rect.y;
   1.215 -        if (right >= winw)
   1.216 -        {
   1.217 +        if (right >= winw) {
   1.218              left -= right - winw;
   1.219              right = winw;
   1.220          }
   1.221 @@ -1373,8 +1346,7 @@
   1.222      }
   1.223  
   1.224      /* Right */
   1.225 -    if (!ok)
   1.226 -    {
   1.227 +    if (!ok) {
   1.228          left = videodata->ime_rect.x + size.cx;
   1.229          top = 0;
   1.230          right = left + size.cx;
   1.231 @@ -1384,8 +1356,7 @@
   1.232      }
   1.233  
   1.234      /* Left */
   1.235 -    if (!ok)
   1.236 -    {
   1.237 +    if (!ok) {
   1.238          left = videodata->ime_rect.x - size.cx;
   1.239          top = 0;
   1.240          right = videodata->ime_rect.x;
   1.241 @@ -1395,8 +1366,7 @@
   1.242      }
   1.243  
   1.244      /* Window too small, show at (0,0) */
   1.245 -    if (!ok)
   1.246 -    {
   1.247 +    if (!ok) {
   1.248          left = 0;
   1.249          top = 0;
   1.250          right = size.cx;
   1.251 @@ -1446,8 +1416,7 @@
   1.252      SetBkMode(hdc, TRANSPARENT);
   1.253      SelectObject(hdc, font);
   1.254  
   1.255 -    for (i = 0; i < candcount; ++i)
   1.256 -    {
   1.257 +    for (i = 0; i < candcount; ++i) {
   1.258          const WCHAR *s = videodata->ime_candidates[i];
   1.259          if (!*s)
   1.260              break;
   1.261 @@ -1490,8 +1459,7 @@
   1.262      SetTextColor(hdc, candtextcolor);
   1.263      SetBkMode(hdc, TRANSPARENT);
   1.264  
   1.265 -    for (i = 0; i < candcount; ++i)
   1.266 -    {
   1.267 +    for (i = 0; i < candcount; ++i) {
   1.268          const WCHAR *s = videodata->ime_candidates[i];
   1.269          int left, top, right, bottom;
   1.270          if (!*s)
   1.271 @@ -1507,20 +1475,17 @@
   1.272              SDL_swap(size.cx, size.cy);
   1.273  
   1.274          bottom = top + maxcandsize.cy + (candpadding * 2) + (candborder * 2);
   1.275 -        if (!vertical)
   1.276 -        {
   1.277 +        if (!vertical) {
   1.278              SDL_swap(left, top);
   1.279              SDL_swap(right, bottom);
   1.280          }
   1.281  
   1.282 -        if (i == videodata->ime_candsel)
   1.283 -        {
   1.284 +        if (i == videodata->ime_candsel) {
   1.285              SelectObject(hdc, selpen);
   1.286              SelectObject(hdc, selbrush);
   1.287              SetTextColor(hdc, seltextcolor);
   1.288          }
   1.289 -        else
   1.290 -        {
   1.291 +        else {
   1.292              SelectObject(hdc, candpen);
   1.293              SelectObject(hdc, candbrush);
   1.294              SetTextColor(hdc, candtextcolor);