• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Brain Fade with NSView layout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Brain Fade with NSView layout


  • Subject: Re: Brain Fade with NSView layout
  • From: John Anderson <email@hidden>
  • Date: Fri, 27 Sep 2002 16:28:25 -0700

Oh, ok, I misunderstood what you were attempting to do.

I did something similar to this before, and created a separate nib file for each type of view you might want to add (an added bonus: I put these nib files in bundles, so that the app can be extended). Load the owner of the nib, and have the owner automatically load the nib when it's inited. Then make an accessor method in the owner class to access an instance variable that you connect to the view in Interface Builder. That way you can do most of your UI work in Interface Builder, and then just add the subviews to your main view and arrange them as necessary.

-j.


On Friday, September 27, 2002, at 03:41 PM, Greg Hulands wrote:

How would this be achieved? It creates it so that each "cell" is below the next one. It is in a scroll view so that there can be an infinite number of properties that can get inspected. This is not your standard macosx inspector, it is more like what real basic has.

Greg
On Saturday, September 28, 2002, at 02:34 AM, John Anderson wrote:

Why subclass an NSView for this purpose at all? You can accomplish the same thing by creating a tabbed panel with invisible tabs in IB. Then you don't have to programatically create your UI at all; just switch tabs.

John Anderson


On Friday, September 27, 2002, at 07:46 AM, Greg Hulands wrote:

Hi,
I seem to be suffering from Friday night brain fade. I have been trying
for the last 4 hours to get this layout to be correct. I have a
Subclassed NSView that is an inspector view that autogenerates the view
depending on the object it is inspecting. The object returns an array
of dictionaries that provides the inspector view the information it
needs to generate the subviews. Depending on the type the attribute is
(NSString, NSColor, etc) it will create a "cell" as it were (not a
subclass of NSCell rather NSView) that allows the attribute to be
changed.

The method that sets all this up is as follows:
- (void)setupInspector
{
int i;
NSEnumerator *g = [[self subviews] objectEnumerator];
id curView;
while (curView = [g nextObject])
[curView removeFromSuperview];

if (![_inspectingObject
conformsToProtocol:@protocol(TADesignInspection)])
return;

NSRect size = NSMakeRect(NSMinX([self frame]), NSMinY([self
frame]), NSWidth([self frame]), [[_inspectingObject
inspectionProperties] count] * TAInspectorCellHeight);
[self setFrame:size];

int e = [[_inspectingObject inspectionProperties] count];
NSDictionary *cur;
float w = NSWidth([self bounds]);

for (i = 0; i < e; i++)
{
cur = [[_inspectingObject inspectionProperties]
objectAtIndex:i];
NSString *classStr = [cur
objectForKey:TADesignInspectionClassKey];
NSRect r = NSMakeRect(0, (i * TAInspectorCellHeight), w,
TAInspectorCellHeight);
TAInspectorCell *cell;

if ([classStr isEqualToString:TADesignClassInt])
{
cell = [[TAInspectorIntCell alloc] initWithFrame:r];
}
else if ([classStr isEqualToString:TADesignClassFloat])
{
cell = [[TAInspectorFloatCell alloc] initWithFrame:r];
}
....
....
else
{
NSLog(@"Unkown inspector type: %@", classStr);
return;
}
[cell setAttribute:[cur
objectForKey:TADesignInspectionNameKey]];
[cell setTarget:_inspectingObject];
[cell setGetSelector:NSSelectorFromString([cur
objectForKey:TADesignInspectionGetSelectorKey])];
[cell setSetSelector:NSSelectorFromString([cur
objectForKey:TADesignInspectionSetSelectorKey])];
[self addSubview:cell];
[cell release];
}
}

The problem is that it is only displaying the first "cell" and no
others. I have checked the frames of all the subviews which are
correct, yet it does not display them. When setting the frame for the
cell to be (0,0, w, TAInspectorCellHeight) it will display all the
cells over the top of each other (which one would expect), yet when it
is set to be what it is in the code above, it does not display them.
It is so frustrating as it must be such a simple thing yet the Friday
night brain fade has set in and is clouding my judgement. Damn you
Johnny Walker and Jim Beam!

Any help is greatly appreciated,

Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Brain Fade with NSView layout (From: Greg Hulands <email@hidden>)

  • Prev by Date: TableView Jaguar Compile Problem
  • Next by Date: AddressBook: getting "address format"
  • Previous by thread: Re: Brain Fade with NSView layout
  • Next by thread: Note: Delegates vs notifications quirk -- {addObserver,setDelegate} != {setDelegate,addObserver}
  • Index(es):
    • Date
    • Thread