2
* The contents of this file are subject to the Mozilla Public License
3
* Version 1.1 (the "License"); you may not use this file except in
4
* compliance with the License. You may obtain a copy of the License at
5
* http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS IS"
8
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9
* License for the specific language governing rights and limitations
12
* The Original Code is the Mozilla OS/2 libraries.
14
* The Initial Developer of the Original Code is John Fairhurst,
15
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
16
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
22
#include "nsGfxDefs.h"
28
//DJ #include "nsLog.h"
29
//DJ NS_IMPL_LOG_ENABLED (GFXLog)
30
//DJ #define DPRINTF NS_LOG_PRINTF(GFXLog)
32
#define DPRINTF printf
35
#define DPRINTF printf
38
#include "nsDeviceContextSpecOS2.h"
42
BOOL GetTextExtentPoint32(HPS aPS, const char* aString, int aLength, PSIZEL aSizeL)
49
while(aLength > 0 && rc == TRUE) {
50
ULONG thislen = min(aLength, 512);
51
rc = GFX (::GpiQueryTextBox(aPS, thislen, (PCH)aString, 5, ptls), FALSE);
52
aSizeL->cx += ptls[TXTBOX_CONCAT].x;
57
aSizeL->cy = ptls[TXTBOX_TOPLEFT].y - ptls[TXTBOX_BOTTOMLEFT].y;
61
BOOL ExtTextOut(HPS aPS, int X, int Y, UINT fuOptions, const RECTL* lprc,
62
const char* aString, unsigned int aLength, const int* pSpacing)
67
GFX (::GpiMove(aPS, &ptl), FALSE);
69
// GpiCharString has a max length of 512 chars at a time...
70
while (aLength > 0 && rc == GPI_OK) {
71
ULONG ulChunkLen = min(aLength, 512);
73
rc = GFX (::GpiCharStringPos(aPS, nsnull, CHS_VECTOR, ulChunkLen,
74
(PCH)aString, (PLONG)pSpacing), GPI_ERROR);
75
pSpacing += ulChunkLen;
77
rc = GFX (::GpiCharString(aPS, ulChunkLen, (PCH)aString), GPI_ERROR);
79
aLength -= ulChunkLen;
80
aString += ulChunkLen;
90
static BOOL bIsDBCSSet = FALSE;
95
// the following lines of code determine whether the system is a DBCS country
97
COUNTRYCODE ctrycodeInfo = {0};
98
CHAR achDBCSInfo[12] = {0}; // DBCS environmental vector
99
ctrycodeInfo.country = 0; // current country
100
ctrycodeInfo.codepage = 0; // current codepage
102
rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo);
105
// NON-DBCS countries will have four bytes in the first four bytes of the
106
// DBCS environmental vector
107
if (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 ||
108
achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0)
127
// Module-level data ---------------------------------------------------------
129
void DEBUG_LogErr(long ReturnCode, const char* ErrorExpression,
130
const char* FileName, const char* FunctionName, long LineNum)
134
strcpy (TempBuf, ErrorExpression);
135
char* APIName = TempBuf;
137
char* ch = strstr (APIName , "("); // Find start of function parameter list
138
if (ch != NULL) // Opening parenthesis found - it is a function
140
while (isspace (*--ch)) {} // Remove whitespaces before opening parenthesis
143
if (APIName [0] == ':' && APIName [1] == ':') // Remove global scope operator
146
while (isspace (*APIName)) // Remove spaces before function name
151
USHORT ErrorCode = ERRORIDERROR (::WinGetLastError(0));
153
printf("GFX_Err: %s = 0x%X, 0x%X (%s - %s, line %ld)\n", APIName, ReturnCode,
154
ErrorCode, FileName, FunctionName, LineNum);
158
void PMERROR( const char *api)
160
ERRORID eid = ::WinGetLastError(0);
161
USHORT usError = ERRORIDERROR(eid);
162
DPRINTF ( "%s failed, error = 0x%X\n", api, usError);