Professional Web Applications Themes

SetGWorld - Mac Programming

I've never really been clear as to what I should pass as the GDHandle parameter of SetGWorld. I want to make a function which will draw into a given CGrafPtr. However, the given CGrafPtr could be either an off-screen GWorld, or a window's port. When the CGrafPtr is an off-screen GWorld, I pass NULL for the GDevice. But when it's a window's port (taken from GetWindowPort), I'm not clear as to what I should pass for the GDevice in SetGWorld. Any clarification would be appreciated. Thanks. I know I could call SetPortWindowPort(myWindow) if I want to draw into a window, ...

  1. #1

    Default SetGWorld

    I've never really been clear as to what I should pass as the GDHandle
    parameter of SetGWorld.


    I want to make a function which will draw into a given CGrafPtr.

    However, the given CGrafPtr could be either an off-screen GWorld, or a
    window's port.

    When the CGrafPtr is an off-screen GWorld, I pass NULL for the GDevice.

    But when it's a window's port (taken from GetWindowPort), I'm not clear
    as to what I should pass for the GDevice in SetGWorld.

    Any clarification would be appreciated.
    Thanks.


    I know I could call SetPortWindowPort(myWindow) if I want to draw into a
    window, but I want this function to be general enough to draw either
    into a window or an off-screen GWorld.

    --
    com http://www3.mb.sympatico.ca/~gbeggs1/
    Gerry Guest

  2. #2

    Default Re: SetGWorld

    In article <1g2snj7.1yj9v8hbngfjeN%com>,
    com (Gerry) wrote:
     

    Long story short: pass NULL, except when restoring. Always save/restore
    both values.

    If you pass NULL for the GDHandle, then one of two things happens:
    1) if the port parameter is an offscreen, then the GDDevice associated
    with that offscreen is used
    2) if the port parameter is an on-screen port, then the current
    GDDevice of the system is used.

    In either case, this is the correct thing to do. Except when creating
    your own GDevices (which just about nobody does any more), you should
    just pass NULL for the 2nd parameter.
    Tom Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139