Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Working With Bitmap Images; Document-Based Application Redux
Subject:   Some changes
Date:   2002-04-27 17:00:43
From:   michele
I've made some changes to avoid warnings at compile time, improve image scaling, and avoid memory leaks.


I - To avoid warning at compile time:


1 - Warning: IAWindoController does not respond to scaleImageTo


Added in IAWindowController.h the declaration of:


- (void)scaleImageTo:(float)_scale;



2 - Warnings: cannot find method
return type for 'activeImage' defaults to id


Added in IAWindowController.m:


#import "MyDocument.h"



II - To avoid incorrect redrawing of image when scaling (image drawn over scrollers)


1 - Change in (void) scaleFrameBy: (float) scale in IAImageView.m


Replace: [self setNeedsDisplay: YES];
by: [[[self window] contentView] displayIfNeededIgnoringOpacity];


As the scrollers are opaque, we need to force a complete redraw.


2 - Add in (void) validateScrollers in IAImageView.m


at the very end: [scrollView tile];


Forces a redraw of scrollView, clipView, scrollers, and ImageView taking into account the opacity (does not redraw the opaque parts).



III - To avoid memory leaks


1 - Add


[windowController release];


at the end of - (void)makeWindowControllers in MyDocumemt.h


2 - Change - (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType in MyDocument.h


- (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType
{
activeImage = [[[NSImage alloc] initWithData: data] autorelease];
return (activeImage != nil);
}

Full Threads Oldest First

Showing messages 1 through 8 of 8.

  • Some changes
    2002-07-14 12:04:04  blukens [View]

    My solution to the poorly drawn scroll bars was to just change
    [self setNeedsDisplay: YES];
    to
    [[[self superview] superview] setNeedsDisplay:YES];

    The problem we had was that the original line just refreshes the imageview, so the scroll bars are being refreshed and therefore don't go away when they should. The new line sets the entire scrollview to be refreshed, which is exactly what we want.
  • Some changes
    2002-05-02 09:24:31  psheldon [View]

    Sorry I have been out wandering in wierd science and virtual reality and missing communication on this thread.

    I see a neat professional subject line, "some changes". This indicates that you have work group experience in programming I sorely lack. I hope this group emerges professionally.

    In 1 you fulfilled your general check prescription you gave me.
    In 2 I found I had had the savvy to do that too.

    II. 1.

    Wanted to step away from obvious learning by the context of what you said.

    Working hypothesis : "displayIfNeededIgnoringOpacity" method might need some interesting knowledge navigation to track down the description of. I checked that hypothesis and simply put in this word into help viewer and got two hits, one for objective c. Devil's advocate hypothesis, polymorphism requires hit on one word rather than going through chain of types and their methods for uninteresting or inexpensive knowledge navigation.

    There was a link to this in the section but it merely went to the top. Was April's developers cd documentation fixing this? I get T1 system updates through an airport card at Apple Store Willowbend and thought I automatically got developer updates; I now don't think so and will install that cd! There was a notice in May e mail on May mailing about April developer upgrade and I might have to wait to see for sure whether April is in May. Confusing verbage somehow makes sense when you realize that the dating might be by web access, a date delayed in cd publication. Yet, April's cd stated that they had developer tools which I suppose included documentation.

    Ok. I fooled with my version and saw Yoda gif drawn over scrollbars. On windows in mac old os, there are clipping rectangles with redraw avoiding outside the clip rectangles. I suppose the same design metaphor is used in the polymorphism and IgnoringOpacity means to redraw ignoring Opacity which is stated as the clipped parts.

    Now, I put in your phrase. I compiled. It didn't redraw unless I clicked on scrollbar. Putting the [self setNeedsDisplay: YES]; in after your statement made things work right for me. So, I differ in your use of the word "replace" and substituted "augment". In IB, I have "surpressed" the green button on my window and that might be why I must use augment rather than replace, "I dunno".

    I commented out the above hypothesizing that "As the scrollers are opaque, we need to force a complete redraw." was a transitional sentence prefatory to the next II.2. Both the experiments and your words confirmed the new hypothesis. The unfound method's phrase was just to establish clip window but not force a redraw.

    III.1.

    I believe makeWindowControllers thereby has MyDocument surrender ownership of WindowController to the MyDocument instance's list of window controllers. I don't know how to say this better because I don't have enough language experience in objective c.

    III.2 .

    I developed a gesture similar to one I use in Maple to make the change. "[]" before the expression to replace and then shift arrow across that expression, cut, arrow back, paste, space, and then type autorelease. It might be nice to applescript automate this gesture.

    ;-)

    Thanks for the walk through of changes. It made an exercise for me. Off to workout in pool.
    • Some changes
      2002-05-03 12:10:48  michele [View]

      Hello p,

      Wooh, it's very hard for me to understand well what you say. I'm not an English native speaker, so, please, try to use only very basic words, so I can follow your ideas.

      "I see a neat professional subject line, "some changes". This indicates that you have work group experience".

      Just one thirty years ago (yes, 30).

      "Working hypothesis : "displayIfNeededIgnoringOpacity" method might need some interesting knowledge navigation to track down the description of."

      I''ve already told you of an application which you can browse the doc with. It's MarshmallowLibrarian. But since sherlock has been greatly improved with the last OS update and MarshmallowLibrarian tends to crash repeatedly on my computer, I use Sherlock (just drop the developer folder on to the main Sherlock page), index it, and give it an enclosed string to search into documents.

      Another good way to learn efficiently is to browse all the examples (see composite lab and sketch for images). Whenever you find a method you don't know, use find in PB with options frameworks only. You'll get all references to the searched method. Then browse the corresponding doc. There are also shortcuts to do it.

      Another excellent way to learn is to subscribe to Cocoa Apple mailing list. Read, read, read it first, then ask people. And download examples when people give you a link to.


      displayIfNeededIgnoringOpacity is well described in NSView:

      Acts as displayIfNeeded, except that this method doesn't back up to the first opaque ancestor-it simply causes the receiver and its descendants to execute their drawing code.

      The April Developer Tools CD is online now for all ADC members. If you have, as I do, a slow connection, you'd better buy it (20$). It's an about 243 Mb download. I've bought it on April 24th and received it today (I'm in France).

      The main advantage is that you have the whole documentation updated (no need to go to Apple site every two lines of code).

      Michèle

      • Some changes
        2002-05-04 09:15:00  psheldon [View]

        "...use only very basic words, so I can follow your ideas..."

        I've found putting ideas in shorter paragraph can also work to get through language barriers.

        """Just one thirty years ago (yes, 30)...."

        I have been a scholar for 17 years and am afraid the work group has developed while I have learned to work alone not with people. I worry about my choices and other lives I might have lived. I suspect most people's work group experience is "getting along with powerful people". I've had that with my thesis advisor because I gave him power by investing with him my life time. I want another sort of work group experience... Don't know what that could be.

        Please compare sherlock indexing string search to Help Viewer. As soon as I asked this question, I imagined your answer. Help Viewer doesn't have find but an html browser does and probably string search gets you right to the instance of the words.

        MarshmallowLibrarian:

        I downloaded MarshmallowLibrarian, enough documentation on web page, the pictures and comments on this page were reassuring and seemed enough, so I turned web page into pdf file. I used sherlock 2 internet channel to find it.

        "...browse all the examples (see composite lab and sketch for images). "

        I couldn't understand this. By "browse" do you mean use a web browser such as netscape or internet explorer? If that is what you meant by browser, I understood that part. I think I might drag the example folder into sherlock and augment web browser to give meaning to the phrase "browse all the examples" to indexed enclosed string search examples. But, "see composite lab and sketch for images" confuses me still. Maybe sketch is an application and is also "composite lab" an application?

        In making guesses, I ease your language embarrassment. It is easier to read than write a foreign language (at first) and allowing you to answer yes or no will give you great energy, just like that Chinese fellow I asked about nobel level stuff with "do I understand you to mean....".

        "...use find in PB with options frameworks only..."

        I know command 7 finds everything, both my code and frameworks. Now I will look for setting options. Very good.

        "... There are also shortcuts to do it. ..."

        Knowing that something is out there to find is valuable to me. I will go find shortcuts.

        I've long ago subscribed to Cocoa Apple mailing list, but I am a bit scared of it, as yet. I peek at it and Maya list, but shyly work Mike's and Maya's tutorials, so far. I'm not so shy on this thread, though.

        " ... download examples when people give you a link to. ...."

        This gets rid of my shyness a bit. I can play with examples and not be embarrassed I don't know the language.

        "displayIfNeededIgnoringOpacity is well described in NSView"

        And my putting together sherlock indexing and search with enclosed string would buy me not having to look through the huge NSView as Help Viewer would have. Perhaps Apple wishes to force new programmers to read introductions, see their doc organization, and so don't put in a find string or jump to method in Help Viewer.

        The phrase you chose out of NSView seems clear enough. Thank you.

        "April Developer Tools CD ..."

        I get the cd mailing to get perpetually embarrassed that I am often too scared to look at it. My ultimate goal is to get so many cd's that I shall have to learn the respect for hypertext and search strategies you have. I believe that April mailing had general os 9 including tools, but May mailing has os x specific tools. Now, I have more courage to look inside and see.

        Thank you!
        • Some changes
          2002-05-06 13:35:01  michele [View]

          Hello p (what's your first name please, p sounds very mathematical to me),

          By "browse" do you mean use a web browser such as netscape or internet explorer?

          No, excuse me, My English is very basic. I mean, read it thorougly, cut the parts of code you thing you understand and use it in your own application to experiment with.

          Sketch and Composite Lab are code examples from Apple. You find them and a lot more in the Developer folder, Examples, AppKit. The Developer folder is at the first level of your hard disk.

          As for the new PB, try it. You can customize the editors, use gcc 3. And what's unvaluable you have the up-to-date documentation. Personnally, I was at the border of nervous breakdown with the ever mentioned "description forthcoming" each time I needed more details on a method, a class or even a topic.

          Michèle
          • I am Paul, Sherlock 3 of Jaguar multithreaded
            2002-05-07 22:37:00  psheldon [View]

            www.maccentral.com has Jobs keynote saying it has this multithreaded feature like Marshmallow librarian has. I suspect that feature is much more than being able to search while indexing. I'd like Apple to eventually tell me something deeper about that multithreadedness being a good feature.

            I'm going to fool with Marshmallow librarian.

            I think there are general things I don't understand about indexing, whether with sherlock or Marshmallow librarian. Where, for example, is the index saved or is it saved?

            I installed the May 2002 cd mailing mac os x developer tools. There was also a disk with developer tools in April. So, to make an April fools joke, I might be fooled as to which was the April tools. They usually have distinct things in different months and two months of tools is surprising. So, I may really be fooled.

            I copied and recompiled and old project in Applescript and then did the "Variables Inside Cocoa Objects" of 04/12/2002 in the new PB. The readme on the May cd mailing tools said that headers were precompiled and so builds were faster. I think they were.

            Exciting.
            • I am Paul, Sherlock 3 of Jaguar multithreaded
              2003-06-10 16:36:20  anonymous2 [View]

              no i am paul sherlock 3 of jaguar multithreaded

              i will unleash my power on all of you!
            • I am Paul, Sherlock 3 of Jaguar multithreaded
              2002-05-13 03:59:57  michele [View]

              Hello Paul,

              The indexes you create with MarshmallowLibrarian are saved in Users/Library/Application Support/MarshmallowLibrarian/Index. Whenever you launch the application or a saved file, the program loads the indexes.

              As for Sherlock, I think the indexes are encoded into the com.Apple.Sherlock.plist file which is located in Users/Library/Preferences folder.

              Michèle