Ask a Question related to Mac Programming, Design and Development.
-
C Lund #1
Drawing in the right window (and not in the panel)
I'm working on an app that starts with one panel open, and no windows.
The panel resides in the Nib file, while the windows are created by code.
In the header:
IBOutlet NSWindow *controlPanel; //this panel is tagged as a utility
panel
NSRect contentRect;
NSWindow *fontWindow;
FontMatrix *fontView;
And the method that creates the window is:
contentRect.origin.x = 40;
contentRect.origin.y = 400;
contentRect.size.height = 128;
contentRect.size.width = 128;
fontWindow = [[NSWindow alloc] initWithContentRect: contentRect
styleMask: NSTitledWindowMask
backing: NSBackingStoreBuffered
defer: NO];
[fontWindow setTitle:@"128x128"];
[fontWindow orderFrontRegardless]; //the window won't show without
this
fontView = [[FontMatrix alloc] initWithFrame:[fontWindow frame]];
[fontView drawRect:[fontView bounds]]; //all drawRect is supposed to
do is color the view black.
What the app is supposed to do is start with the control panel open and
no visible windows. Menu selections should open windows and fill them
with whatever I feel like putting in drawRect.
What happens is that selecting a menu item only gives me an empty
window. If I click on the window, a portion of the panel corresponding
to the size of the window goes black.
What's wrong is:
1) I have to click on the new before any drawing takes place.
2) The drawing takes place in the panel instead of the window.
Any idea what I'm doing wrong?
--
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
Combine Spry Tabbed Panel and Spry HTML Panel
I would like to maintain the presentation of the tabbed panel and utilize its ability to load content from a Spry Dataset, but I would also like to... -
hide and slide the panel out of window
Hi, I try to create a panel which has a handler that slides open the panel from the right edge of the window when clicked and slide hide the... -
Child window property window.opener null after postback
I have an webform from which I open a child window to display a calendar. When a date is selected in the calendar window it attempts to set the... -
Drawing in Flex? Drawing and AS for custom compon
Hey Peter, I just went to your site to check out your flex prototypes. They're pretty nice. I'm currently looking into developing something... -
dlopen is failing on Window XP works great on Window 2000
Michael Davis <mdavis@sevasoftware.com> writes: Check the permission of the so file: $ ls -l... -
matt neuburg #2
Re: Drawing in the right window (and not in the panel)
In <clund-B256AC.21390203082003@amstwist00.chello.com> C Lund wrote:
How to draw in a window: In PB, make an NSView subclass. Drag the header> contentRect.origin.x = 40;
> contentRect.origin.y = 400;
> contentRect.size.height = 128;
> contentRect.size.width = 128;
>
> fontWindow = [[NSWindow alloc] initWithContentRect: contentRect
> styleMask: NSTitledWindowMask
> backing: NSBackingStoreBuffered
> defer: NO];
> [fontWindow setTitle:@"128x128"];
> [fontWindow orderFrontRegardless]; //the window won't show without
> this
> fontView = [[FontMatrix alloc] initWithFrame:[fontWindow frame]];
>
> [fontView drawRect:[fontView bounds]];
file into IB. In IB, make a custom NSView and drag it into a window. Set
its class to the NSView subclass. Do your drawing in the NSView
subclass's drawRect override. m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest
-
John C. Randolph #3
Re: Drawing in the right window (and not in the panel)
C Lund wrote:
In order:>
> I'm working on an app that starts with one panel open, and no windows.
> The panel resides in the Nib file, while the windows are created by code.
>
> In the header:
>
> IBOutlet NSWindow *controlPanel; //this panel is tagged as a utility
> panel
> NSRect contentRect;
> NSWindow *fontWindow;
> FontMatrix *fontView;
>
> And the method that creates the window is:
>
> contentRect.origin.x = 40;
> contentRect.origin.y = 400;
> contentRect.size.height = 128;
> contentRect.size.width = 128;
>
> fontWindow = [[NSWindow alloc] initWithContentRect: contentRect
> styleMask: NSTitledWindowMask
> backing: NSBackingStoreBuffered
> defer: NO];
> [fontWindow setTitle:@"128x128"];
> [fontWindow orderFrontRegardless]; //the window won't show without
> this
> fontView = [[FontMatrix alloc] initWithFrame:[fontWindow frame]];
>
> [fontView drawRect:[fontView bounds]]; //all drawRect is supposed to
> do is color the view black.
>
> What the app is supposed to do is start with the control panel open and
> no visible windows. Menu selections should open windows and fill them
> with whatever I feel like putting in drawRect.
>
> What happens is that selecting a menu item only gives me an empty
> window. If I click on the window, a portion of the panel corresponding
> to the size of the window goes black.
>
> What's wrong is:
>
> 1) I have to click on the new before any drawing takes place.
> 2) The drawing takes place in the panel instead of the window.
>
> Any idea what I'm doing wrong?
1) I don't see you putting the fontView into the fontWindow. See
-setContentView: and -addSubView: in the NSWindow documentation.
2) You're building a window and a view programmatically, instead of
just creating them in the Interface Builder, like any other Cocoa
developer would.
Is there some reason why you want to do this the hard way?
-jcr
John C. Randolph Guest
-
C Lund #4
Re: Drawing in the right window (and not in the panel)
In article <3F2DFE4D.8D2EEC80@nospam.idiom.com>,
"John C. Randolph" <jcr@nospam.idiom.com> wrote:
>> > What's wrong is:
> >
> > 1) I have to click on the new before any drawing takes place.
> > 2) The drawing takes place in the panel instead of the window.> > Any idea what I'm doing wrong?> In order:> 1) I don't see you putting the fontView into the fontWindow. See
> -setContentView: and -addSubView: in the NSWindow documentation.> 2) You're building a window and a view programmatically, instead of
> just creating them in the Interface Builder, like any other Cocoa
> developer would.I want the window+view to be resizeable via the menu. However, I forgot> Is there some reason why you want to do this the hard way?
about the setFrame:display method so I tried doing it programmatically.
Having fixed that, I now have a window+view in the Nib file that resizes
arbitrarily via the menu plus a panel for the controls, and the app
draws to the view without having to click in the frame. That solves #1.
However; #2 is still a problem since the drawing now takes place not
only where intended, but also in the area around the buttons and sliders
and so on in the panel.
--> -jcr
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
Raleigh Ledet #5
Re: Drawing in the right window (and not in the panel)
In article <clund-8A6CA2.10125204082003@amstwist00.chello.com>, C Lund
<clund@NOSPAMnotam02.no> wrote:
You where manually calling drawRect if I recall correctly. drawRect> In article <clund-A9EFD8.09444004082003@amstwist00.chello.com>,
> C Lund <clund@NOSPAMnotam02.no> wrote:
>>> > However; #2 is still a problem since the drawing now takes place not
> > only where intended, but also in the area around the buttons and sliders
> > and so on in the panel.
> Turns out this was caused by a superfluous drawRect call. Problem
> solved. B)
>
> (wonder why that caused stuff to be drawn in the wrong window though)
assumes that the proper CGContext, grafPort, etc... drawable port is set
and locked in place. You where not handeling the setup required by
drawRect.
The easiest thing to do is call [myView setNeedsDisplay:YES]; on the view
you want to call DrawRect on. If you are not in some special loop,
drawRect will be called for you on the normal event chain. Usually, this
is fast enough. UMMV.
-raleigh
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
[url]http://www.newsfeeds.com[/url] - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
Raleigh Ledet Guest
-
matt neuburg #6
Re: Drawing in the right window (and not in the panel)
In <blackgold-0408031510540001@rledet.wacom.com> Raleigh Ledet wrote:
And that is why I said to use the drawRect inside the NSView subclass.> In article <clund-8A6CA2.10125204082003@amstwist00.chello.com>, C Lund
> <clund@NOSPAMnotam02.no> wrote:
>
> You where manually calling drawRect if I recall correctly. drawRect
> assumes that the proper CGContext, grafPort, etc... drawable port is
> set and locked in place. You where not handeling the setup required by
> drawRect.
That way you are guaranteed that everything is ready for you to draw
right here, in this NSView. m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest
-
John C. Randolph #7
Re: Drawing in the right window (and not in the panel)
C Lund wrote:
You shouldn't need to call -drawRect: yourself at all. When you know>
> In article <clund-A9EFD8.09444004082003@amstwist00.chello.com>,
> C Lund <clund@NOSPAMnotam02.no> wrote:
>>> > However; #2 is still a problem since the drawing now takes place not
> > only where intended, but also in the area around the buttons and sliders
> > and so on in the panel.
> Turns out this was caused by a superfluous drawRect call. Problem
> solved. B)
>
> (wonder why that caused stuff to be drawn in the wrong window though)
that a view needs updating, call -setNeedsDisplay: or
-setNeedsDisplayInRect:, and let the framework take care of sending
-drawRect: messages to the view hierarchy.
-jcr
John C. Randolph Guest



Reply With Quote

