From a60b86de5fbe121d51d756c166eac49e1832e007 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 26 Feb 2008 09:02:03 +0000 Subject: First revision of uikittools. --- makefile | 5 +++++ uialert.mm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 makefile create mode 100644 uialert.mm diff --git a/makefile b/makefile new file mode 100644 index 0000000..83a4e00 --- /dev/null +++ b/makefile @@ -0,0 +1,5 @@ +all: uialert + +%: %.mm + arm-apple-darwin-g++ -o $@ $< -framework CoreFoundation -framework Foundation -framework UIKit -lobjc + arm-apple-darwin-strip $@ diff --git a/uialert.mm b/uialert.mm new file mode 100644 index 0000000..a72cbd4 --- /dev/null +++ b/uialert.mm @@ -0,0 +1,54 @@ +#include +#include + +int argc_; +char **argv_; + +@interface AlertSheet : UIApplication { +} + +- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button; +- (void) applicationDidFinishLaunching:(id)unused; +@end + +@implementation AlertSheet + +- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button { + [sheet dismiss]; + exit(button); +} + +- (void) applicationDidFinishLaunching:(id)unused { + NSMutableArray *buttons = [NSMutableArray arrayWithCapacity:(argc_ - 3)]; + for (size_t i(0); i != argc_ - 3; ++i) + [buttons addObject:[NSString stringWithCString:argv_[i + 3]]]; + + UIAlertSheet *sheet = [[[UIAlertSheet alloc] + initWithTitle:[NSString stringWithCString:argv_[1]] + buttons:buttons + defaultButtonIndex:0 + delegate:self + context:self + ] autorelease]; + + [sheet setBodyText:[NSString stringWithCString:argv_[2]]]; + + [sheet setShowsOverSpringBoardAlerts:YES]; + [sheet popupAlertAnimated:YES]; +} + +@end + +int main(int argc, char *argv[]) { + argc_ = argc; + argv_ = argv; + + char *args[] = { + "AlertSheet", NULL + }; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + UIApplicationMain(1, args, [AlertSheet class]); + [pool release]; + return 0; +} -- cgit v1.2.3