Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working on toolbar

  • Loading branch information...
commit 457de121f68bf1ee3719a0a5f1e90a1e2b2a26c2 1 parent 640788f
Todd Ditchendorf authored
View
1  demoapp/MyRootViewController.h
@@ -16,6 +16,7 @@
@interface MyRootViewController : UMEViewController {
IBOutlet NSButton *button;
+ IBOutlet UMEToolbar *toolbar;
}
- (IBAction)click:(id)sender;
View
11 demoapp/MyRootViewController.m
@@ -78,6 +78,17 @@ - (void)viewDidLoad {
action:@selector(stop:)] autorelease];
}
+
+ NSMutableArray *items = [NSMutableArray array];
+ UMEBarButtonItem *item = nil;
+
+ item = [[[UMEBarButtonItem alloc] initWithBarButtonSystemItem:UMEBarButtonSystemItemCamera target:nil action:nil] autorelease];
+ [items addObject:item];
+
+ item = [[[UMEBarButtonItem alloc] initWithBarButtonSystemItem:UMEBarButtonSystemItemCompose target:nil action:nil] autorelease];
+ [items addObject:item];
+
+ toolbar.items = items;
}
View
43 demoapp/RootView.xib
@@ -68,10 +68,10 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSCustomView" id="51695152">
+ <object class="NSCustomView" id="1064836951">
<reference key="NSNextResponder" ref="732109442"/>
- <int key="NSvFlags">266</int>
- <string key="NSFrame">{{0, 143}, {357, 44}}</string>
+ <int key="NSvFlags">290</int>
+ <string key="NSFrameSize">{357, 44}</string>
<reference key="NSSuperview" ref="732109442"/>
<string key="NSClassName">UMEToolbar</string>
</object>
@@ -105,13 +105,21 @@
</object>
<int key="connectionID">76</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">toolbar</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="1064836951"/>
+ </object>
+ <int key="connectionID">80</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
- <object class="NSArray" key="object" id="657685256">
+ <object class="NSArray" key="object" id="1024186320">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
@@ -120,19 +128,19 @@
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
- <reference key="parent" ref="657685256"/>
+ <reference key="parent" ref="1024186320"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
- <reference key="parent" ref="657685256"/>
+ <reference key="parent" ref="1024186320"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
- <reference key="parent" ref="657685256"/>
+ <reference key="parent" ref="1024186320"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
@@ -143,7 +151,7 @@
<reference ref="1000708822"/>
<reference ref="732109442"/>
</object>
- <reference key="parent" ref="657685256"/>
+ <reference key="parent" ref="1024186320"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">74</int>
@@ -164,13 +172,13 @@
<reference key="object" ref="732109442"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="51695152"/>
+ <reference ref="1064836951"/>
</object>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">78</int>
- <reference key="object" ref="51695152"/>
+ <reference key="object" ref="1064836951"/>
<reference key="parent" ref="732109442"/>
</object>
</object>
@@ -222,7 +230,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">78</int>
+ <int key="maxID">80</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -244,8 +252,17 @@
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">button</string>
- <string key="NS.object.0">NSButton</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>button</string>
+ <string>toolbar</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSButton</string>
+ <string>UMEToolbar</string>
+ </object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
View
36 src/UMEToolbar.m
@@ -12,6 +12,10 @@
static NSImage *sBlackBackgroundImage = nil;
static NSImage *sGrayBackgroundImage = nil;
+@interface UMEBarButtonItem ()
+- (void)sizeToFit;
+@end
+
@interface UMEToolbar ()
- (void)layoutItems;
@end
@@ -22,9 +26,7 @@ + (void)initialize {
if ([UMEToolbar class] == self) {
NSBundle *b = [NSBundle bundleForClass:self];
-
- NSString *s = [b pathForImageResource:@"toolbar_bg_default"];
- s;
+
sDefaultBackgroundImage = [[NSImage alloc] initWithContentsOfFile:[b pathForImageResource:@"toolbar_bg_default"]];
sBlackBackgroundImage = [[NSImage alloc] initWithContentsOfFile:[b pathForImageResource:@"toolbar_bg_black"]];
sGrayBackgroundImage = [[NSImage alloc] initWithContentsOfFile:[b pathForImageResource:@"toolbar_bg_gray"]];
@@ -34,7 +36,7 @@ + (void)initialize {
- (id)initWithFrame:(NSRect)frame {
if (self = [super initWithFrame:frame]) {
- self.barStyle = UMEBarStyleDefault;
+ self.barStyle = UMEBarStyleBlack;
}
return self;
}
@@ -56,13 +58,13 @@ - (BOOL)isFlipped {
// necessary for the first run layout :|
-- (void)viewWillDraw {
- if (!layoutDone) {
- layoutDone = YES;
- [self layoutItems];
- }
- [super viewWillDraw];
-}
+//- (void)viewWillDraw {
+// if (!layoutDone) {
+// layoutDone = YES;
+// [self layoutItems];
+// }
+// [super viewWillDraw];
+//}
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
@@ -100,6 +102,16 @@ - (void)setItems:(NSArray *)a animated:(BOOL)animated {
}
+- (void)setItems:(NSArray *)a {
+ if (a != items) {
+ [items autorelease];
+ items = [a retain];
+
+ [self layoutItems];
+ }
+}
+
+
#pragma mark -
#pragma mark Private
@@ -110,6 +122,7 @@ - (void)layoutItems {
CGFloat h = 0;
for (UMEBarButtonItem *item in items) {
+ //[item sizeToFit];
[self addSubview:item.customView];
w = [item width];
h = NSHeight([item.customView frame]);
@@ -117,6 +130,7 @@ - (void)layoutItems {
x += w;
}
+ [self setNeedsDisplay:YES];
}
@synthesize barStyle;
Please sign in to comment.
Something went wrong with that request. Please try again.