Platforms to show: All Mac Windows Linux Cross-Platform

/Leopard/IKSlideShow
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Leopard/IKSlideShow
This example is the version from Mon, 9th Nov 2008.
Notes: Last modified: Mon, 9th Nov 2008
Class Window1
Inherits Window
// Controls
ControlInstance
Sub Change() Handles Event
update
End Sub
Sub Open() Handles Event
me.AcceptFileDrop "any"

End Sub
Sub DropObject(obj As DragItem) Handles Event
dim b as Boolean

do
if obj.FolderItemAvailable then
dim f as FolderItem=obj.FolderItem

// save item in the listbox
ListBox1.AddRow f.DisplayName
ListBox1.CellTag(ListBox1.LastIndex,0)=f
ListBox1.Cell(ListBox1.LastIndex,1)="File"

b=true

end if
loop until not obj.NextItem

if b then update


End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim f as FolderItem
dim p as Picture
dim n as NSImageMBS

f=GetOpenFolderItem("any")
if f<>Nil then
// make item from a Realbasic picture
p=f.OpenAsPicture
if p<>Nil then
n=new NSImageMBS(p)
if n.isValid then

// save item in the listbox
ListBox1.AddRow f.DisplayName
ListBox1.CellTag(ListBox1.LastIndex,0)=n
ListBox1.Cell(ListBox1.LastIndex,1)="Picture"
update
else
MsgBox "Failed to make a NSImage."
end if
Else
MsgBox "OpenAsPicture failed on that file."
end if
end if

End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim f as FolderItem
dim page as PDFPageMBS
dim n as PDFDocumentMBS
dim i,c as integer

f=GetOpenFolderItem("any")
if f<>Nil then

n=new PDFDocumentMBS(f)

c=n.pageCount-1
for i=0 to c
page=n.pageAtIndex(i)

// save item in the listbox
ListBox1.AddRow f.DisplayName+" page "+str(i+1)
ListBox1.Cell(ListBox1.LastIndex,1)="PDF"
ListBox1.CellTag(ListBox1.LastIndex,0)=page
ListBox1.CellTag(ListBox1.LastIndex,1)=n // keep reference
next

update
end if

End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim f as FolderItem

f=GetOpenFolderItem("any")
if f<>Nil then

// save item in the listbox
ListBox1.AddRow f.DisplayName
ListBox1.CellTag(ListBox1.LastIndex,0)=f
ListBox1.Cell(ListBox1.LastIndex,1)="File"

update
end if

End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
run
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim i as integer

// remove selected rows
for i=ListBox1.ListCount-1 DownTo 0
if ListBox1.Selected(i) then
ListBox1.RemoveRow i
end if
next

update
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
export
End Sub
End ControlInstance

// Properties
Protected Dim slideshow As myikSlideshowMBS

// Event implementations
Sub Open()

if IKSlideshowMBS.Available=False then
MsgBox "You need Mac OS X 10.5 for this and a MachO application."
quit
end if

End Sub

// Methods
Protected Sub update()
removebutton.enabled=ListBox1.ListIndex>=0
runbutton.enabled=ListBox1.ListCount>0
SendButton.enabled=ListBox1.ListCount>0

End Sub
Protected Sub run()
slideshow = new MyIKSlideshowMBS

dim i,c as integer
c=ListBox1.ListCount-1
for i=0 to c

dim o as Object=ListBox1.CellTag(i,0)

if o isa FolderItem then
slideshow.addFile FolderItem(o), Listbox1.Cell(i,0)
elseif o isa NSImageMBS then
slideshow.addImage NSImageMBS(o), Listbox1.Cell(i,0)
elseif o isa PDFPageMBS then
slideshow.addPage PDFPageMBS(o), Listbox1.Cell(i,0)
end if
next

if slideshow.ItemCount>=0 then
slideshow.runSlideshow
else
MsgBox "no slides?"
end if

End Sub
Protected Sub export()
if false=IKSlideshowMBS.canExportToApplication(IKSlideshowMBS.iPhotoBundleIdentifier) then
MsgBox "Can't export to iPhoto."
else

slideshow=new MyIKSlideshowMBS

dim i,c as integer
c=ListBox1.ListCount-1
for i=0 to c
dim o as Object=ListBox1.CellTag(i,0)
if o isa FolderItem then
slideshow.addFile FolderItem(o), Listbox1.Cell(i,0)
elseif o isa NSImageMBS then
slideshow.addImage NSImageMBS(o), Listbox1.Cell(i,0)
elseif o isa PDFPageMBS then
slideshow.addPage PDFPageMBS(o), Listbox1.Cell(i,0)
end if
next

if slideshow.ItemCount>0 then

slideshow.exportSlideshowItems IKSlideshowMBS.iPhotoBundleIdentifier

else
MsgBox "no files?"
end if

end if

End Sub
End Class

Class App
Inherits Application
End Class

Class MyIKSlideshowMBS
Inherits IKSlideshowMBS
End Class





Links
MBS REALbasic Plugins - Pfarrgemeinde St. Arnulf Nickenich