Canvas>>origin:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Canvas>>origin:

Bill Schwab
Blair,

Digging though my loose methods, I ran across my dusty old
#setViewportOrigin:, complete with comment to use #origin:.  The two look
similar, except that I have a test on the return value.  Is there a
performance and/or "it's never gonna happen" argument against such a test?

I won't defend what I did (return nil vs. throw an exception), but, I think
#origin: probably should look at the return value.

Have a good one,

Bill



!Canvas methodsFor!

setViewportOrigin:aPoint
 "Move the origin from its current location to the indicated point,
answering
 the previous origin, or nil on error."

  | oldPoint |

 #wksSafe.
 #deprecated. "Use Canvas>>origin: instead!!"
 oldPoint := POINTL new.

 ^( GDILibrary default setViewportOrgEx:self asParameter X:aPoint x Y:aPoint
y lpPoint:oldPoint )
  ifTrue:[ oldPoint asPoint ]
  ifFalse:[ nil ]! !
!Canvas categoriesFor:
#setViewportOrigin:!*-deprecated!*-unclassified!public! !

!Canvas methodsFor!

origin: aPoint
 "Sets the origin offset for drawing within the receiver to
 be aPoint. Answers the previous origin"

 | previous |
 previous := POINTL new.
 GDILibrary default
  setViewportOrgEx: self asParameter nXOrg: aPoint x nYOrg: aPoint y lppt:
previous asParameter.
 ^previous asPoint
! !
!Canvas categoriesFor: #origin:!operations!public! !



--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Canvas>>origin:

Blair McGlashan
"Bill Schwab" <[hidden email]> wrote in message
news:[hidden email]...
> Blair,
>
> Digging though my loose methods, I ran across my dusty old
> #setViewportOrigin:, complete with comment to use #origin:.  The two look
> similar, except that I have a test on the return value.  Is there a
> performance and/or "it's never gonna happen" argument against such a test?
>
> I won't defend what I did (return nil vs. throw an exception), but, I
think
> #origin: probably should look at the return value.

True, #648.

BTW: #origin: has been deprecated. You should use #viewportOrigin: (and
#viewportExtent:).

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Canvas>>origin:

Bill Schwab-2
Hi Blair,

> BTW: #origin: has been deprecated. You should use #viewportOrigin: (and
> #viewportExtent:).

Sounds good.  It's not marked as deprecated though, at least not in beta 2.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]