Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS AVFoundation Plugin, MBS MacCocoa Plugin, MBS MacBase Plugin, MBS Main Plugin, MBS MacCG Plugin, MBS MacControls Plugin, MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/IKSlideShow
This example is the version from Sun, 23th Sep 2017.
Project "IKSlideShow.xojo_binary_project"
FileTypes
Filetype text
Filetype any
End FileTypes
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
EventHandler Sub Change()
update
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
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 EventHandler
EventHandler Sub Open()
me.AcceptFileDrop "any"
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
dim f as FolderItem
dim p as Picture
dim n as NSImageMBS
f=GetOpenFolderItem("any")
if f<>Nil then
// make item from a Xojo 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 EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
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 EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
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 EventHandler
End Control
Control RunButton Inherits PushButton
ControlInstance RunButton Inherits PushButton
EventHandler Sub Action()
run
End EventHandler
End Control
Control RemoveButton Inherits PushButton
ControlInstance RemoveButton Inherits PushButton
EventHandler Sub Action()
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 EventHandler
End Control
Control SendButton Inherits PushButton
ControlInstance SendButton Inherits PushButton
EventHandler Sub Action()
export
End EventHandler
End Control
EventHandler 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 EventHandler
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
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 update()
removebutton.enabled=ListBox1.ListIndex>=0
runbutton.enabled=ListBox1.ListCount>0
SendButton.enabled=ListBox1.ListCount>0
End Sub
Property Protected slideshow As myikSlideshowMBS
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class MyIKSlideshowMBS Inherits IKSlideshowMBS
End Class
End Project
The items on this page are in the following plugins: MBS MacFrameworks Plugin.