| 1 | /* |
|---|
| 2 | * SapphireFrontRowCompat.m |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by Graham Booker on Oct. 29, 2007. |
|---|
| 6 | * Copyright 2007 Sapphire Development Team and/or www.nanopi.net |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
|---|
| 10 | * General Public License as published by the Free Software Foundation; either version 3 of the License, |
|---|
| 11 | * or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|---|
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|---|
| 15 | * Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License along with this program; if not, |
|---|
| 18 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #import "SapphireFrontRowCompat.h" |
|---|
| 22 | #import <ExceptionHandling/NSExceptionHandler.h> |
|---|
| 23 | #import "SapphireButtonControl.h" |
|---|
| 24 | |
|---|
| 25 | /*Yes, this is the wrong class, but otherwise gcc gripes about BRImage class not existing; this removes warnings so no harm*/ |
|---|
| 26 | @interface SapphireFrontRowCompat (compat) |
|---|
| 27 | + (id)imageWithPath:(NSString *)path; |
|---|
| 28 | - (id)downsampledImageForMaxSize:(NSSize)size; |
|---|
| 29 | + (id)imageWithCGImageRef:(CGImageRef)ref; |
|---|
| 30 | - (CGImageRef)image; |
|---|
| 31 | @end |
|---|
| 32 | |
|---|
| 33 | NSData *CreateBitmapDataFromImage(CGImageRef image, unsigned int width, unsigned int height); |
|---|
| 34 | |
|---|
| 35 | /*Yes, wrong class and other wrong things, just to shut up warnings*/ |
|---|
| 36 | @interface BRAdornedMenuItemLayer (compat) |
|---|
| 37 | + (id)folderMenuItem; |
|---|
| 38 | + (id)menuItem; |
|---|
| 39 | - (void)setTitle:(NSString *)title; |
|---|
| 40 | - (void)setTitle:(NSString *)title withAttributes:(NSDictionary *)attributes; |
|---|
| 41 | - (void)setRightJustifiedText:(NSString *)text; |
|---|
| 42 | - (void)setLeftIconInfo:(BRTexture *)icon; |
|---|
| 43 | - (void)setRightIconInfo:(BRTexture *)icon; |
|---|
| 44 | @end |
|---|
| 45 | |
|---|
| 46 | @interface BRThemeInfo (compat) |
|---|
| 47 | - (id)selectedSettingImage; |
|---|
| 48 | - (id)unplayedPodcastImage; |
|---|
| 49 | - (id)returnToImage; |
|---|
| 50 | @end |
|---|
| 51 | |
|---|
| 52 | @interface BRButtonControl (compat) |
|---|
| 53 | - (id)initWithMasterLayerSize:(NSSize)fp8; |
|---|
| 54 | @end |
|---|
| 55 | |
|---|
| 56 | @interface BRTextControl (compat) |
|---|
| 57 | - (void)setText:(NSString *)text withAttributes:(NSDictionary *)attr; |
|---|
| 58 | - (NSRect)controllerFrame; /*technically wrong; it is really a CGRect*/ |
|---|
| 59 | - (NSSize)renderedSizeWithMaxSize:(NSSize)maxSize; /*technically wrong; it is really a CGSize*/ |
|---|
| 60 | @end |
|---|
| 61 | |
|---|
| 62 | @interface NSException (compat) |
|---|
| 63 | - (NSArray *)callStackReturnAddresses; |
|---|
| 64 | @end |
|---|
| 65 | |
|---|
| 66 | @interface BRAlertController (compat) |
|---|
| 67 | + (BRAlertController *)alertOfType:(int)type titled:(NSString *)title primaryText:(NSString *)primaryText secondaryText:(NSString *)secondaryText; |
|---|
| 68 | @end |
|---|
| 69 | |
|---|
| 70 | @interface BROptionDialog (compat) |
|---|
| 71 | - (void)setPrimaryInfoText:(NSString *)text withAttributes:(NSDictionary *)attributes; |
|---|
| 72 | @end |
|---|
| 73 | |
|---|
| 74 | @interface BRTextWithSpinnerController (compat) |
|---|
| 75 | - (BRTextWithSpinnerController *)initWithTitle:(NSString *)title text:(NSString *)text isNetworkDependent:(BOOL)networkDependent; |
|---|
| 76 | @end |
|---|
| 77 | |
|---|
| 78 | @interface BRControl (compat) |
|---|
| 79 | - (void)insertControl:(id)control atIndex:(long)index; |
|---|
| 80 | @end |
|---|
| 81 | |
|---|
| 82 | @interface BRWaitSpinnerControl (compat) |
|---|
| 83 | - (void)setSpins:(BOOL)spin; |
|---|
| 84 | @end |
|---|
| 85 | |
|---|
| 86 | @implementation SapphireFrontRowCompat |
|---|
| 87 | |
|---|
| 88 | static BOOL usingFrontRow = NO; |
|---|
| 89 | static BOOL usingTakeTwo = NO; |
|---|
| 90 | static BOOL usingTakeTwoDotTwo = NO; |
|---|
| 91 | static BOOL usingTakeTwoDotThree = NO; |
|---|
| 92 | |
|---|
| 93 | + (void)initialize |
|---|
| 94 | { |
|---|
| 95 | if(NSClassFromString(@"BRAdornedMenuItemLayer") == nil) |
|---|
| 96 | usingFrontRow = YES; |
|---|
| 97 | |
|---|
| 98 | if(NSClassFromString(@"BRBaseAppliance") != nil) |
|---|
| 99 | usingTakeTwo = YES; |
|---|
| 100 | |
|---|
| 101 | if(NSClassFromString(@"BRVideoPlayerController") == nil) |
|---|
| 102 | usingTakeTwoDotTwo = YES; |
|---|
| 103 | |
|---|
| 104 | if([(Class)NSClassFromString(@"BRController") instancesRespondToSelector:@selector(wasExhumed)]) |
|---|
| 105 | usingTakeTwoDotThree = YES; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | + (BOOL)usingFrontRow |
|---|
| 109 | { |
|---|
| 110 | return usingFrontRow; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | + (BOOL)usingTakeTwo |
|---|
| 114 | { |
|---|
| 115 | return usingTakeTwo; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | + (BOOL)usingTakeTwoDotTwo |
|---|
| 119 | { |
|---|
| 120 | return usingTakeTwoDotTwo; |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | + (BOOL)usingTakeTwoDotThree |
|---|
| 124 | { |
|---|
| 125 | return usingTakeTwoDotThree; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | + (id)imageAtPath:(NSString *)path |
|---|
| 129 | { |
|---|
| 130 | if(usingFrontRow) { |
|---|
| 131 | Class cls = NSClassFromString(@"BRImage"); |
|---|
| 132 | return [cls imageWithPath:path]; |
|---|
| 133 | } else { |
|---|
| 134 | // this returns a CGImageRef |
|---|
| 135 | NSURL *url = [NSURL fileURLWithPath:path]; |
|---|
| 136 | CGImageRef imageRef = NULL; |
|---|
| 137 | CGImageSourceRef sourceRef; |
|---|
| 138 | |
|---|
| 139 | sourceRef = CGImageSourceCreateWithURL((CFURLRef)url, NULL); |
|---|
| 140 | if(sourceRef) { |
|---|
| 141 | imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL); |
|---|
| 142 | CFRelease(sourceRef); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | return [(id)imageRef autorelease]; |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | + (id)imageAtPath:(NSString *)path scene:(BRRenderScene *)scene |
|---|
| 150 | { |
|---|
| 151 | if(usingFrontRow) { |
|---|
| 152 | return [self imageAtPath:path]; |
|---|
| 153 | } else { |
|---|
| 154 | CGImageRef imageRef = (CGImageRef)[self imageAtPath:path]; |
|---|
| 155 | BRTexture *ret = nil; |
|---|
| 156 | |
|---|
| 157 | if(imageRef != NULL) { |
|---|
| 158 | /*Create a texture*/ |
|---|
| 159 | ret = [BRBitmapTexture textureWithImage:imageRef context:[scene resourceContext] mipmap:YES]; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | return ret; |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | + (BRAdornedMenuItemLayer *)textMenuItemForScene:(BRRenderScene *)scene folder:(BOOL)folder |
|---|
| 167 | { |
|---|
| 168 | if(usingFrontRow) |
|---|
| 169 | { |
|---|
| 170 | if(folder) |
|---|
| 171 | return [NSClassFromString(@"BRTextMenuItemLayer") folderMenuItem]; |
|---|
| 172 | else |
|---|
| 173 | return [NSClassFromString(@"BRTextMenuItemLayer") menuItem]; |
|---|
| 174 | } |
|---|
| 175 | else |
|---|
| 176 | { |
|---|
| 177 | if(folder) |
|---|
| 178 | return [NSClassFromString(@"BRAdornedMenuItemLayer") adornedFolderMenuItemWithScene:scene]; |
|---|
| 179 | else |
|---|
| 180 | return [NSClassFromString(@"BRAdornedMenuItemLayer") adornedMenuItemWithScene:scene]; |
|---|
| 181 | } |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | + (void)setTitle:(NSString *)title forMenu:(BRAdornedMenuItemLayer *)menu |
|---|
| 185 | { |
|---|
| 186 | if(usingFrontRow) |
|---|
| 187 | [menu setTitle:title]; |
|---|
| 188 | else |
|---|
| 189 | [[menu textItem] setTitle:title]; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | + (void)setTitle:(NSString *)title withAttributes:(NSDictionary *)attributes forMenu:(BRAdornedMenuItemLayer *)menu |
|---|
| 193 | { |
|---|
| 194 | if(usingFrontRow) |
|---|
| 195 | [menu setTitle:title withAttributes:attributes]; |
|---|
| 196 | else |
|---|
| 197 | [[menu textItem] setTitle:title withAttributes:attributes]; |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | + (NSString *)titleForMenu:(BRAdornedMenuItemLayer *)menu { |
|---|
| 201 | if(usingFrontRow) |
|---|
| 202 | return [menu title]; |
|---|
| 203 | else |
|---|
| 204 | return [[menu textItem] title]; |
|---|
| 205 | } |
|---|
| 206 | + (void)setRightJustifiedText:(NSString *)text forMenu:(BRAdornedMenuItemLayer *)menu |
|---|
| 207 | { |
|---|
| 208 | if(usingFrontRow) |
|---|
| 209 | [menu setRightJustifiedText:text]; |
|---|
| 210 | else |
|---|
| 211 | [[menu textItem] setRightJustifiedText:text]; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | + (void)setLeftIcon:(BRTexture *)icon forMenu:(BRAdornedMenuItemLayer *)menu |
|---|
| 215 | { |
|---|
| 216 | if(usingFrontRow) |
|---|
| 217 | [menu setLeftIconInfo:[NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 218 | icon, @"BRMenuIconImageKey", |
|---|
| 219 | nil]]; |
|---|
| 220 | else |
|---|
| 221 | [menu setLeftIcon:icon]; |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | + (void)setRightIcon:(BRTexture *)icon forMenu:(BRAdornedMenuItemLayer *)menu |
|---|
| 225 | { |
|---|
| 226 | if(usingFrontRow) |
|---|
| 227 | [menu setRightIconInfo:[NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 228 | icon, @"BRMenuIconImageKey", |
|---|
| 229 | nil]]; |
|---|
| 230 | else |
|---|
| 231 | [menu setRightIcon:icon]; |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | + (id)selectedSettingImageForScene:(BRRenderScene *)scene |
|---|
| 235 | { |
|---|
| 236 | if(usingFrontRow) |
|---|
| 237 | return [[BRThemeInfo sharedTheme] selectedSettingImage]; |
|---|
| 238 | else |
|---|
| 239 | return [[BRThemeInfo sharedTheme] selectedSettingImageForScene:scene]; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | + (id)unplayedPodcastImageForScene:(BRRenderScene *)scene |
|---|
| 243 | { |
|---|
| 244 | if(usingFrontRow) |
|---|
| 245 | return [[BRThemeInfo sharedTheme] unplayedPodcastImage]; |
|---|
| 246 | else |
|---|
| 247 | return [[BRThemeInfo sharedTheme] unplayedPodcastImageForScene:scene]; |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | + (id)returnToImageForScene:(BRRenderScene *)scene { |
|---|
| 251 | if(usingFrontRow) |
|---|
| 252 | return [[BRThemeInfo sharedTheme] returnToImage]; |
|---|
| 253 | else |
|---|
| 254 | return [[BRThemeInfo sharedTheme] returnToImageForScene:scene]; |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | + (NSRect)frameOfController:(id)controller |
|---|
| 258 | { |
|---|
| 259 | if(usingTakeTwo) |
|---|
| 260 | // ATV2 |
|---|
| 261 | return [controller frame]; |
|---|
| 262 | else if(usingFrontRow) |
|---|
| 263 | // 10.5 |
|---|
| 264 | return [controller controllerFrame]; |
|---|
| 265 | else |
|---|
| 266 | return [[controller masterLayer] frame]; |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | + (void)setText:(NSString *)text withAtrributes:(NSDictionary *)attributes forControl:(BRTextControl *)control |
|---|
| 270 | { |
|---|
| 271 | if(usingFrontRow) |
|---|
| 272 | [control setText:text withAttributes:attributes]; |
|---|
| 273 | else |
|---|
| 274 | { |
|---|
| 275 | if(attributes != nil) |
|---|
| 276 | [control setTextAttributes:attributes]; |
|---|
| 277 | [control setText:text]; |
|---|
| 278 | } |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | + (NSSize)textControl:(BRTextControl *)text renderedSizeWithMaxSize:(NSSize)maxSize |
|---|
| 282 | { |
|---|
| 283 | if(usingTakeTwo) |
|---|
| 284 | return [text renderedSizeWithMaxSize:maxSize]; |
|---|
| 285 | |
|---|
| 286 | [text setMaximumSize:maxSize]; |
|---|
| 287 | return [text renderedSize]; |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | + (void)addDividerAtIndex:(int)index toList:(BRListControl *)list |
|---|
| 291 | { |
|---|
| 292 | if(usingFrontRow) |
|---|
| 293 | [list addDividerAtIndex:index withLabel:@""]; |
|---|
| 294 | else |
|---|
| 295 | [list addDividerAtIndex:index]; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | + (void)addSublayer:(id)sub toControl:(id)controller |
|---|
| 299 | { |
|---|
| 300 | if(usingFrontRow) { |
|---|
| 301 | // ATV2 |
|---|
| 302 | if(NSClassFromString(@"BRPanel") == nil) |
|---|
| 303 | [controller addControl:sub]; |
|---|
| 304 | // 10.5 |
|---|
| 305 | else |
|---|
| 306 | [[controller layer] addSublayer:sub]; |
|---|
| 307 | } |
|---|
| 308 | else |
|---|
| 309 | [[controller masterLayer] addSublayer:sub]; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | + (void)insertSublayer:(id)sub toControl:(id)controller atIndex:(long)index { |
|---|
| 313 | if(usingFrontRow) { |
|---|
| 314 | // ATV2 |
|---|
| 315 | if(NSClassFromString(@"BRPanel") == nil) |
|---|
| 316 | [controller insertControl:sub atIndex:index]; |
|---|
| 317 | // 10.5 |
|---|
| 318 | else |
|---|
| 319 | [[controller layer] insertSublayer:sub atIndex:index]; |
|---|
| 320 | } else |
|---|
| 321 | [[controller masterLayer] insertSublayer:sub atIndex:index]; |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | + (BRHeaderControl *)newHeaderControlWithScene:(BRRenderScene *)scene |
|---|
| 325 | { |
|---|
| 326 | if(usingFrontRow) |
|---|
| 327 | return [[BRHeaderControl alloc] init]; |
|---|
| 328 | else |
|---|
| 329 | return [[BRHeaderControl alloc] initWithScene:scene]; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | + (BRButtonControl *)newButtonControlWithScene:(BRRenderScene *)scene masterLayerSize:(NSSize)size; |
|---|
| 333 | { |
|---|
| 334 | if(usingFrontRow) |
|---|
| 335 | return [[SapphireButtonControl alloc] initWithMasterLayerSize:size]; |
|---|
| 336 | else |
|---|
| 337 | return [[BRButtonControl alloc] initWithScene:scene masterLayerSize:size]; |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | + (BRTextControl *)newTextControlWithScene:(BRRenderScene *)scene |
|---|
| 341 | { |
|---|
| 342 | if(usingFrontRow) |
|---|
| 343 | return [[BRTextControl alloc] init]; |
|---|
| 344 | else |
|---|
| 345 | return [[BRTextControl alloc] initWithScene:scene]; |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | + (BRTextEntryControl *)newTextEntryControlWithScene:(BRRenderScene *)scene |
|---|
| 349 | { |
|---|
| 350 | if(usingFrontRow) |
|---|
| 351 | return [[BRTextEntryControl alloc] init]; |
|---|
| 352 | else |
|---|
| 353 | return [[BRTextEntryControl alloc] initWithScene:scene]; |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | + (BRProgressBarWidget *)newProgressBarWidgetWithScene:(BRRenderScene *)scene |
|---|
| 357 | { |
|---|
| 358 | if(usingFrontRow) |
|---|
| 359 | return [[BRProgressBarWidget alloc] init]; |
|---|
| 360 | else |
|---|
| 361 | return [[BRProgressBarWidget alloc] initWithScene:scene]; |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | + (BRMarchingIconLayer *)newMarchingIconLayerWithScene:(BRRenderScene *)scene |
|---|
| 365 | { |
|---|
| 366 | if(usingTakeTwo) |
|---|
| 367 | return nil; |
|---|
| 368 | if(usingFrontRow) |
|---|
| 369 | return [[BRMarchingIconLayer alloc] init]; |
|---|
| 370 | else |
|---|
| 371 | return [[BRMarchingIconLayer alloc] initWithScene:scene]; |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | + (BRImageLayer *)newImageLayerWithScene:(BRRenderScene *)scene { |
|---|
| 375 | // 10.5 |
|---|
| 376 | if(usingFrontRow && NSClassFromString(@"BRImageLayer") != nil) |
|---|
| 377 | return [[BRImageLayer alloc] init]; |
|---|
| 378 | // ATV2 |
|---|
| 379 | else if(usingFrontRow) |
|---|
| 380 | return [[NSClassFromString(@"BRImageControl") alloc] init]; |
|---|
| 381 | else |
|---|
| 382 | return [BRImageLayer layerWithScene:scene]; |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | + (void)setImage:(id)image forLayer:(BRImageLayer *)layer { |
|---|
| 386 | if(usingFrontRow) |
|---|
| 387 | // this cast is not proper, it just makes a warning disappear. |
|---|
| 388 | [layer setImage:(CGImageRef)image]; |
|---|
| 389 | else |
|---|
| 390 | [layer setTexture:image]; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | + (BRImageLayer *)newImageLayerWithImage:(id)image scene:(BRRenderScene *)scene { |
|---|
| 394 | BRImageLayer *result = [self newImageLayerWithScene:scene]; |
|---|
| 395 | [self setImage:image forLayer:result]; |
|---|
| 396 | return result; |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | + (void)renderScene:(BRRenderScene *)scene |
|---|
| 400 | { |
|---|
| 401 | if(!usingFrontRow) |
|---|
| 402 | [scene renderScene]; |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | + (BRAlertController *)alertOfType:(int)type titled:(NSString *)title primaryText:(NSString *)primaryText secondaryText:(NSString *)secondaryText withScene:(BRRenderScene *)scene { |
|---|
| 406 | if(usingFrontRow) |
|---|
| 407 | return [BRAlertController alertOfType:type |
|---|
| 408 | titled:title |
|---|
| 409 | primaryText:primaryText |
|---|
| 410 | secondaryText:secondaryText]; |
|---|
| 411 | else |
|---|
| 412 | return [BRAlertController alertOfType:type |
|---|
| 413 | titled:title |
|---|
| 414 | primaryText:primaryText |
|---|
| 415 | secondaryText:secondaryText |
|---|
| 416 | withScene:scene]; |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | + (BROptionDialog *)newOptionDialogWithScene:(BRRenderScene *)scene { |
|---|
| 420 | if(usingFrontRow) |
|---|
| 421 | return [[BROptionDialog alloc] init]; |
|---|
| 422 | else |
|---|
| 423 | return [[BROptionDialog alloc] initWithScene:scene]; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | + (void)setOptionDialogPrimaryInfoText:(NSString *)primaryInfoText withAttributes:(NSDictionary *)attributes optionDialog:(BROptionDialog *)dialog { |
|---|
| 427 | if(usingFrontRow) { |
|---|
| 428 | [dialog setPrimaryInfoText:primaryInfoText withAttributes:attributes]; |
|---|
| 429 | } else { |
|---|
| 430 | [dialog setPrimaryInfoText:primaryInfoText]; |
|---|
| 431 | [dialog setPrimaryInfoTextAttributes:attributes]; |
|---|
| 432 | } |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | + (BRTextWithSpinnerController *)newTextWithSpinnerControllerTitled:(NSString *)title text:(NSString *)text isNetworkDependent:(BOOL)networkDependent scene:(BRRenderScene *)scene { |
|---|
| 436 | if(usingFrontRow) |
|---|
| 437 | return [[BRTextWithSpinnerController alloc] initWithTitle:title text:text isNetworkDependent:networkDependent]; |
|---|
| 438 | else |
|---|
| 439 | return [[BRTextWithSpinnerController alloc] initWithScene:scene title:title text:text showBack:NO isNetworkDependent:NO]; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | + (void)setSpinner:(BRWaitSpinnerControl *)spinner toSpin:(BOOL)spin |
|---|
| 443 | { |
|---|
| 444 | if([spinner respondsToSelector:@selector(setSpins:)]) |
|---|
| 445 | [spinner setSpins:spin]; |
|---|
| 446 | else if([spinner respondsToSelector:@selector(startSpinning)]) |
|---|
| 447 | { |
|---|
| 448 | if(spin) |
|---|
| 449 | [spinner startSpinning]; |
|---|
| 450 | else |
|---|
| 451 | [spinner stopSpinning]; |
|---|
| 452 | } |
|---|
| 453 | } |
|---|
| 454 | |
|---|
| 455 | + (NSArray *)callStackReturnAddressesForException:(NSException *)exception |
|---|
| 456 | { |
|---|
| 457 | if([exception respondsToSelector:@selector(callStackReturnAddresses)]) |
|---|
| 458 | { |
|---|
| 459 | NSArray *ret = [exception callStackReturnAddresses]; |
|---|
| 460 | if([ret count]) |
|---|
| 461 | return ret; |
|---|
| 462 | } |
|---|
| 463 | return [[exception userInfo] objectForKey:NSStackTraceKey]; |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | + (RUIPreferences *)sharedFrontRowPreferences { |
|---|
| 467 | Class preferencesClass = NSClassFromString(@"RUIPreferences"); |
|---|
| 468 | if(!preferencesClass) preferencesClass = NSClassFromString(@"BRPreferences"); |
|---|
| 469 | |
|---|
| 470 | if(preferencesClass) |
|---|
| 471 | return [preferencesClass sharedFrontRowPreferences]; |
|---|
| 472 | else |
|---|
| 473 | return nil; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | @end |
|---|