Platforms to show: All Mac Windows Linux Cross-Platform

/Leopard/QuickLook Items
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Leopard/QuickLook Items
This example is the version from Sun, 10th Apr 2010.
Notes: Last modified: Sun, 10th Apr 2010
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete
End Class

Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance

// Properties
Dim windows(-1) As MyOverlayWindow

// Event implementations
Sub Open()

me.AcceptFileDrop "Disc"
me.AcceptFileDrop "AllFiles"
me.AcceptFileDrop "Folder"

End Sub
Sub DropObject(obj As DragItem)
do
if obj.FolderItemAvailable then
AddItem obj.FolderItem,System.Mousex,System.Mousey
end If

loop until obj.NextItem=False

End Sub

// Methods
Sub AddItem(file as folderitem, x as integer, y as integer)
dim w as MyOverlayWindow

w=NewWindow(x-64,y-64,128,128)
w.file=file
w.IgnoreClicks=false
w.InstallEventHandler
w.Show
w.redraw

windows.Append w

End Sub
Function NewWindow(x as integer, y as integer, w as integer, h as integer) As MyOverlayWindow
dim win as MyOverlayWindow
dim e as integer

win=new MyOverlayWindow

e=win.Create(x,y,w,h)

if e=0 then

Return win

end if

End Function
End Class

Class MyOverlayWindow
Inherits OverlayWindowMBS
// Properties
Dim LastWidth As Integer
Dim LastHeight As Integer
Dim Image As picture
Dim file As folderitem
Dim cgimage As cgimageMBS
Dim StartX As Integer
Dim StartY As Integer
Dim StartWidth As Integer
Dim StartHeight As Integer
Dim LeftDelta As double
Dim TopDelta As Double

// Event implementations
Sub WindowBoundsChanged()
redraw
End Sub
Sub WindowShown()
redraw
End Sub
Function MouseDown(x as single, y as single, ModifierKeys as integer, MouseButton as integer, ClickCount as integer) As boolean

StartX=left
StartY=top
StartWidth=Width
StartHeight=Height

LeftDelta=0
TopDelta=0

Return true

End Function
Function MouseDragged(x as single, y as single, ModifierKeys as integer, MouseDeltaX as single, MouseDeltaY as single, MouseButton as integer) As boolean

LeftDelta=LeftDelta+MouseDeltaX
TopDelta=TopDelta+MouseDeltaY

me.SetBounds(StartX+LeftDelta,StartY+TopDelta,StartWidth,StartHeight)

Return true

End Function

// Methods
Sub redraw()
dim c as CGContextMBS
dim w,h as integer
dim r as CGRectMBS
dim i as CGImageMBS

c=self.Context
w=Width
h=Height

if w<>LastWidth or h<>LastHeight then
image=file.QuickLookMBS(w,h,true,1.0)

if Image=nil then
// use icon on failure
image=file.IconMBS(min(w,h))
end if

LastWidth=w
LastHeight=h

CGImage=CGCreateImageMBS(image,image.Mask)

end if

c.ClearRect CGMakeRectMBS(0,0,w,h)
c.SetRGBFillColor 0,0,0.5,0.5
c.FillEllipseInRect CGMakeRectMBS(0,0,w,h)


if cgimage<>nil then
r=CGMakeRectMBS((w-cgimage.Width)/2,(h-cgimage.Height)/2,cgimage.Width,cgimage.Height)
c.DrawPicture(cgimage,r)
end if

c.Flush

End Sub
End Class





Links
MBS Realbasic tutorial videos - Pfarrgemeinde Messdiener Nickenich