Skip to content

Instantly share code, notes, and snippets.

@nickjs
Created November 14, 2008 10:26
Show Gist options
  • Save nickjs/24853 to your computer and use it in GitHub Desktop.
Save nickjs/24853 to your computer and use it in GitHub Desktop.
- (void)openEditor:(id)sender
{
if(!_panel)
{
_panel = [[CPPanel alloc] initWithContentRect:CGRectMake(0,0,300,270) styleMask:CPHUDBackgroundWindowMask | CPClosableWindowMask | CPResizableWindowMask];
[_panel setFloatingPanel:YES];
[_panel center];
[_panel setTitle:@"Contact Info"];
var view = [_panel contentView],
bounds = [view bounds];
var label = [[CPTextField alloc] initWithFrame:CGRectMake(0,10,90,22)];
[label setTextColor:[CPColor whiteColor]];
[label setHasShadow:YES];
[label setFont:[CPFont boldSystemFontOfSize:14.0]];
[label setAlignment:CPRightTextAlignment];
label = [CPKeyedArchiver archivedDataWithRootObject:label];
var field = [[CPTextField alloc] initWithFrame:CGRectMake(100,10,165,22)];
[field setEditable:YES]; [field setSelectable:YES];
[field setBordered:YES]; [field setBezeled:YES];
[field setBezelStyle:CPTextFieldSquareBezel];
field = [CPKeyedArchiver archivedDataWithRootObject:field];
_phoneField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
_emailField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
_addressField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
_cityField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
_stateField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
_zipField = [CPKeyedUnarchiver unarchiveObjectWithData:field];
var fields = [_phoneField,_emailField,_addressField,_cityField,_stateField,_zipField];
var labels = ["phone","email","address","city","state","zip"];
for(var i=0; i < [fields count]; i++)
{
var _label = [CPKeyedUnarchiver unarchiveObjectWithData:label];
[_label setFrameOrigin:CGPointMake(0,10+30*i)];
[_label setStringValue:labels[i]];
[view addSubview:_label];
var _field = fields[i];
[_field setFrameOrigin:CGPointMake(100,10+30*i)];
// [_field setFrameOrigin:CGPointMake([field frame].origin.x,30*i)];
[view addSubview:_field];
}
var submit = [[CPButton alloc] initWithFrame:CGRectMake(15,bounds.size.height-30,75,20)];
[submit setBezelStyle:CPHUDBezelStyle];
[submit setTitle:LEL.submit];
[submit setTarget:self];
[submit setAction:@selector(submitData:)];
[view addSubview:submit];
_showsMap = [[CheckboxButton alloc] initWithFrame:CGRectMake(100,bounds.size.height-30,100,20)];
[_showsMap setTitle:@"Show Map?"];
[_showsMap setTextColor:[CPColor whiteColor]];
[view addSubview:_showsMap];
}
[_phoneField setStringValue:[_data objectForKey:@"phone"]];
[_emailField setStringValue:[_data objectForKey:@"email"]];
[_addressField setStringValue:[_data objectForKey:@"address"]];
[_cityField setStringValue:[_data objectForKey:@"city"]];
[_stateField setStringValue:[_data objectForKey:@"state"]];
[_zipField setStringValue:[_data objectForKey:@"zip"]];
[_showsMap setChecked:[_preferences objectForKey:@"showsMap"]];
[_panel orderFront:self];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment