Created
January 26, 2009 00:33
-
-
Save lsinger/52634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <Foundation/CPObject.j> | |
@implementation AccountBarView : CPView | |
{ | |
CPSecureTextField passwordField; | |
CPTextField usernameField; | |
} | |
- (id)initWithFrame:(CGRect)aFrame | |
{ | |
self = [super initWithFrame: aFrame]; | |
if (self) | |
{ | |
[self setBackgroundColor: [CPColor colorWithHexString:@"666"]]; | |
[self setAutoresizingMask: CPViewWidthSizable]; | |
//[self setAutoresizingMask: CPViewMinXMargin | CPViewMaxXMargin]; // to make it stick to the right edge, tell it to let CPViewMinXMargin (left) be flexible | |
var bounds = [self bounds]; | |
// create input fields for username and password | |
usernameField = [[CPTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-340,10,100,21)]; | |
[usernameField setBezeled: YES]; | |
//[usernameField setBordered: YES]; // what is bordered supposed to do? | |
[usernameField setEditable: YES]; | |
[usernameField setBezelStyle: CPTextFieldSquareBezel]; | |
[usernameField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]]; | |
[usernameField setAutoresizingMask: CPViewMinXMargin]; | |
[self addSubview: usernameField]; | |
passwordField = [[CPSecureTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-220,10,100,21)]; | |
[passwordField setBezeled: YES]; | |
[passwordField setEditable: YES]; | |
[passwordField setBezelStyle: CPTextFieldSquareBezel]; | |
[passwordField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]]; | |
[passwordField setAutoresizingMask: CPViewMinXMargin]; | |
[self addSubview: passwordField]; | |
// add submit button | |
var submit = [[CPButton alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-100,12,60,18)]; | |
[submit setBezelStyle: CPRoundRectBezelStyle]; | |
[submit setTitle: @"Log in"]; | |
[submit setAutoresizingMask: CPViewMinXMargin]; | |
[submit setTarget: self]; | |
[submit setAction: @selector(credentialsSubmitted)]; | |
[self addSubview: submit]; | |
// add logo | |
var logo = [[CPImage alloc] initWithContentsOfFile: @"Resources/Logo.png" size: CPSizeMake(174, 36)]; | |
var logoView = [[CPImageView alloc] initWithFrame: CGRectMake(10,2,174,36)]; | |
[logoView setAutoresizingMask: CPViewMaxXMargin]; | |
[logoView setImage: logo]; | |
[self addSubview: logoView]; | |
} | |
return self; | |
} | |
- (void)credentialsSubmitted | |
{ | |
var username = [usernameField stringValue]; | |
var password = [passwordField stringValue]; | |
CPLog(@"username: %@, password: %@", username, password); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment