| 1 | /* |
|---|
| 2 | * SapphireLayoutManager.h |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by Graham Booker on Nov. 24, 2008. |
|---|
| 6 | * Copyright 2008 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 "SapphireLayoutManager.h" |
|---|
| 22 | #import "SapphireFrontRowCompat.h" |
|---|
| 23 | |
|---|
| 24 | @interface BRLayerController (compat) |
|---|
| 25 | - (void)setLayoutManager:(id)newLayout; |
|---|
| 26 | - (id)layoutManager; |
|---|
| 27 | @end |
|---|
| 28 | |
|---|
| 29 | @implementation SapphireLayoutManager |
|---|
| 30 | |
|---|
| 31 | + (id)setCustomLayoutOnControl:(BRLayerController <SapphireLayoutDelegate> *)control |
|---|
| 32 | { |
|---|
| 33 | if(![SapphireFrontRowCompat usingATypeOfTakeTwo]) |
|---|
| 34 | return nil; |
|---|
| 35 | |
|---|
| 36 | SapphireLayoutManager *newLayout = [[SapphireLayoutManager alloc] initWithReal:[control layoutManager]]; |
|---|
| 37 | [newLayout setDelegate:control]; |
|---|
| 38 | [control setLayoutManager:newLayout]; |
|---|
| 39 | [newLayout autorelease]; |
|---|
| 40 | |
|---|
| 41 | return newLayout; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | - (id)initWithReal:(id)real |
|---|
| 45 | { |
|---|
| 46 | self = [super init]; |
|---|
| 47 | if(self == nil) |
|---|
| 48 | return self; |
|---|
| 49 | realLayout = [real retain]; |
|---|
| 50 | return self; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | - (void) dealloc |
|---|
| 54 | { |
|---|
| 55 | [realLayout release]; |
|---|
| 56 | [super dealloc]; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | - (void)setDelegate:(id <SapphireLayoutDelegate>)theDelegate |
|---|
| 60 | { |
|---|
| 61 | delegate = theDelegate; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | - (void)layoutSublayersOfLayer:(id)layer |
|---|
| 65 | { |
|---|
| 66 | [realLayout layoutSublayersOfLayer:layer]; |
|---|
| 67 | [delegate doMyLayout]; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | - (NSSize)preferredSizeOfLayer:(id)layer |
|---|
| 71 | { |
|---|
| 72 | return [realLayout preferredSizeOfLayer:layer]; |
|---|
| 73 | } |
|---|
| 74 | @end |
|---|