Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/QuickLook Items
Function:
Required plugins for this example: MBS MacCG Plugin, MBS MacFrameworks Plugin, MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/QuickLook Items
This example is the version from Sun, 17th Mar 2012.
Project "QuickLook Items.rbp"
FileTypes
Filetype AllFiles
Filetype Disc
Filetype Folder
End FileTypes
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) do if obj.FolderItemAvailable then AddItem obj.FolderItem,System.Mousex,System.Mousey end If loop until obj.NextItem=False End EventHandler
EventHandler Sub Open() me.AcceptFileDrop "Disc" me.AcceptFileDrop "AllFiles" me.AcceptFileDrop "Folder" End EventHandler
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
Property windows() As MyOverlayWindow
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyOverlayWindow Inherits OverlayWindowMBS
EventHandler Function MouseDown(x as double, y as double, 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 EventHandler
EventHandler Function MouseDragged(x as double, y as double, ModifierKeys as integer, MouseDeltaX as double, MouseDeltaY as double, MouseButton as integer) As boolean LeftDelta=LeftDelta+MouseDeltaX TopDelta=TopDelta+MouseDeltaY me.SetBounds(StartX+LeftDelta,StartY+TopDelta,StartWidth,StartHeight) Return true End EventHandler
EventHandler Sub WindowBoundsChanged() redraw End EventHandler
EventHandler Sub WindowShown() redraw End EventHandler
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
Property Image As picture
Property LastHeight As Integer
Property LastWidth As Integer
Property LeftDelta As double
Property StartHeight As Integer
Property StartWidth As Integer
Property StartX As Integer
Property StartY As Integer
Property TopDelta As Double
Property cgimage As cgimageMBS
Property file As folderitem
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.





Links
MBS Xojo Chart Plugins