[Drawkit] From "Bypassing Interface builder"
Graham Cox
graham.cox at bigpond.com
Wed May 14 18:38:28 PDT 2008
Hi, welcome to the DK list.
First off, I'm about to release beta 3 (I'll announce it properly when
I'm done). It includes the first draft of the documentation - still
just an overview at this stage and with no illustrations but it might
help. Right now it's in Omni Outliner 3 format, which might be a
problem for some, though note that this app was part of the consumer
Mac software bundle a while ago, it may still be.
Seems to me that a lot of people could use a way to deploy DK to the
point where they can get it to draw *something* starting from scratch.
What I'd suggest is this:
1. use IB to set up a DKDrawingView instance. This doesn't need to be
inside an NSScrollView but it might be better when you get further
along if it is. This view can be in
the window that's part of MainMenu.nib when you start a non-document
based project for example. That's likely to be the easiest to start
with.
2. let DK instantiate the entire drawing structure automatically using
the DKDrawingView. You can tell if it's working because you'll see the
grid (looks like graph paper) in the view when you run it. If you
click and drag in the view, you should see the selection rectangle
(will be a transparent rect having a colour based on your system
preference for highlight colour). Because the drawing's size is based
on the view's bounds at this point, it's a good idea to make sure you
didn't make it too small in IB.
3. The next thing is to select a drawing tool to create an object
instead of the selection tool. A standard set of drawing tools (Rects,
Ovals and so on) are already set up by DK, you just need to pick one
of them. To do this without writing any code, one very easy way is to
add a menu (call it "Tools" say) to the menu bar and name each item to
be the same as the tool's name. These are:
Rectangle
Round Rectangle
Round End Rectangle
Oval
Ring
Text
Path
Line
Polygon
Freehand
Arc
Wedge
Speech Balloon
Select
You are not required to add all of them - just any you want. Case and
spaces matter. Then add the action method selectDrawingToolByName: to
first responder. Connect each menu item to first responder with this
action method.
At run time, choosing the item in the menu should select the tool -
click and drag in the view to create new objects of the chosen kind.
They'll all have the default style (light gray fill, black stroke) but
you should be able to create as many as you want, and going back to
the Select tool, select, move, resize and rotate them. By the way, in
beta 3, you are able to assign key equivalents to the drawing tools,
so it will be even easier there - just type the letter 'r' to select
the Rectangle tool for example.
At this stage you should have started to feel confident that DK is
working!
Next you might want to explore how it does its thing, using the
debugger. To do this, first ensure you are building a debug version,
otherwise you won't have the symbols in the code needed to see what's
going on. You might then set a breakpoint on the view's mouseDown:
method, for example, then step down through the code to see where it
goes. This should start to give you a bit of insight into how stuff
gets drawn and what objects are involved.
Good luck - do ask on the list for any help you need.
G.
On 15 May 2008, at 11:07 am, colo wrote:
> I will make it known that I do not know enough to save me in this
> Cocoa Whirlpool.
> So asking stupid questions like what's an instance will not come up. I
> know that much at least :P
>
> My only current focus is to mash together enough of an app that I can
> see how the view is created, calls the Drawkit
> and allows a draw able box on the view. From that I will have a basis
> to plug into F-script and go from there.
>
> I'm not asking for anything. I won't refuse examples though. I am
> mearly posting to see if I can gather ideas, and patiently await any
> documentation.
> Otherwise back to my books and i'll see where I get in a week from
> now.
>
> I hope this message plays well and does not sound like I am expecting
> anything. I am grateful that the whole Drawkit exists in the first
> place.
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list