Platforms to show: All Mac Windows Linux Cross-Platform

/Linux/Directory Listings with Icons


Required plugins for this example: MBS Picture Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Linux/Directory Listings with Icons

This example is the version from Wed, 10th Sep 2019.

Project "Directory Listings with Icons.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean If column = 0 Then Dim v As Variant = Me.CellTag(row, column) If v IsA Picture Then Dim p As Picture = v // draw scaled down into cell Dim pw As Integer = p.Width Dim ph As Integer = p.Height // output always in 16 Dim w As Integer = 16 Dim h As Integer = 16 g.DrawPicture p, x - 15 - w/2, (18 - h)/2, w, h, 0, 0, pw, ph Return False // let text draw End If End If End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim f as FolderItem = me.RowTag(row) if f.Directory then dim c as integer = f.Count for i as integer = 1 to c dim file as FolderItem = f.TrueItem(i) if file<>nil then if file.Visible then add file end if end if next end if End EventHandler
End Control
EventHandler Sub Open() List.ColumnAlignmentOffset(0) = 30 add SpecialFolder.Desktop End EventHandler
Sub Add(f as FolderItem) If f.directory Then list.AddFolder "" else List.AddRow "" End If Dim pic As Picture dim type as string #If TargetLinux Then Dim ThumbnailFile As FolderItem = LinuxIconMBS.FileThumbnail(f) If ThumbnailFile <> Nil Then pic = Picture.Open(ThumbnailFile) type = "thumbnail" End If If pic <> Nil Then pic = LinuxIconMBS.FilePreview(f, 32) type = "preview" End If If pic = Nil Then pic = LinuxIconMBS.FileIcon(f, 32) type = "icon" End If If pic = Nil Then Dim mimetype As String = FileExtensionToMimeTypeMBS(f.name) If mimetype = "" then mimetype = "application/octet-stream" end if pic = LinuxIconMBS.Icon(mimetype) type = mimetype End If 'If pic = Nil Then 'type = "failed?" 'end if #Else pic = f.IconMBS(32) #EndIf List.CellTag(List.LastIndex, 0) = pic List.Cell(List.LastIndex, 0) = f.DisplayName List.Cell(List.LastIndex, 1) = type List.RowTag(List.LastIndex) = f End Sub
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
End Project

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


The biggest plugin in space...