xref: /trunk/main/sal/systools/win32/uwinapi/DrawStateW.cpp (revision 24297db34623acd4ed3cd634e301c7c8a91fabbc)
1*fc0bc008SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fc0bc008SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fc0bc008SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fc0bc008SAndrew Rist  * distributed with this work for additional information
6*fc0bc008SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fc0bc008SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fc0bc008SAndrew Rist  * "License"); you may not use this file except in compliance
9*fc0bc008SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*fc0bc008SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*fc0bc008SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fc0bc008SAndrew Rist  * software distributed under the License is distributed on an
15*fc0bc008SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fc0bc008SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fc0bc008SAndrew Rist  * specific language governing permissions and limitations
18*fc0bc008SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*fc0bc008SAndrew Rist  *************************************************************/
21*fc0bc008SAndrew Rist 
22*fc0bc008SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "macros.h"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir IMPLEMENT_THUNK( user32, WINDOWS, BOOL, WINAPI, DrawStateW,
27cdf0e10cSrcweir (
28cdf0e10cSrcweir     HDC             hdc,            // handle to device context
29cdf0e10cSrcweir     HBRUSH          hbr,            // handle to brush
30cdf0e10cSrcweir     DRAWSTATEPROC   lpOutputFunc,   // pointer to callback function
31cdf0e10cSrcweir     LPARAM          lData,          // image information
32cdf0e10cSrcweir     WPARAM          wData,          // more image information
33cdf0e10cSrcweir     int             x,              // horizontal location of image
34cdf0e10cSrcweir     int             y,              // vertical location of image
35cdf0e10cSrcweir     int             cx,             // width of image
36cdf0e10cSrcweir     int             cy,             // height of image
37cdf0e10cSrcweir     UINT            fuFlags         // image type and state
38cdf0e10cSrcweir 
39cdf0e10cSrcweir ))
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     switch ( fuFlags & 0x000F )
42cdf0e10cSrcweir     {
43cdf0e10cSrcweir     case DST_TEXT:
44cdf0e10cSrcweir     case DST_PREFIXTEXT:
45cdf0e10cSrcweir         {
46cdf0e10cSrcweir             LPSTR   lpTextA = NULL;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir             if ( lData )
49cdf0e10cSrcweir             {
50cdf0e10cSrcweir                 int cchWideChar = (int) (wData ? wData : -1);
51cdf0e10cSrcweir                 int cchNeeded = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lData, cchWideChar, NULL, 0, NULL, NULL );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir                 lpTextA = (LPSTR)_alloca( cchNeeded * sizeof(CHAR) );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir                 if ( !lpTextA )
56cdf0e10cSrcweir                 {
57cdf0e10cSrcweir                     SetLastError( ERROR_OUTOFMEMORY );
58cdf0e10cSrcweir                     return FALSE;
59cdf0e10cSrcweir                 }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir                 WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lData, cchWideChar, lpTextA, cchNeeded, NULL, NULL );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir             }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir             return DrawStateA( hdc, hbr, lpOutputFunc, (LPARAM)lpTextA, wData, x, y, cx, cy, fuFlags );
66cdf0e10cSrcweir         }
67cdf0e10cSrcweir     default:
68cdf0e10cSrcweir         return DrawStateA( hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags );
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir }
71