windows backend bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-01-31 11:03:42 +00:00
parent 7bc423f962
commit 656b31fc96
4 changed files with 105 additions and 51 deletions

View file

@ -1,3 +1,9 @@
2007-01-31 Richard Frith-Macdonald <rfm@gnu.org>
* Source\winlib\WIN32FontInfo.m: Attempt to make unicode clean
* Source\winlib\WIN32FontEnumerator.m: ditto
* Source\win32\WIN32Server.m: Implement -windowlist method.
2007-01-15 Adam Fedor <fedor@gnu.org>
* Source/x11/XGServerWindow.m ([XGServer -orderwindow:::]): Set

View file

@ -1872,8 +1872,38 @@ printf("\n\n##############################################################\n");
- (NSArray *) windowlist
{
// FIXME
return [super windowlist];
NSMutableArray *list = [NSMutableArray arrayWithCapacity: 100];
HWND w;
HWND next;
w = GetForegroundWindow(); // Try to start with frontmost window
if (w == NULL)
{
w = GetDesktopWindow(); // This should always succeed.
}
/* Step up to the frontmost window.
*/
while ((next = GetNextWindow(w, GW_HWNDPREV)) != NULL)
{
w = next;
}
/* Now walk down the window list populating the array.
*/
while (w != NULL)
{
/* Only add windows we own.
* FIXME We should improve the API to support all windows on server.
*/
if (GSWindowWithNumber((int)w) != nil)
{
[list addObject: [NSNumber numberWithInt: (int)w]];
}
w = GetNextWindow(w, GW_HWNDNEXT);
}
return list;
}
- (int) windowdepth: (int) winNum

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#include "Foundation/NSArray.h"
@ -103,9 +104,10 @@ NSString *win32_font_family(NSString *fontName)
static
void add_font(NSMutableArray *fontDefs, NSString *fontName,
ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme)
ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme)
{
NSArray *fontDef;
NSString *fontStyle;
NSFontTraitMask traits = 0;
int weight;
@ -120,22 +122,30 @@ void add_font(NSMutableArray *fontDefs, NSString *fontName,
else
traits |= NSUnitalicFontMask;
fontDef = [NSArray arrayWithObjects: fontName,
[NSString stringWithCString: lpelfe->elfStyle],
[NSNumber numberWithInt: weight],
[NSNumber numberWithUnsignedInt: traits], nil];
fontStyle = [[NSString alloc] initWithBytes: lpelfe->elfStyle
length: wcslen(lpelfe->elfStyle)
encoding: NSUnicodeStringEncoding];
fontDef = [NSArray arrayWithObjects:
fontName,
fontStyle,
[NSNumber numberWithInt: weight],
[NSNumber numberWithUnsignedInt: traits],
nil];
RELEASE(fontStyle);
[fontDefs addObject: fontDef];
}
int CALLBACK fontenum(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme,
int CALLBACK fontenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme,
DWORD FontType, LPARAM lParam)
{
NSString *fontName;
NSLog(@"Found font %s", lpelfe->elfFullName);
fontName = [NSString stringWithCString: lpelfe->elfFullName];
fontName = [[NSString alloc] initWithBytes: lpelfe->elfFullName
length: wcslen(lpelfe->elfFullName)
encoding: NSUnicodeStringEncoding];
NSLog(@"Found font %@", fontName);
add_font((NSMutableArray *)lParam, fontName, lpelfe, lpntme);
RELEASE(fontName);
return 1;
}
@ -143,22 +153,24 @@ static
void enumerate_font(NSMutableArray *fontDefs, NSString *fontFamily)
{
HDC hdc;
LOGFONT logfont;
LOGFONTW logfont;
int res;
CREATE_AUTORELEASE_POOL(pool);
NSLog(@"Enumerate font family %@", fontFamily);
hdc = GetDC(NULL);
logfont.lfCharSet = DEFAULT_CHARSET;
strncpy(logfont.lfFaceName, [fontFamily cString], LF_FACESIZE);
wcsncpy(logfont.lfFaceName,
(const unichar*)[fontFamily cStringUsingEncoding: NSUnicodeStringEncoding],
LF_FACESIZE);
logfont.lfPitchAndFamily = 0;
res = EnumFontFamiliesEx(hdc, &logfont, (FONTENUMPROC)fontenum,
res = EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)fontenum,
(LPARAM)fontDefs, 0);
ReleaseDC(NULL, hdc);
RELEASE(pool);
}
int CALLBACK fontfamilyenum(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme,
int CALLBACK fontfamilyenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme,
DWORD FontType, LPARAM lParam)
{
NSString *fontName;
@ -166,8 +178,11 @@ int CALLBACK fontfamilyenum(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme,
NSMutableArray *fontDefs;
WIN32FontEnumerator *enumer = (WIN32FontEnumerator*)lParam;
//NSLog(@"Found font family %s", lpelfe->elfFullName);
fontName = [NSString stringWithCString: lpelfe->elfFullName];
fontName = AUTORELEASE([[NSString alloc]
initWithBytes: lpelfe->elfFullName
length: wcslen(lpelfe->elfFullName)
encoding: NSUnicodeStringEncoding]);
familyName = win32_font_family(fontName);
fontDefs = [enumer->allFontFamilies objectForKey: familyName];
if (fontDefs == nil)
@ -179,25 +194,33 @@ int CALLBACK fontfamilyenum(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme,
// FIXME: Need to loop over all fonts for this family
//add_font(fontDefs, fontName, lpelfe, lpntme);
//enumerate_font(fontDefs, familyName);
fontDef = [NSArray arrayWithObjects: familyName,
@"Normal",
[NSNumber numberWithInt: 6],
[NSNumber numberWithUnsignedInt: 0], nil];
fontDef = [NSArray arrayWithObjects:
familyName,
@"Normal",
[NSNumber numberWithInt: 6],
[NSNumber numberWithUnsignedInt: 0],
nil];
[fontDefs addObject: fontDef];
fontDef = [NSArray arrayWithObjects: [familyName stringByAppendingString: @" Bold"],
@"Bold",
[NSNumber numberWithInt: 9],
[NSNumber numberWithUnsignedInt: NSBoldFontMask], nil];
fontDef = [NSArray arrayWithObjects:
[familyName stringByAppendingString: @" Bold"],
@"Bold",
[NSNumber numberWithInt: 9],
[NSNumber numberWithUnsignedInt: NSBoldFontMask],
nil];
[fontDefs addObject: fontDef];
fontDef = [NSArray arrayWithObjects: [familyName stringByAppendingString: @" Italic"],
@"Italic",
[NSNumber numberWithInt: 6],
[NSNumber numberWithUnsignedInt: NSItalicFontMask], nil];
fontDef = [NSArray arrayWithObjects:
[familyName stringByAppendingString: @" Italic"],
@"Italic",
[NSNumber numberWithInt: 6],
[NSNumber numberWithUnsignedInt: NSItalicFontMask],
nil];
[fontDefs addObject: fontDef];
fontDef = [NSArray arrayWithObjects: [familyName stringByAppendingString: @" Bold Italic"],
@"Bold Italic",
[NSNumber numberWithInt: 9],
[NSNumber numberWithUnsignedInt: NSBoldFontMask | NSItalicFontMask], nil];
fontDef = [NSArray arrayWithObjects:
[familyName stringByAppendingString: @" Bold Italic"],
@"Bold Italic",
[NSNumber numberWithInt: 9],
[NSNumber numberWithUnsignedInt: NSBoldFontMask | NSItalicFontMask],
nil];
[fontDefs addObject: fontDef];
[(NSMutableArray*)(enumer->allFontNames) addObject: fontName];

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
@ -72,7 +73,7 @@ NSString *win32_font_family(NSString *fontName);
[super dealloc];
}
- (float) widthOf: (const char*) s length: (int) len
- (float) widthOfString: (NSString*)string
{
SIZE size;
HDC hdc;
@ -80,24 +81,16 @@ NSString *win32_font_family(NSString *fontName);
hdc = GetDC(NULL);
old = SelectObject(hdc, hFont);
GetTextExtentPoint32(hdc, s, len, &size);
GetTextExtentPoint32W(hdc,
(const unichar*)[string cStringUsingEncoding: NSUnicodeStringEncoding],
[string length],
&size);
SelectObject(hdc, old);
ReleaseDC(NULL, hdc);
return size.cx;
}
- (float) widthOfString: (NSString*)string
{
const char *s;
int len;
s = [string cString];
len = strlen(s);
return [self widthOf: s length: len];
}
- (NSMultibyteGlyphPacking)glyphPacking
{
return NSOneByteGlyphPacking;
@ -213,7 +206,7 @@ NSString *win32_font_family(NSString *fontName);
HDC hdc;
TEXTMETRIC metric;
HFONT old;
LOGFONT logfont;
LOGFONTW logfont;
NSRange range;
//NSLog(@"Creating Font %@ of size %f", fontName, matrix[0]);
@ -233,8 +226,10 @@ NSString *win32_font_family(NSString *fontName);
logfont.lfItalic = 1;
logfont.lfQuality = ANTIALIASED_QUALITY;
strncpy(logfont.lfFaceName, [familyName cString], LF_FACESIZE);
hFont = CreateFontIndirect(&logfont);
wcsncpy(logfont.lfFaceName,
(const unichar*)[familyName cStringUsingEncoding: NSUnicodeStringEncoding],
LF_FACESIZE);
hFont = CreateFontIndirectW(&logfont);
if (!hFont)
{
NSLog(@"Could not create font %@", fontName);