Guest User

Untitled

a guest
Feb 28th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. @import <Foundation/CPObject.j>
  2.  
  3.  
  4. @implementation AccountBarView : CPView
  5. {
  6. CPSecureTextField passwordField;
  7. CPTextField usernameField;
  8. }
  9.  
  10. - (id)initWithFrame:(CGRect)aFrame
  11. {
  12. self = [super initWithFrame: aFrame];
  13.  
  14. if (self)
  15. {
  16. [self setBackgroundColor: [CPColor colorWithHexString:@"666"]];
  17. [self setAutoresizingMask: CPViewWidthSizable];
  18. //[self setAutoresizingMask: CPViewMinXMargin | CPViewMaxXMargin]; // to make it stick to the right edge, tell it to let CPViewMinXMargin (left) be flexible
  19.  
  20. var bounds = [self bounds];
  21.  
  22. // create input fields for username and password
  23. usernameField = [[CPTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-340,10,100,21)];
  24. [usernameField setBezeled: YES];
  25. //[usernameField setBordered: YES]; // what is bordered supposed to do?
  26. [usernameField setEditable: YES];
  27. [usernameField setBezelStyle: CPTextFieldSquareBezel];
  28. [usernameField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]];
  29. [usernameField setAutoresizingMask: CPViewMinXMargin];
  30. [self addSubview: usernameField];
  31.  
  32. passwordField = [[CPSecureTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-220,10,100,21)];
  33. [passwordField setBezeled: YES];
  34. [passwordField setEditable: YES];
  35. [passwordField setBezelStyle: CPTextFieldSquareBezel];
  36. [passwordField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]];
  37. [passwordField setAutoresizingMask: CPViewMinXMargin];
  38. [self addSubview: passwordField];
  39.  
  40. // add submit button
  41. var submit = [[CPButton alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-100,12,60,18)];
  42. [submit setBezelStyle: CPRoundRectBezelStyle];
  43. [submit setTitle: @"Log in"];
  44. [submit setAutoresizingMask: CPViewMinXMargin];
  45. [submit setTarget: self];
  46. [submit setAction: @selector(credentialsSubmitted)];
  47. [self addSubview: submit];
  48.  
  49. // add logo
  50. var logo = [[CPImage alloc] initWithContentsOfFile: @"Resources/Logo.png" size: CPSizeMake(174, 36)];
  51. var logoView = [[CPImageView alloc] initWithFrame: CGRectMake(10,2,174,36)];
  52. [logoView setAutoresizingMask: CPViewMaxXMargin];
  53. [logoView setImage: logo];
  54. [self addSubview: logoView];
  55. }
  56. return self;
  57. }
  58.  
  59. - (void)credentialsSubmitted
  60. {
  61. var username = [usernameField stringValue];
  62. var password = [passwordField stringValue];
  63. CPLog(@"username: %@, password: %@", username, password);
  64. }
Add Comment
Please, Sign In to add comment