Xojo Conferences
XDCMay2019MiamiUSA

[OT - maybe] macoslib and MacIcon (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Cairo, anyone? (was Re: graphics in console apps?)
Next thread: Database Blob Document Edit?


FolderItem--IsReadable   -   Claude Stone
  [OT - maybe] macoslib and MacIcon   -   robl no-no-badpuppy.com
   Re: [OT - maybe] macoslib and MacIcon   -   Charles Yeomans
    Re: [OT - maybe] macoslib and MacIcon   -   robl no-no-badpuppy.com

[OT - maybe] macoslib and MacIcon
Date: 29.07.08 22:02 (Tue, 29 Jul 2008 17:02:44 -0400)
From: robl no-no-badpuppy.com
I am noticing something a little odd, and I wondering if someone using MacOSLib (the Carbon wrappers library for RB) has some helpful advice.

Specifically, when using MacIcon's Draw() method, it seems to only work in the Window's paint event. If I try to get it to paint within say a canvas's paint event, it draws nothing.

Easy to reproduce by creating a new Desktop Application, adding macoslib and add the following to window1:

Window1.Paint:
Sub Paint(g As Graphics)
if self.Icon <> nil then
self.Icon.Size = 128
self.Icon.Draw(g, 50, 50)
end if
End Sub

Private Icon As MacIcon

Window1 Control BevelButton1:
Sub Action()
self.Icon = MacIcon.NewIconFromExtension("doc")
self.Refresh
End Sub

Window1 Control Canvas1:
Sub Paint(g As Graphics)
if self.icon <> Nil Then
self.Icon.Size = 128
self.Icon.Draw(g, 0, 0)
end if
End Sub

End Class

Does anyone know how to get the MacIcon class to draw within any control besides a window?

Thanks,
Robert
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: [OT - maybe] macoslib and MacIcon
Date: 29.07.08 22:19 (Tue, 29 Jul 2008 17:19:18 -0400)
From: Charles Yeomans

On Jul 29, 2008, at 5:02 PM, <email address removed> wrote:

> I am noticing something a little odd, and I wondering if someone
> using MacOSLib (the Carbon wrappers library for RB) has some helpful
> advice.
>
> Specifically, when using MacIcon's Draw() method, it seems to only
> work in the Window's paint event. If I try to get it to paint
> within say a canvas's paint event, it draws nothing.
>
> Easy to reproduce by creating a new Desktop Application, adding
> macoslib and add the following to window1:
>
> Window1.Paint:
> Sub Paint(g As Graphics)
> if self.Icon <> nil then
> self.Icon.Size = 128
> self.Icon.Draw(g, 50, 50)
> end if
> End Sub
>
> Private Icon As MacIcon
>
> Window1 Control BevelButton1:
> Sub Action()
> self.Icon = MacIcon.NewIconFromExtension("doc")
> self.Refresh
> End Sub
>
> Window1 Control Canvas1:
> Sub Paint(g As Graphics)
> if self.icon <> Nil Then
> self.Icon.Size = 128
> self.Icon.Draw(g, 0, 0)
> end if
> End Sub
>
> End Class
>
> Does anyone know how to get the MacIcon class to draw within any
> control besides a window?

I do. The coordinates you pass to Draw are assumed to be relative to
the window. In Canvas.Paint, try

icon.Draw g, me.Left + X, me.Top + Y

Alternatively, try

g.DrawPicture icon, X, Y

The effect of this is to invoke MacIcon.Operator_Convert to get a
Picture object, then the Picture is drawn. There may be some masking
issues with that approach.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: [OT - maybe] macoslib and MacIcon
Date: 29.07.08 23:39 (Tue, 29 Jul 2008 18:39:39 -0400)
From: robl no-no-badpuppy.com


On 7/29/08 4:19 PM, "Charles Yeomans" <<email address removed>> wrote:

>
> Does anyone know how to get the MacIcon class to draw within any
> control besides a window?

I do. The coordinates you pass to Draw are assumed to be relative to
the window. In Canvas.Paint, try

icon.Draw g, me.Left + X, me.Top + Y

Alternatively, try

g.DrawPicture icon, X, Y

The effect of this is to invoke MacIcon.Operator_Convert to get a
Picture object, then the Picture is drawn. There may be some masking
issues with that approach.

Charles:

You are the man!!

Thanks!! Worked perfectly! I kept thinking the coordinates were relative to the control (i.e. Canvas).

Robert
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>