variety of small fixes

-[NSWindow setViewsNeedDisplay:] will now schedule a displayIfNeeded to properly redisplay after a non-UI event.

NSFont LucidaGrande, LucidaGrande-Bold mapping

NSMenuItem NSValidatedUserInterfaceItem conformance

NSProgressIndicator tweaks for display update

NSThemeFrame fixes for toolbar layout

NSView autoresizesSubviews set to YES always when reading from nibs

Mouse deltas and scroll wheel fixes in Win32Display

NSPropertyListReader_vintage reads hex encoded NSData now.

assorted mundane fixes
This commit is contained in:
Christopher Lloyd 2011-01-10 11:44:35 -05:00
parent 00def2fa31
commit dda2f03a42
39 changed files with 413 additions and 134 deletions

View File

@ -526,6 +526,11 @@ id NSApp=nil;
[[event window] sendEvent:event];
}
// This method is used by NSWindow
-(void)_displayAllWindowsIfNeeded {
[[NSApp windows] makeObjectsPerformSelector:@selector(displayIfNeeded)];
}
-(NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue {
NSEvent *nextEvent=nil;
@ -538,7 +543,7 @@ id NSApp=nil;
[self _checkForReleasedWindows];
[self _checkForAppActivation];
[[NSApp windows] makeObjectsPerformSelector:@selector(displayIfNeeded)];
[self _displayAllWindowsIfNeeded];
nextEvent=[[_display nextEventMatchingMask:mask untilDate:untilDate inMode:mode dequeue:dequeue] retain];

View File

@ -229,7 +229,9 @@ static NSFont **_fontCache=NULL;
if([name isEqual:@"Symbol"])
return name;
if([name isEqual:@"LucidaGrande"])
return @"Lucida Sans Regular";
return @"Lucida Sans Unicode Regular";
if([name isEqual:@"LucidaGrande-Bold"])
return @"Lucida Sans Unicode Regular";
if([name isEqual:@"HelveticaNeue-CondensedBold"])
return @"Arial";

View File

@ -6,11 +6,12 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
#import <AppKit/NSUserInterfaceValidation.h>
@class NSMenu, NSImage;
@class NSMenu, NSImage,NSAttributedString;
@interface NSMenuItem : NSObject {
@interface NSMenuItem : NSObject <NSValidatedUserInterfaceItem> {
NSMenu *_menu;
NSAttributedString *_atitle;
id _target;

View File

@ -81,7 +81,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(void)_buildTimer {
if(_animationTimer==nil){
[self willChangeValueForKey:@"animate"];
_animationTimer = [[NSTimer scheduledTimerWithTimeInterval:_animationDelay
_animationTimer = [[NSTimer timerWithTimeInterval:_animationDelay
target:self
selector:@selector(animate:)
userInfo:nil
@ -89,7 +89,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// FIXME: does it do this? Or does it add it to the current mode?
// Apple's does work in a modal panel (right?)_
[[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:NSModalPanelRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:_animationTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop mainRunLoop] addTimer:_animationTimer forMode:NSModalPanelRunLoopMode];
[self didChangeValueForKey:@"animate"];
}
@ -290,6 +291,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return;
[self _buildTimer];
[self setNeedsDisplay:YES];
}
-(void)stopAnimation:sender {
@ -297,6 +299,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return;
[self _invalidateTimer];
[self setNeedsDisplay:YES];
}
-(void)animate:sender {

View File

@ -34,7 +34,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
float cheatSheet = 0;
[[[self window] backgroundColor] setFill];
NSRectFill([self bounds]);
NSRectFill(bounds);
switch(_borderType){
case NSNoBorder:
@ -63,7 +63,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(void)resizeSubviewsWithOldSize:(NSSize)oldSize {
NSView *menuView=nil;
NSView *toolbarView=nil;
NSToolbarView *toolbarView=nil;
NSView *contentView=nil;
// tile the subviews, when/if we add titlebars and such do it here
@ -71,16 +71,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if([view isKindOfClass:[NSMenuView class]])
menuView=view;
else if([view isKindOfClass:[NSToolbarView class]])
toolbarView=view;
toolbarView=(NSToolbarView *)view;
else
contentView=view;
}
[menuView resizeWithOldSuperviewSize:oldSize];
[toolbarView resizeWithOldSuperviewSize:oldSize];
// subtracts menu height but not toolbar height
NSRect contentFrame=[[[self window] class] contentRectForFrameRect:[self bounds] styleMask:[[self window] styleMask]];
NSRect contentFrame=[[self window] contentRectForFrameRect:[self bounds]];
NSRect menuFrame=(menuView!=nil)?[menuView frame]:NSZeroRect;
NSRect toolbarFrame=(toolbarView!=nil)?[toolbarView frame]:NSZeroRect;
menuFrame.origin.y=NSMaxY(contentFrame);
menuFrame.origin.x=contentFrame.origin.x;
menuFrame.size.width=contentFrame.size.width;
[menuView setFrame:menuFrame];
toolbarFrame.origin.y=NSMaxY(contentFrame)-toolbarFrame.size.height;
toolbarFrame.origin.x=contentFrame.origin.x;
toolbarFrame.size.width=contentFrame.size.width;
[toolbarView setFrame:toolbarFrame];
[toolbarView layoutViews];
contentFrame.size.height-=toolbarFrame.size.height;
[contentView setFrame:contentFrame];
}

View File

@ -83,7 +83,9 @@ NSString * const NSViewFocusDidChangeNotification=@"NSViewFocusDidChangeNotifica
_autoresizingMask=vFlags&0x3F;
if([keyed containsValueForKey:@"NSvFlags"])
_autoresizesSubviews=(vFlags&0x100)?YES:NO;
else
// Despite the fact it appears _autoresizesSubviews is encoded in the flags, it should always be ON
// *** Do not turn off or base on the flags unless you have an alternative for enabling it when it
// should be.
_autoresizesSubviews=YES;
_isHidden=(vFlags&0x80000000)?YES:NO;
_tag=-1;

View File

@ -1582,6 +1582,11 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
-(void)setViewsNeedDisplay:(BOOL)flag {
_viewsNeedDisplay=flag;
if(flag){
// NSApplication does a _displayAllWindowsIfNeeded before every event, but there are some things which wont generate
// an event such as performOnMainThread, so we do the callout here too. There is probably a better way to do this
[[NSRunLoop currentRunLoop] performSelector:@selector(_displayAllWindowsIfNeeded) target:NSApp argument:nil order:0 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
}
}
-(void)disableFlushWindow {

View File

@ -145,7 +145,7 @@ static DWORD WINAPI runWaitCursor(LPVOID arg){
_cursorDisplayCount=1;
_cursorCache=[NSMutableDictionary new];
_pastLocation = NSMakePoint(FLT_MAX, FLT_MAX);
_pastLocation = [self mouseLocation];
[self loadPrivateFonts];
}
@ -955,17 +955,16 @@ The values should be upgraded to something which is more generic to implement, p
-(BOOL)postMouseMSG:(MSG)msg type:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned)modifierFlags window:(NSWindow *)window {
NSEvent *event;
/* Use mouseLocation to compute deltas, message coordinates are window based, and if the window is moving
with the mouse, things get messy
*/
NSPoint currentLocation=[self mouseLocation];
CGFloat deltaX=currentLocation.x-_pastLocation.x;
CGFloat deltaY=-(currentLocation.y-_pastLocation.y);
if (((type == NSLeftMouseDragged) || (type == NSRightMouseDragged)) && (_pastLocation.x != FLT_MAX))
event = [NSEvent mouseEventWithType:type location:location modifierFlags:modifierFlags window:window clickCount:_clickCount deltaX:location.x - _pastLocation.x deltaY:-(location.y - _pastLocation.y)];
else
event = [NSEvent mouseEventWithType:type location:location modifierFlags:modifierFlags window:window clickCount:_clickCount deltaX:0.0 deltaY:0.0];
event = [NSEvent mouseEventWithType:type location:location modifierFlags:modifierFlags window:window clickCount:_clickCount deltaX:deltaX deltaY:deltaY];
if ((type == NSLeftMouseDragged) || (type == NSRightMouseDragged))
_pastLocation = location;
if ((type == NSLeftMouseUp) || (type == NSRightMouseUp))
_pastLocation = NSMakePoint(FLT_MAX, FLT_MAX);
_pastLocation = currentLocation;
[self postEvent:event atStart:NO];
@ -974,9 +973,9 @@ The values should be upgraded to something which is more generic to implement, p
-(BOOL)postScrollWheelMSG:(MSG)msg type:(NSEventType)type location:(NSPoint)location modifierFlags:(unsigned)modifierFlags window:(NSWindow *)window {
NSEvent *event;
float deltaY=((short)HIWORD(msg.wParam));
float deltaY=((float)GET_WHEEL_DELTA_WPARAM(msg.wParam));
deltaY/=WHEEL_DELTA;
// deltaY/=WHEEL_DELTA;
event=[NSEvent mouseEventWithType:type location:location modifierFlags:modifierFlags window:window deltaY:deltaY];
[self postEvent:event atStart:NO];
@ -1033,9 +1032,29 @@ The values should be upgraded to something which is more generic to implement, p
return result;
}
static HWND findWindowForScrollWheel(POINT point){
HWND check=GetTopWindow(NULL);
while(check!=NULL){
RECT checkRect={0};
GetWindowRect(check,&checkRect);
if(PtInRect(&checkRect,point)){
if((id)GetProp(check,"self")!=nil)
return check;
}
check=GetNextWindow(check,GW_HWNDNEXT);
}
return check;
}
-(BOOL)postMSG:(MSG)msg {
NSEventType type;
id platformWindow=(id)GetProp(msg.hwnd,"self");
HWND windowHandle=msg.hwnd;
id platformWindow;
NSWindow *window=nil;
POINT deviceLocation;
NSPoint location;
@ -1043,6 +1062,60 @@ The values should be upgraded to something which is more generic to implement, p
DWORD tickCount=GetTickCount();
int lastClickCount=_clickCount;
deviceLocation.x=GET_X_LPARAM(msg.lParam);
deviceLocation.y=GET_Y_LPARAM(msg.lParam);
if(msg.message==WM_MOUSEWHEEL) {
// Scroll wheel events go to the window under the mouse regardless of key. Win32 set hwnd to the active window
// So we look for the window under the mouse and use that for the event.
POINT pt={GET_X_LPARAM(msg.lParam),GET_Y_LPARAM(msg.lParam)};
RECT r;
GetWindowRect(windowHandle,&r);
pt.x+=r.left;
pt.y+=r.top;
HWND scrollWheelWindow=findWindowForScrollWheel(pt);
if(scrollWheelWindow!=NULL)
windowHandle=scrollWheelWindow;
platformWindow=(id)GetProp(windowHandle,"self");
}
#if 0
else if(msg.message==WM_MOUSEMOVE){
if((msg.wParam&MK_LBUTTON) || (msg.wParam&MK_RBUTTON)){
// mouse down, normal behavior
platformWindow=(id)GetProp(windowHandle,"self");
}
else {
/* Mouse moved only goes to the key window, on Windows mouse moved is sent to the mouse under the cursor
or the window for SetCapture()d. So we send it to the active window
Caveat: If SetCapture()d, you only receive mouse moved if a mouse button is down.
*/
HWND activeWindow=GetActiveWindow();
RECT r;
// convert to screen
GetWindowRect(windowHandle,&r);
deviceLocation.x+=r.left;
deviceLocation.y+=r.top;
// convert to active window
GetWindowRect(activeWindow,&r);
deviceLocation.x-=r.left;
deviceLocation.y-=r.top;
platformWindow=(id)GetProp(activeWindow,"self");
// NSLog(@"mapped mouse move to %@ %d %d",[platformWindow appkitWindow],deviceLocation.x,deviceLocation.y);
}
}
#endif
else {
platformWindow=(id)GetProp(windowHandle,"self");
}
if([platformWindow respondsToSelector:@selector(appkitWindow)])
window=[platformWindow performSelector:@selector(appkitWindow)];
@ -1089,11 +1162,14 @@ The values should be upgraded to something which is more generic to implement, p
else if(msg.wParam&MK_RBUTTON)
type=NSRightMouseDragged;
else {
if(window!=nil && [window acceptsMouseMovedEvents])
ReleaseCapture();
if(window!=nil && [window acceptsMouseMovedEvents]){
type=NSMouseMoved;
else
}
else {
return YES;
}
}
break;
case WM_LBUTTONDOWN:
@ -1141,12 +1217,11 @@ The values should be upgraded to something which is more generic to implement, p
return NO;
}
deviceLocation.x=GET_X_LPARAM(msg.lParam);
deviceLocation.y=GET_Y_LPARAM(msg.lParam);
location.x=deviceLocation.x;
location.y=deviceLocation.y;
if(msg.hwnd!=[platformWindow windowHandle]){
// This is used for OpenGL child windows which will interfere will scrollwheel coordinates
if(windowHandle!=[platformWindow windowHandle]){
RECT child={0},parent={0};
// There is no way to get a child's frame inside the parent, you have to get

View File

@ -6,5 +6,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <ApplicationServices/ApplicationServices.h>
#import <CoreData/CoreData.h>

View File

@ -73,6 +73,8 @@ typedef enum {
-(void)addOverlay:(CGLPixelSurface *)overlay;
-(void)removeOverlay:(CGLPixelSurface *)overlay;
-(void)flushOverlay:(CGLPixelSurface *)overlay;
@end
@interface NSObject(CGWindow_delegate)

View File

@ -21,13 +21,13 @@
[super dealloc];
}
-(void)timer:(NSTimer *)timer {
-(void)displayLinkTimer:(NSTimer *)timer {
if(_callback!=NULL)
_callback(self,NULL,NULL,0,NULL,_userInfo);
}
-(void)start {
_timer=[[NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(timer:) userInfo:nil repeats:YES] retain];
_timer=[[NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(displayLinkTimer:) userInfo:nil repeats:YES] retain];
}
CVReturn CVDisplayLinkCreateWithActiveCGDisplays(CVDisplayLinkRef *result) {

View File

@ -298,7 +298,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-(NSUInteger)indexOfObject:object {
return [self indexOfObject:object inRange:NSMakeRange(0,[self count])];
NSInteger i,count=[self count];
for(i=0;i<count;i++)
if([[self objectAtIndex:i] isEqual:object])
return i;
return NSNotFound;
}

View File

@ -237,7 +237,7 @@ void *, const void *))
{
NSInteger h, i, j, k, l, m, n = nel;
void* A; // points to an element
void* B = malloc((n/2 + 1) * width); // points to a temp array
void* B = NSZoneMalloc(NULL,(n/2 + 1) * width); // points to a temp array
for (h = 1; h < n; h += h) {
@ -398,7 +398,7 @@ static int selectorCompare(id object1,id object2,void *userData){
-(void)sortUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context
{
NSInteger h, i, j, k, l, m, n = [self count];
id A, *B = malloc((n/2 + 1) * sizeof(id));
id A, *B = NSZoneMalloc(NULL,(n/2 + 1) * sizeof(id));
// to prevent retain counts from temporarily hitting zero.
for(i=0;i<n;i++)

View File

@ -286,7 +286,7 @@ static inline NSUInteger indexOfObject(NSMutableArray_concrete *self,id object){
// iterative mergesort based on http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm
-(void)sortUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context {
NSInteger h, i, j, k, l, m, n = _count;
id A, *B = malloc((n/2 + 1) * sizeof(id));
id A, *B = NSZoneMalloc(NULL,(n/2 + 1) * sizeof(id));
for (h = 1; h < n; h += h)
{

View File

@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
BOOL NSZombieEnabled=NO;
BOOL NSDebugEnabled=YES;
BOOL NSCooperativeThreadsEnabled=YES;
BOOL NSCooperativeThreadsEnabled=NO;
const char* _NSPrintForDebugger(id object) {
if(object && [object respondsToSelector:@selector(description)]) {

View File

@ -201,10 +201,14 @@ static inline void setValueForKey(NSMutableDictionary_CF *self,const void *value
}
static inline void setObjectForKey(NSMutableDictionary_CF *self,id object,id key){
if (key==nil)
if (key==nil){
NSRaiseException(NSInvalidArgumentException,self,@selector(setObject:forKey:),@"Attempt to insert object with nil key");
else if(object==nil)
return;
}
else if(object==nil){
NSRaiseException(NSInvalidArgumentException,self,@selector(setObject:forKey:),@"Attempt to insert nil object for key %@", key);
return;
}
setValueForKey(self,object,key);
}

View File

@ -31,7 +31,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
int i;
_length = length;
_indexes = malloc(length*sizeof(NSUInteger));
_indexes = NSZoneMalloc(NULL,length*sizeof(NSUInteger));
for(i=0;i<length;i++)
_indexes[i]=indexes[i];

View File

@ -7,6 +7,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import "NSString+KVCAdditions.h"
#import <ctype.h>
@implementation NSString (KVCPrivateAdditions)

View File

@ -244,7 +244,7 @@ static id _readObjectAtOffset(NSPropertyListReader_binary1 *self,NSUInteger *off
if( topNibble == 0xA )
{
id result;
id *objs = malloc( length * sizeof( *objs ) );
id *objs = NSZoneMalloc(NULL, length * sizeof( *objs ) );
uint64_t i;
for( i = 0; i < length; i++ )
objs[i] = _readInlineObjectAtOffset(self,offset);
@ -259,8 +259,8 @@ static id _readObjectAtOffset(NSPropertyListReader_binary1 *self,NSUInteger *off
if( topNibble == 0xD )
{
id result;
id *keys = malloc( length * sizeof( *keys ) );
id *objs = malloc( length * sizeof( *objs ) );
id *keys = NSZoneMalloc(NULL, length * sizeof( *keys ) );
id *objs = NSZoneMalloc(NULL, length * sizeof( *objs ) );
uint64_t i;
for( i = 0; i < length; i++ )
keys[i] = _readInlineObjectAtOffset(self,offset);

View File

@ -24,6 +24,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
NSUInteger _bufferSize;
unichar *_buffer;
NSUInteger _dataBufferCapacity;
NSUInteger _dataBufferSize;
uint8_t *_dataBuffer;
NSUInteger _index;
NSUInteger _lineNumber;

View File

@ -30,6 +30,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_bufferSize=0;
_buffer=NSZoneMalloc(NULL,sizeof(unichar *)*_bufferCapacity);
_dataBufferCapacity=256;
_dataBufferSize=0;
_dataBuffer=NSZoneMalloc(NULL,sizeof(uint8_t *)*_dataBufferCapacity);
_index=0;
_lineNumber=1;
@ -46,6 +50,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
NSZoneFree(NULL,_stack);
if(_buffer!=NULL)
NSZoneFree(NULL,_buffer);
if(_dataBuffer!=NULL)
NSZoneFree(NULL,_dataBuffer);
[super dealloc];
}
@ -117,6 +123,14 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,uint8_t c)
self->_buffer[self->_bufferSize++]=c;
}
static inline void appendByte(NSPropertyListReader_vintage *self,uint8_t c){
if(self->_dataBufferSize>=self->_dataBufferCapacity){
self->_dataBufferCapacity*=2;
self->_dataBuffer=NSZoneRealloc(NULL,self->_dataBuffer,self->_dataBufferCapacity*sizeof(unichar));
}
self->_dataBuffer[self->_dataBufferSize++]=c;
}
-(NSObject *)propertyListWithInfo:(NSString *)info {
enum {
STATE_WHITESPACE,
@ -132,7 +146,9 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,uint8_t c)
STATE_STRING_SLASH_U0000,
STATE_STRING_SLASH_UX000,
STATE_STRING_SLASH_UXX00,
STATE_STRING_SLASH_UXXX0
STATE_STRING_SLASH_UXXX0,
STATE_DATA_HINIBBLE,
STATE_DATA_LONIBBLE,
} state=STATE_WHITESPACE;
enum {
EXPECT_KEY,
@ -168,6 +184,13 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,uint8_t c)
_bufferSize=0;
state=STATE_STRING;
}
else if(code=='<'){
if(expect!=EXPECT_KEY && expect!=EXPECT_VAL)
return [self parseError:expect:code info:info];
_dataBufferSize=0;
state=STATE_DATA_HINIBBLE;
}
else if(code=='{'){
if(expect!=EXPECT_VAL)
return [self parseError:expect:code info:info];
@ -414,6 +437,61 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,uint8_t c)
}
break;
case STATE_DATA_HINIBBLE:
case STATE_DATA_LONIBBLE:
if(code=='>'){
NSData *data=[NSData dataWithBytes:_dataBuffer length:_dataBufferSize];
pushObject(self,[data retain]);
state=STATE_WHITESPACE;
if(_stackSize==1)
expect=EXPECT_EOF;
else if(expect==EXPECT_KEY)
expect=EXPECT_EQUAL;
else
expect=EXPECT_SEPARATOR;
}
else if(code<=' ')
break;
else if(code>='0' && code<='9'){
uint8_t nibble=code-'0';
if(state==STATE_DATA_HINIBBLE){
appendByte(self,nibble<<4);
state=STATE_DATA_LONIBBLE;
}
else {
_dataBuffer[_dataBufferSize-1]|=nibble;
state=STATE_DATA_HINIBBLE;
}
}
else if(code>='A' && code<='F'){
uint8_t nibble=(code-'A')+10;
if(state==STATE_DATA_HINIBBLE){
appendByte(self,nibble<<4);
state=STATE_DATA_LONIBBLE;
}
else {
_dataBuffer[_dataBufferSize-1]|=nibble;
state=STATE_DATA_HINIBBLE;
}
}
else if(code>='a' && code<='f'){
uint8_t nibble=(code-'a')+10;
if(state==STATE_DATA_HINIBBLE){
appendByte(self,nibble<<4);
state=STATE_DATA_LONIBBLE;
}
else {
_dataBuffer[_dataBufferSize-1]|=nibble;
state=STATE_DATA_HINIBBLE;
}
}
break;
}
}

View File

@ -200,11 +200,16 @@ NSString * const NSRunLoopCommonModes=@"kCFRunLoopCommonModes";
NSRunLoopState *state=[self stateForMode:mode];
if([[NSNotificationQueue defaultQueue] hasIdleNotificationsInMode:mode]){
if(![state pollInputForMode:mode])
if([state pollInputForMode:mode]){
[pool release];
return YES;
}
else {
[[NSNotificationQueue defaultQueue] idleProcessMode:mode];
}
}
else {
[state waitForSingleInputForMode:mode beforeDate:limitDate];
[pool release];

View File

@ -177,10 +177,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-(BOOL)pollInputForMode:(NSString *)mode {
if([self fireSingleImmediateInputInMode:mode])
return YES;
return [_inputSourceSet waitForInputInMode:mode beforeDate:[NSDate date]];
return [self waitForSingleInputForMode:mode beforeDate:[NSDate date]];
}
-(id)description {

View File

@ -1164,12 +1164,12 @@ U+2029 (Unicode paragraph separator), \r\n, in that order (also known as CRLF)
NSUInteger selfLength=[self length];
NSUInteger otherLength=[other length];
NSUInteger totalLength=selfLength+otherLength;
unichar unicode[totalLength];
unichar *unicode=NSZoneMalloc(NULL,sizeof(unichar)*totalLength);
[self getCharacters:unicode];
[other getCharacters:unicode+selfLength];
return [NSString stringWithCharacters:unicode length:totalLength];
return [[[NSString alloc] initWithCharactersNoCopy:unicode length:totalLength freeWhenDone:YES] autorelease];
}
-(NSArray *)componentsSeparatedByString:(NSString *)pattern {

View File

@ -25,7 +25,7 @@ NSString *NSString_unicodePtrNewNoCopy(NSZone *zone,const unichar *unicode,NSUIn
}
NSString *NSString_unicodePtrNew(NSZone *zone,const unichar *unicode,NSUInteger length) {
unichar *copy=malloc(length*sizeof(unichar));
unichar *copy=NSZoneMalloc(NULL,length*sizeof(unichar));
int i;
for(i=0;i<length;i++)

View File

@ -75,6 +75,7 @@ static void *nsThreadStartThread(void* t)
NSThread *thread = t;
NSPlatformSetCurrentThread(thread);
[thread setExecuting:YES];
NSCooperativeThreadWaiting();
[thread main];
[thread setExecuting:NO];
[thread setFinished:YES];
@ -111,11 +112,15 @@ static void *nsThreadStartThread(void* t)
+(void)sleepUntilDate:(NSDate *)date {
NSTimeInterval interval=[date timeIntervalSinceNow];
NSCooperativeThreadBlocking();
NSPlatformSleepThreadForTimeInterval(interval);
NSCooperativeThreadWaiting();
}
+(void)sleepForTimeInterval:(NSTimeInterval)value {
NSCooperativeThreadBlocking();
NSPlatformSleepThreadForTimeInterval(value);
NSCooperativeThreadWaiting();
}
+(void)exit {

View File

@ -27,11 +27,13 @@ static NSString *valueInHeaders(NSDictionary *headers,NSString *key){
}
static NSString *mimeTypeFromContentType(NSString *contentType){
return nil;
// FIXME
return contentType;
}
static NSString *textEncodingNameFromContentType(NSString *contentType){
return nil;
// FIXME
return contentType;
}
-initWithURL:(NSURL *)url statusCode:(NSInteger)statusCode headers:(NSDictionary *)headers {

View File

@ -434,8 +434,10 @@ NSLog(@"parse error %d",__LINE__);
[string appendString:@"\015\012"];
if(NSDebugEnabled){
#if 0
NSLog(@"HTTP request=%@",string);
NSLog(@"body=%@",[[[NSString alloc] initWithData:[_request HTTPBody] encoding:NSUTF8StringEncoding] autorelease]);
#endif
}
NSData *data=[string dataUsingEncoding:NSUTF8StringEncoding];

View File

@ -54,7 +54,9 @@ NSString * const NSUserDefaultsDidChangeNotification=@"NSUserDefaultsDidChangeNo
key=[key substringFromIndex:1];
NS_DURING
pval=[val propertyList];
if((pval=[val propertyList])==nil)
pval=val;
NS_HANDLER
pval=val;
NS_ENDHANDLER

View File

@ -28,14 +28,14 @@
[super dealloc];
}
-(BOOL)processImmediateEvents:(NSUInteger)selectEvent {
-(NSUInteger)processImmediateEvents:(NSUInteger)selectEvent {
if(selectEvent & NSSelectReadEvent) {
uint8_t buf[256];
[_cancelRead read:buf maxLength:256];
_hasCanceled=NO;
return YES;
return NSSelectReadEvent;
}
return NO;
return 0;
}
-(void)cancel {

View File

@ -438,28 +438,35 @@ void *NSPlatformContentsOfFile(NSString *path,NSUInteger *lengthp) {
-(BOOL)writeContentsOfFile:(NSString *)path bytes:(const void *)bytes length:(NSUInteger)length atomically:(BOOL)atomically {
HANDLE file;
DWORD wrote;
const uint16_t *pathW=[path fileSystemRepresentationW];
atomically=NO;
if(atomically){
NSString *backup=[path stringByAppendingString:@"##"];
const uint16_t *backupW=[backup fileSystemRepresentationW];
file=CreateFileW([backup fileSystemRepresentationW],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(!WriteFile(file,bytes,length,&wrote,NULL))
file=CreateFileW(backupW,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(!WriteFile(file,bytes,length,&wrote,NULL)){
CloseHandle(file);
}
else {
CloseHandle(file);
if(wrote!=length)
DeleteFileW([backup fileSystemRepresentationW]);
if(wrote!=length){
DeleteFileW(backupW);
}
else {
if(MoveFileExW([backup fileSystemRepresentationW],[path fileSystemRepresentationW],MOVEFILE_REPLACE_EXISTING))
if(MoveFileExW(backupW,pathW,MOVEFILE_REPLACE_EXISTING)){
return YES;
}
}
}
// atomic failure drops through to non-atomic
}
file=CreateFileW([path fileSystemRepresentationW],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
file=CreateFileW(pathW,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(!WriteFile(file,bytes,length,&wrote,NULL)){
CloseHandle(file);
return NO;

View File

@ -8,7 +8,7 @@
#import <Foundation/NSLock.h>
#import <windows.h>
@interface NSRecursiveLock_win32 : NSRecursiveLock <NSLocking> {
@interface NSRecursiveLock_win32 : NSObject <NSLocking> {
CRITICAL_SECTION _lock;
NSString *_name;
}

View File

View File

View File

@ -11,6 +11,21 @@ IMAGEKIT_EXPORT NSString * const IKImageBrowserGroupStyleKey;
IMAGEKIT_EXPORT NSString * const IKImageBrowserBackgroundColorKey;
IMAGEKIT_EXPORT NSString * const IKImageBrowserPathRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserNSURLRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserNSImageRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserCGImageRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserCGImageSourceRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserNSDataRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserNSBitmapImageRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserQTMovieRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserQTMoviePathRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserQCCompositionRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserQCCompositionPathRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserQuickLookPathRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserIconRefPathRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserIconRefRepresentationType;
IMAGEKIT_EXPORT NSString * const IKImageBrowserPDFPageRepresentationType;
enum {
IKGroupBezelStyle,
@ -22,7 +37,7 @@ enum {
IKCellsStyleShadowed =1,
IKCellsStyleOutlined =2,
IKCellsStyleTitled =4,
IKCellsStyleSubtitled =8
IKCellsStyleSubtitled =8,
};
typedef enum {
@ -45,7 +60,6 @@ typedef enum {
BOOL _allowsReordering;
BOOL _animates;
BOOL _canControlQuickLookPanel;
}
-initWithFrame:(NSRect)frame;
@ -57,40 +71,59 @@ typedef enum {
-(BOOL)allowsDroppingOnItems;
-(BOOL)allowsEmptySelection;
-(BOOL)allowsMultipleSelection;
-(BOOL)allowsReordering;
-(BOOL)animates;
-(CALayer *)backgroundLayer;
-(BOOL)canControlQuickLookPanel;
-(IKImageBrowserCell *)cellForItemAtIndex:(NSUInteger)index;
-(BOOL)constrainsToOriginalSize;
-(NSSize)cellSize;
-(NSUInteger)cellsStyleMask;
-(CALayer *)backgroundLayer;
-(CALayer *)foregroundLayer;
-(void)setAllowsDroppingOnItems:(BOOL)value;
-(void)setAllowsEmptySelection:(BOOL)value;
-(void)setAllowsMultipleSelection:(BOOL)value;
-(void)setAllowsReordering:(BOOL)value;
-(void)setAnimates:(BOOL)value;
-(void)setCanControlQuickLookPanel:(BOOL)value;
-(void)setCellSize:(NSSize)value;
-(void)setCellsStyleMask:(NSUInteger)value;
-(void)setConstrainsToOriginalSize:(BOOL)value;
-(void)setContentResizingMask:(NSUInteger)value;
-(void)setBackgroundLayer:(CALayer *)aLayer;
-(void)setDataSource:source;
-(void)setDelegate:delegate;
-(void)setDraggingDestinationDelegate:delegate;
-(void)setForegroundLayer:(CALayer *)layer;
-(void)setIntercellSpacing:(NSSize)value;
-(IKImageBrowserCell *)cellForItemAtIndex:(NSUInteger)index;
-(void)collapseGroupAtIndex:(NSUInteger)index;
-(NSIndexSet *)columnIndexesInRect:(NSRect)rect;
-(BOOL)constrainsToOriginalSize;
-(NSUInteger)contentResizingMask;
-draggingDestinationDelegate;
-(IKImageBrowserDropOperation)dropOperation;
-(void)expandGroupAtIndex:(NSUInteger)index;
-(CALayer *)foregroundLayer;
-(NSUInteger)indexAtLocationOfDroppedItem;
@ -99,57 +132,26 @@ typedef enum {
-(NSRect)itemFrameAtIndex:(NSInteger)index;
-(IKImageBrowserCell *)newCellForRepresentedItem:(id)anItem;
-(NSUInteger)numberOfColumns;
-(IKImageBrowserCell *)newCellForRepresentedItem:item;
-(NSUInteger)numberOfRows;
-(NSUInteger)numberOfColumns;
-(NSRect)rectOfColumn:(NSUInteger)columnIndex;
-(NSRect)rectOfColumn:(NSUInteger)column;
-(NSRect)rectOfRow:(NSUInteger)rowIndex;
-(void)reloadData;
-(NSIndexSet *)rowIndexesInRect:(NSRect)rect;
-(void)scrollIndexToVisible:(NSInteger)index;
-(NSIndexSet *)selectionIndexes;
-(void)setAllowsDroppingOnItems:(BOOL)flag;
-(void)setAllowsEmptySelection:(BOOL)flag;
-(void)setSelectionIndexes:(NSIndexSet *)value byExtendingSelection:(BOOL)extendSelection;
-(void)setAllowsMultipleSelection:(BOOL)flag;
-(void)setAllowsReordering:(BOOL)flag;
-(void)setAnimates:(BOOL)flag;
-(void)setBackgroundLayer:(CALayer *)aLayer;
-(void)setCanControlQuickLookPanel:(BOOL)flag;
-(void)setCellSize:(NSSize)size;
-(void)setCellsStyleMask:(NSUInteger)mask;
-(void)setConstrainsToOriginalSize:(BOOL)flag;
-(void)setContentResizingMask:(NSUInteger)mask;
-(void)setDataSource:source;
-(void)setDelegate:delegate;
-(void)setDraggingDestinationDelegate:(id)delegate;
-(void)setForegroundLayer:(CALayer *)aLayer;
-(void)setIntercellSpacing:(NSSize)value;
-(void)setSelectionIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extendSelection;
-(void)scrollIndexToVisible:(NSInteger)index;
-(NSIndexSet *)visibleItemIndexes;
@ -157,3 +159,48 @@ typedef enum {
-(void)setZoomValue:(float)value;
@end
@interface NSObject(IKImageBrowserItem)
- (id) imageRepresentation;
- (NSString *) imageRepresentationType;
- (NSString *) imageSubtitle;
- (NSString *) imageTitle;
- (NSString *) imageUID;
- (NSUInteger) imageVersion;
- (BOOL) isSelectable;
@end
@interface NSObject(IKImageBrowserDelegate)
-(void)imageBrowserSelectionDidChange:(IKImageBrowserView *)browser;
-(void)imageBrowser:(IKImageBrowserView *)browser backgroundWasRightClickedWithEvent:(NSEvent *)event;
-(void)imageBrowser:(IKImageBrowserView *)browser cellWasRightClickedAtIndex:(NSUInteger)index withEvent:(NSEvent *)event;
-(void)imageBrowser:(IKImageBrowserView *)browser cellWasDoubleClickedAtIndex:(NSUInteger)index;
@end
@interface NSObject(IKImageBrowserDataSource)
-(NSDictionary *)imageBrowser:(IKImageBrowserView *)browser groupAtIndex:(NSUInteger)index;
-imageBrowser:(IKImageBrowserView *)browser itemAtIndex:(NSUInteger)index;
-(BOOL)imageBrowser:(IKImageBrowserView *)browser moveItemsAtIndexes: (NSIndexSet *)indexes toIndex:(NSUInteger)destinationIndex;
-(void)imageBrowser:(IKImageBrowserView *)browser removeItemsAtIndexes:(NSIndexSet *)indexes;
-(NSUInteger)imageBrowser:(IKImageBrowserView *)browser writeItemsAtIndexes:(NSIndexSet *)itemIndexes toPasteboard:(NSPasteboard *)pasteboard;
-(NSUInteger)numberOfGroupsInImageBrowser:(IKImageBrowserView *)browser;
-(NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *)browser;
@end

View File

@ -7,7 +7,7 @@ NSString * const IKImageBrowserGroupRangeKey=@"IKImageBrowserGroupRangeKey";
NSString * const IKImageBrowserGroupTitleKey=@"IKImageBrowserGroupTitleKey";
NSString * const IKImageBrowserGroupStyleKey=@"IKImageBrowserGroupStyleKey";
NSString * const IKImageBrowserBackgroundColorKey=@"IKImageBrowserBackgroundColorKey";
NSString * const IKImageBrowserBackgroundColorKey=@"backgroundColor";
@implementation IKImageBrowserView
@ -109,7 +109,7 @@ NSString * const IKImageBrowserBackgroundColorKey=@"IKImageBrowserBackgroundColo
}
-(id)draggingDestinationDelegate {
-draggingDestinationDelegate {
NSUnimplementedMethod();
return 0;
}
@ -155,7 +155,7 @@ NSString * const IKImageBrowserBackgroundColorKey=@"IKImageBrowserBackgroundColo
}
-(IKImageBrowserCell *)newCellForRepresentedItem:(id)anItem {
-(IKImageBrowserCell *)newCellForRepresentedItem:anItem {
NSUnimplementedMethod();
return 0;
}
@ -269,12 +269,12 @@ NSString * const IKImageBrowserBackgroundColorKey=@"IKImageBrowserBackgroundColo
}
-(void)setDelegate:(id)delegate {
-(void)setDelegate:delegate {
_delegate=delegate;
}
-(void)setDraggingDestinationDelegate:(id)delegate {
-(void)setDraggingDestinationDelegate:delegate {
NSUnimplementedMethod();
}

View File

@ -1,13 +1,6 @@
#import <Onyx2D/O2Font_ttf.h>
#import <Onyx2D/O2TTFDecoder.h>
O2FontRef O2FontCreateWithFontName_platform(NSString *name) {
return nil;
}
O2FontRef O2FontCreateWithDataProvider_platform(NSString *name) {
return nil;
}
@implementation O2Font_ttf
@ -23,4 +16,12 @@ O2FontRef O2FontCreateWithDataProvider_platform(NSString *name) {
return (O2Glyph)(int)NSMapGet(_nameToGlyph,name);
}
O2FontRef O2FontCreateWithFontName_platform(NSString *name) {
return nil;
}
O2FontRef O2FontCreateWithDataProvider_platform(O2DataProviderRef provider) {
return nil;
}
@end

View File

@ -574,7 +574,7 @@ void O2PDF_render_gs(O2PDFScanner *scanner,void *info) {
if([graphicsState getNameForKey:"SMask" value:&name]){
O2PDFFix(__FILE__,__LINE__,@"SMask not implemented");
O2PDFFix(__FILE__,__LINE__,@"SMask not implemented, name=%s",name);
}
else if([graphicsState getDictionaryForKey:"SMask" value:&dictionary]){
O2PDFFix(__FILE__,__LINE__,@"SMask not implemented");

View File

@ -283,7 +283,14 @@
isa = PBXProject;
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "OpenGL" */;
compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
);
mainGroup = 0867D691FE84028FC02AAC07 /* OpenGL */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";