From c045fc111c16a554edd88e9eccd37938f88e790a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 14 Apr 2008 22:21:12 +0000 Subject: [PATCH] Ported to iPhoneOS 2.0. --- Cydia.mm | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- makefile | 2 +- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index 0da4550f..8bd168cf 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -60,9 +61,50 @@ while (false) @end /* }}} */ -#ifdef SRK_ASPEN -#define UITable UITableView +/* iPhoneOS 2.0 Compatibility {{{ */ +#ifdef __OBJC2__ +@interface UICGColor : NSObject { +} + +- (id) initWithCGColor:(CGColorRef)color; +@end + +@interface UIFont { +} + +- (UIFont *) fontWithSize:(CGFloat)size; +@end + +@interface NSObject (iPhoneOS) +- (CGColorRef) cgColor; +- (void) set; +@end + +@implementation NSObject (iPhoneOS) + +- (CGColorRef) cgColor { + return (CGColorRef) self; +} + +- (void) set { + [[[[objc_getClass("UICGColor") alloc] initWithCGColor:[self cgColor]] autorelease] set]; +} + +@end + +@interface UITextView (iPhoneOS) +- (void) setTextSize:(float)size; +@end + +@implementation UITextView (iPhoneOS) + +- (void) setTextSize:(float)size { + [self setFont:[[self font] fontWithSize:size]]; +} + +@end #endif +/* }}} */ OBJC_EXPORT const char *class_getName(Class cls); @@ -244,9 +286,9 @@ UITextView *GetTextView(NSString *value, float left, bool html) { UITextView *text([[[UITextView alloc] initWithFrame:CGRectMake(left, 3, 310 - left, 1000)] autorelease]); [text setEditable:NO]; [text setTextSize:16]; - if (html) + /*if (html) [text setHTML:value]; - else + else*/ [text setText:value]; [text setEnabled:NO]; @@ -3277,7 +3319,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) { - (void) packageTable:(id)table packageSelected:(Package *)package { if (package == nil) { +#ifndef __OBJC2__ [navbar_ setAccessoryView:accessory_ animate:(resetting_ ? NO : YES) goingBack:YES]; +#else + [navbar_ setAccessoryView:accessory_ animate:YES removeOnPop:NO]; +#endif [package_ release]; package_ = nil; @@ -3285,7 +3331,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) { [view_ release]; view_ = nil; } else { +#ifndef __OBJC2__ [navbar_ setAccessoryView:nil animate:YES goingBack:NO]; +#else + [navbar_ setAccessoryView:nil animate:YES removeOnPop:YES]; +#endif _assert(package_ == nil); _assert(view_ == nil); @@ -3352,9 +3402,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) { [field_ setPaddingTop:5]; [field_ setDelegate:self]; +#ifndef __OBJC2__ UITextTraits *traits = [field_ textTraits]; [traits setEditingDelegate:self]; [traits setReturnKeyType:6]; +#endif accessory_ = [[UIView alloc] initWithFrame:CGRectMake(6, 6, area.size.width, area.size.height + 30)]; [accessory_ addSubview:field_]; diff --git a/makefile b/makefile index 70b511fb..4bdbca0d 100644 --- a/makefile +++ b/makefile @@ -15,6 +15,6 @@ exec: exec.mm makefile $(target)g++ -Wall -Werror -o $@ $< -framework Foundation -framework CoreFoundation -lobjc Cydia: Cydia.mm *.h makefile - $(target)g++ -fobjc-call-cxx-cdtors -g3 -O2 -Wall -Werror -o $@ $< -framework UIKit -framework IOKit -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework GraphicsServices -lobjc -lapt-pkg -lpcre -fobjc-exceptions + $(target)g++ -fobjc-call-cxx-cdtors -g3 -O2 -Wall -Werror -o $@ $< -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices -lobjc -lapt-pkg -lpcre -fobjc-exceptions -I/apl/i20 -F$${PKG_ROOT}/System/Library/PrivateFrameworks .PHONY: all clean test -- 2.45.2