w00t. ITButton and ITButtonCell. Also, ITTextField is now correctly implemented...
authorMatthew Judy <mjudy@ithinksw.com>
Thu, 25 Sep 2003 11:28:51 +0000 (11:28 +0000)
committerMatthew Judy <mjudy@ithinksw.com>
Thu, 25 Sep 2003 11:28:51 +0000 (11:28 +0000)
14 files changed:
ITButton.h [new file with mode: 0755]
ITButton.m [new file with mode: 0755]
ITButtonCell.h [new file with mode: 0755]
ITButtonCell.m [new file with mode: 0755]
ITHotKey.m
ITKit.h
ITTextField.h
ITTextField.m
ITTextFieldCell.m
Showcase/Controller.h
Showcase/Controller.m
Showcase/English.lproj/MainMenu.nib/classes.nib
Showcase/English.lproj/MainMenu.nib/info.nib
Showcase/English.lproj/MainMenu.nib/keyedobjects.nib

diff --git a/ITButton.h b/ITButton.h
new file mode 100755 (executable)
index 0000000..12f5599
--- /dev/null
@@ -0,0 +1,8 @@
+#import <Cocoa/Cocoa.h>
+
+
+@interface ITButton : NSButton {
+
+}
+
+@end
diff --git a/ITButton.m b/ITButton.m
new file mode 100755 (executable)
index 0000000..7a7a242
--- /dev/null
@@ -0,0 +1,39 @@
+#import "ITButton.h"
+#import "ITButtonCell.h"
+
+
+@implementation ITButton
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark INITIALIZATION METHODS
+/*************************************************************************/
+
++ (void)initialize
+{
+    if ( self == [ITButton class] ) {
+        [self setCellClass:[ITButtonCell class]];
+    }
+}
+
++ (Class)cellClass
+{
+    return [ITButtonCell class];
+}
+
+- (id)initWithCoder:(NSCoder *)coder
+{
+    if ( ( self = [super initWithCoder:coder] ) ) {
+        ITButtonCell *cell = [[ITButtonCell alloc] init];
+        [self setCell:cell];
+    }
+    return self;
+}
+
+- (BOOL)isOpaque
+{
+    return NO;
+}
+
+@end
diff --git a/ITButtonCell.h b/ITButtonCell.h
new file mode 100755 (executable)
index 0000000..fea3247
--- /dev/null
@@ -0,0 +1,16 @@
+#import <Cocoa/Cocoa.h>
+
+
+typedef enum _ITBezelStyle {
+    ITGrayRoundedBezelStyle  = 1001
+} ITBezelStyle;
+
+
+@interface ITButtonCell : NSButtonCell {
+
+    ITBezelStyle _subStyle;
+
+}
+
+
+@end
diff --git a/ITButtonCell.m b/ITButtonCell.m
new file mode 100755 (executable)
index 0000000..7885dc3
--- /dev/null
@@ -0,0 +1,94 @@
+#import "ITButtonCell.h"
+#import "ITTextFieldCell.h"
+
+
+#define GRAY_EXTRA_PAD_H 60.0
+
+
+@interface ITButtonCell (Private)
+- (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView;
+@end
+
+
+@implementation ITButtonCell
+
+- (id)init
+{
+    if ( ( self = [super init] ) ) {
+        _subStyle = 0;
+    }
+    
+    return self;
+}
+
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark INSTANCE METHODS
+/*************************************************************************/
+
+- (void)setBezelStyle:(NSBezelStyle)bezelStyle
+{
+    if ( bezelStyle == ITGrayRoundedBezelStyle ) {
+        _subStyle  = bezelStyle;
+        bezelStyle = NSRegularSquareBezelStyle;
+    } else {
+        _subStyle = 0;
+    }
+
+    [super setBezelStyle:bezelStyle];
+}
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark DRAWING METHODS
+/*************************************************************************/
+
+- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
+{
+    if ( _subStyle == ITGrayRoundedBezelStyle ) {
+        [self drawGrayRoundedBezelWithFrame:rect inView:controlView];
+        [super drawInteriorWithFrame:rect inView:controlView];
+    } else {
+        [super drawWithFrame:rect inView:controlView];
+    }
+}
+
+- (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView
+{
+    NSBezierPath *path   = [NSBezierPath bezierPath];
+    float         ch     = rect.size.height;
+    float         cw     = rect.size.width;
+    float         radius = ( ch / 2 );
+    NSPoint       pointA = NSMakePoint( (ch / 2)        , 0.0      );
+    NSPoint       pointB = NSMakePoint( (cw - (ch / 2)) , 0.0      );
+//  NSPoint       pointC = NSMakePoint( (cw - (ch / 2)) , ch       );
+    NSPoint       pointD = NSMakePoint( (ch / 2)        , ch       );
+    NSPoint       lCtr   = NSMakePoint( (ch / 2)        , (ch / 2) );
+    NSPoint       rCtr   = NSMakePoint( (cw - (ch / 2)) , (ch / 2) );
+    float         alpha  = 0.35;
+    
+    [path moveToPoint:pointA];
+    [path lineToPoint:pointB];
+    [path appendBezierPathWithArcWithCenter:rCtr
+                                     radius:radius
+                                 startAngle:270.0
+                                   endAngle:90.0];
+    [path lineToPoint:pointD];
+    [path appendBezierPathWithArcWithCenter:lCtr
+                                     radius:radius
+                                 startAngle:90.0
+                                   endAngle:270.0];
+
+    if ( [self isHighlighted] ) {
+        alpha = 0.50;
+    }
+
+    [[NSColor colorWithCalibratedWhite:0.0 alpha:alpha] set];
+    [path fill];
+}
+
+
+@end
index bf411f9..0e2ddc3 100755 (executable)
@@ -14,9 +14,7 @@
 
 - (id)init
 {
-       self = [super init];
-       
-       if( self )
+       if ( (self = [super init]) )
        {
                [self setKeyCombo: [ITKeyCombo clearKeyCombo]];
        }
@@ -34,7 +32,9 @@
 
 - (NSString*)description
 {
-       return [NSString stringWithFormat: @"<%@: %@>", NSStringFromClass( [self class] ), [self keyCombo]];
+       return [NSString stringWithFormat: @"<%@: %@>",
+        NSStringFromClass( [self class] ),
+        [self keyCombo]];
 }
 
 #pragma mark -
diff --git a/ITKit.h b/ITKit.h
index 8279c53..e76e907 100755 (executable)
--- a/ITKit.h
+++ b/ITKit.h
@@ -18,6 +18,8 @@
 #import <ITKit/ITKeyBroadcaster.h>
 #import <ITKit/ITKeyCombo.h>
 #import <ITKit/ITKeyComboPanel.h>
+#import <ITKit/ITButton.h>
+#import <ITKit/ITButtonCell.h>
 #import <ITKit/ITStatusItem.h>
 #import <ITKit/ITTableView.h>
 #import <ITKit/ITTabView.h>
index ea3e8f3..0a100ae 100755 (executable)
 
 @interface ITTextField : NSTextField {
 
-    BOOL  castsShadow;
-    
-    float shadowElevation;
-    float shadowAzimuth;
-    float shadowAmbient;
-    float shadowHeight;
-    float shadowRadius;
-    float shadowSaturation;
-
 }
 
 - (BOOL)castsShadow;
index 3ab85b7..7c0c92b 100755 (executable)
@@ -1,4 +1,5 @@
 #import "ITTextField.h"
+#import "ITTextFieldCell.h"
 #import <CoreGraphics/CoreGraphics.h>
 #import "ITCoreGraphicsHacks.h"
 
 
 @implementation ITTextField
 
+
 /*************************************************************************/
 #pragma mark -
 #pragma mark INITIALIZATION METHODS
 /*************************************************************************/
 
-- (id)initWithFrame:(NSRect)frameRect
++ (void)initialize
 {
-    if ( ( self = [super initWithFrame:frameRect] ) ) {
-        castsShadow      = NO;
-        shadowElevation  = 45.0;
-        shadowAzimuth    = 90.0;
-        shadowAmbient    = 0.15;
-        shadowHeight     = 1.00;
-        shadowRadius     = 4.00;
-        shadowSaturation = 1.0;
+    if ( self == [ITTextField class] ) {
+        [self setCellClass:[ITTextFieldCell class]];
     }
-
-    return self;
 }
 
-- (id)initWithCoder:(NSCoder *)coder
++ (Class)cellClass
 {
-    if ( ( self = [super initWithCoder:coder] ) ) {
-        castsShadow      = NO;
-        shadowElevation  = 45.0;
-        shadowAzimuth    = 90.0;
-        shadowAmbient    = 0.15;
-        shadowHeight     = 1.00;
-        shadowRadius     = 4.00;
-        shadowSaturation = 1.0;
-    }
-    
-    return self;
+    return [ITTextFieldCell class];
 }
 
 
-/*************************************************************************/
-#pragma mark -
-#pragma mark DRAWING METHODS
-/*************************************************************************/
-
-- (void)drawRect:(NSRect)rect
-{
-    CGSGenericObj        style = nil;
-    CGShadowStyle        shadow;
-
-    if ( castsShadow ) { 
-        // Create the shadow style to use for drawing the string
-        shadow.version    = 0;
-        shadow.elevation  = shadowElevation;
-        shadow.azimuth    = shadowAzimuth;
-        shadow.ambient    = shadowAmbient;
-        shadow.height     = shadowHeight;
-        shadow.radius     = shadowRadius;
-        shadow.saturation = shadowSaturation;
-        style = CGStyleCreateShadow(&shadow);
-        
-        // Set the context for drawing the string
-        [NSGraphicsContext saveGraphicsState];
-        CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
-    }
-    
-    // Draw the string
-    [super drawRect:rect];
-    
-
-    if ( castsShadow ) { 
-        // Restore the old context
-        [NSGraphicsContext restoreGraphicsState];
-        CGStyleRelease(style);
-    }
-}
-
-
-
 /*************************************************************************/
 #pragma mark -
 #pragma mark ACCESSOR METHODS
 
 - (BOOL)castsShadow;
 {
-    return castsShadow;
+    return [[self cell] castsShadow];
 }
 
 - (void)setCastsShadow:(BOOL)newSetting;
 {
-    castsShadow = newSetting;
-    [self setNeedsDisplay:YES];
+    [[self cell] setCastsShadow:newSetting];
 }
 
 - (float)shadowElevation;
 {
-    return shadowElevation;
+    return [[self cell] shadowElevation];
 }
 
 - (void)setShadowElevation:(float)newElevation;
 {
-    shadowElevation = newElevation;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowElevation:newElevation];
 }
 
 - (float)shadowAzimuth;
 {
-    return shadowAzimuth;
+    return [[self cell] shadowAzimuth];
 }
 
 - (void)setShadowAzimuth:(float)newAzimuth;
 {
-    shadowAzimuth = newAzimuth;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowAzimuth:newAzimuth];
 }
 
 - (float)shadowAmbient;
 {
-    return shadowAmbient;
+    return [[self cell] shadowAmbient];
 }
 
 - (void)setShadowAmbient:(float)newAmbient;
 {
-    shadowAmbient = newAmbient;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowAmbient:newAmbient];
 }
 
 - (float)shadowHeight;
 {
-    return shadowHeight;
+    return [[self cell] shadowHeight];
 }
 
 - (void)setShadowHeight:(float)newHeight;
 {
-    shadowHeight = newHeight;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowHeight:newHeight];
 }
 
 - (float)shadowRadius;
 {
-    return shadowRadius;
+    return [[self cell] shadowRadius];
 }
 
 - (void)setShadowRadius:(float)newRadius;
 {
-    shadowRadius = newRadius;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowRadius:newRadius];
 }
 
 - (float)shadowSaturation;
 {
-    return shadowSaturation;
+    return [[self cell] shadowSaturation];
 }
 
 - (void)setShadowSaturation:(float)newSaturation;
 {
-    shadowSaturation = newSaturation;
-    [self setNeedsDisplay:YES];
+    [[self cell] setShadowSaturation:newSaturation];
 }
 
 
