Source/Card.m
changeset 6 af9b2b929b03
parent 1 3eb7be1dd7b6
child 8 45c82a071aca
     1.1 --- a/Source/Card.m	Mon Mar 10 17:30:57 2008 -0700
     1.2 +++ b/Source/Card.m	Wed Mar 12 15:51:32 2008 -0700
     1.3 @@ -28,6 +28,8 @@
     1.4  @implementation Card
     1.5  
     1.6  
     1.7 +static CGSize sCardSize = {100,150};
     1.8 +
     1.9  static CATransform3D kFaceUpTransform, kFaceDownTransform;
    1.10  
    1.11  + (void) initialize
    1.12 @@ -51,12 +53,16 @@
    1.13  }
    1.14  
    1.15  
    1.16 ++ (CGSize) cardSize                 {return sCardSize;}
    1.17 ++ (void) setCardSize: (CGSize)size  {sCardSize = size;}
    1.18 +
    1.19 +
    1.20  - (id) initWithSerialNumber: (int)serial position: (CGPoint)pos
    1.21  {
    1.22      self = [super init];
    1.23      if (self != nil) {
    1.24          _serialNumber = serial;
    1.25 -        self.bounds = CGRectMake(0,0,kCardWidth,kCardHeight);
    1.26 +        self.bounds = CGRectMake(0,0,sCardSize.width,sCardSize.height);
    1.27          self.position = pos;
    1.28          self.edgeAntialiasingMask = 0;
    1.29          _back = [self createBack];
    1.30 @@ -111,11 +117,11 @@
    1.31  - (GGBLayer*) createFront
    1.32  {
    1.33      GGBLayer *front = [[GGBLayer alloc] init];
    1.34 -    front.bounds = CGRectMake(0,0,kCardWidth,kCardHeight);
    1.35 -    front.position = CGPointMake(kCardWidth/2,kCardHeight/2);
    1.36 +    front.bounds = CGRectMake(0,0,sCardSize.width,sCardSize.height);
    1.37 +    front.position = CGPointMake(sCardSize.width/2,sCardSize.height/2);
    1.38      front.edgeAntialiasingMask = 0;
    1.39      front.backgroundColor = kWhiteColor;
    1.40 -    front.cornerRadius = 8;
    1.41 +    front.cornerRadius = 8 * (sCardSize.height/150);
    1.42      front.borderWidth = 1;
    1.43      front.borderColor = CreateGray(0.7, 1.0);
    1.44      front.doubleSided = NO;         // this makes the layer invisible when it's flipped
    1.45 @@ -128,19 +134,29 @@
    1.46      CGSize size = self.bounds.size;
    1.47      GGBLayer *back = [[GGBLayer alloc] init];
    1.48      back.bounds = CGRectMake(0,0,size.width,size.height);
    1.49 -    back.position = CGPointMake(kCardWidth/2,kCardHeight/2);
    1.50 +    back.position = CGPointMake(sCardSize.width/2,sCardSize.height/2);
    1.51 +#if TARGET_OS_ASPEN
    1.52 +    back.backgroundColor = CreateRGB(0.0,0.5,0.5, 1.0);
    1.53 +#else
    1.54      back.contents = (id) GetCGImageNamed(@"/Library/Desktop Pictures/Classic Aqua Blue.jpg");
    1.55 +#endif
    1.56      back.contentsGravity = kCAGravityResize;
    1.57      back.masksToBounds = YES;
    1.58 -    back.borderWidth = 4;
    1.59 +    back.borderWidth = 4 * (sCardSize.height/150);
    1.60      back.borderColor = kWhiteColor;
    1.61 -    back.cornerRadius = 8;
    1.62 +    back.cornerRadius = 8 * (sCardSize.height/150);
    1.63      back.edgeAntialiasingMask = 0;
    1.64      back.doubleSided = NO;          // this makes the layer invisible when it's flipped
    1.65      
    1.66 +#if TARGET_OS_ASPEN
    1.67 +    // On iPhone, only Hiragana Kaku includes the coveted snowman glyph... who knows why?
    1.68 +    UIFont *font = [UIFont fontWithName: @"HiraKakuProN-W3" size: 1*size.width];
    1.69 +#else
    1.70 +    NSFont *font = [NSFont systemFontOfSize: 1*size.width];
    1.71 +#endif
    1.72      GGBTextLayer *label = [GGBTextLayer textLayerInSuperlayer: back
    1.73                                                       withText: @"\u2603"          // Unicode snowman character
    1.74 -                                                     fontSize: 0.9*size.width
    1.75 +                                                         font: font
    1.76                                                      alignment: kCALayerWidthSizable|kCALayerHeightSizable];
    1.77      label.foregroundColor = CreateGray(1.0,0.5);
    1.78      return [back autorelease];