index 6d2b86a..3d04848 100755 (executable)
@@ -15,9 +15,9 @@
 #pragma mark INITIALIZATION METHODS
 /*************************************************************************/
 
-- (id)init
+- (id)initTextCell:(NSString *)string;
 {
-    if ( ( self = [super init] ) ) {
+    if ( ( self = [super initTextCell:string] ) ) {
         castsShadow      = NO;
         shadowElevation  = 45.0;
         shadowAzimuth    = 90.0;
@@ -32,7 +32,7 @@
 
 - (id)initWithCoder:(NSCoder *)coder
 {
-    if ( ( self = [super initWithCoder:coder] ) ) {
+    if ( ( self = [super initWithCoder:coder] ) ) {        
         castsShadow      = NO;
         shadowElevation  = 45.0;
         shadowAzimuth    = 90.0;
 #pragma mark DRAWING METHODS
 /*************************************************************************/
 
-- (void)drawInteriorWithFrame:(NSRect)rect inView:(NSView *)controlView
+- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
 {
     CGSGenericObj        style = nil;
     CGShadowStyle        shadow;
 
     if ( castsShadow ) { 
-        // Create the shadow style to use for drawing the string
+//      Create the shadow style to use for drawing the string
         shadow.version    = 0;
         shadow.elevation  = shadowElevation;
         shadow.azimuth    = shadowAzimuth;
@@ -73,7 +73,7 @@
     }
     
     // Draw the string
-    [super drawInteriorWithFrame:rect inView:controlView];
+    [super drawWithFrame:rect inView:controlView];
     
 
     if ( castsShadow ) { 
index 1bd81ea..0cc1118 100755 (executable)
@@ -13,6 +13,9 @@
     IBOutlet NSButton *useInvertedCheckBox;
     IBOutlet NSButton *showTitleCheckBox;
     
+    // ITButton Support
+    IBOutlet ITButton *button;
+    
     // ITTabView Support
     IBOutlet ITTabView *tabView;
 
index 71463aa..b23d06f 100755 (executable)
 - (void)awakeFromNib
 {
     [self createStatusItem];
+    [button setBezelStyle:1001];
+    [button setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:14]];
+    [button setTitle:@"Launch Manually"];
+    [button setButtonType:NSMomentaryLight];
+    [button sizeToFit];
+    [button setFrameSize:NSMakeSize([button frame].size.width + 8, 24)];
     [testTextField setCastsShadow:YES];
     [tabView setAllowsDragging:YES];
     [bevelView setBevelDepth:10];
     [bevelView setBevelDepth:[sender intValue]];
 }
 
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITButton SUPPORT
+/*************************************************************************/
+
+
 /*************************************************************************/
 #pragma mark -
 #pragma mark NSWindow DELEGATE METHODS
index c1ffceb..37fb827 100755 (executable)
@@ -21,6 +21,7 @@
             LANGUAGE = ObjC; 
             OUTLETS = {
                 bevelView = ITBevelView; 
+                button = ITButton; 
                 showImageCheckBox = NSButton; 
                 showStatusItemCheckBox = NSButton; 
                 showTitleCheckBox = NSButton; 
         }, 
         {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
         {CLASS = ITBevelView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, 
+        {CLASS = ITButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; }, 
+        {CLASS = ITButtonCell; LANGUAGE = ObjC; SUPERCLASS = NSButtonCell; }, 
         {CLASS = ITLED; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, 
         {CLASS = ITLEDCell; LANGUAGE = ObjC; SUPERCLASS = NSActionCell; }, 
         {CLASS = ITTabView; LANGUAGE = ObjC; SUPERCLASS = NSTabView; }, 
-        {CLASS = ITTextField; LANGUAGE = ObjC; SUPERCLASS = NSTextField; }
+        {CLASS = ITTextField; LANGUAGE = ObjC; SUPERCLASS = NSTextField; }, 
+        {CLASS = ITTextFieldCell; LANGUAGE = ObjC; SUPERCLASS = NSTextFieldCell; }
     ); 
     IBVersion = 1; 
 }
\ No newline at end of file
index 206ddc1..e3e4173 100755 (executable)
@@ -15,7 +15,6 @@
        <string>286.0</string>
        <key>IBOpenObjects</key>
        <array>
-               <integer>29</integer>
                <integer>21</integer>
        </array>
        <key>IBSystem Version</key>
index e339f7a..944ea80 100755 (executable)
Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