Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Picture/Icon/Icon
Function:
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: /Picture/Icon/Icon
This example is the version from Thu, 16th Nov 2016.
Project "Icon.rbp"
FileTypes
Filetype special/any
End FileTypes
Class MainWindow Inherits Window
Control StaticTexts Inherits Label
ControlInstance StaticTexts(6) Inherits Label
ControlInstance StaticTexts(13) Inherits Label
End Control
Control Big Inherits IconCanvas
ControlInstance Big Inherits IconCanvas
End Control
Control huge Inherits IconCanvas
ControlInstance huge Inherits IconCanvas
End Control
Control small Inherits IconCanvas
ControlInstance small Inherits IconCanvas
End Control
Control middle Inherits IconCanvas
ControlInstance middle Inherits IconCanvas
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
EventHandler Sub Change() updatelabel End EventHandler
EventHandler Sub Open() for i as integer=0 to 7 me.AddRow str(i) next End EventHandler
End Control
Control CheckSelected Inherits CheckBox
ControlInstance CheckSelected Inherits CheckBox
EventHandler Sub Action() updatelabel End EventHandler
End Control
Control PopupMenu2 Inherits PopupMenu
ControlInstance PopupMenu2 Inherits PopupMenu
EventHandler Sub Change() updatelabel End EventHandler
End Control
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 i as IconMBS = List.CellTag(row,0) if i<>nil and i.valid then dim p as Picture = new Picture(g.Width,g.Height,32) i.drawIcon(p.graphics,0,0,g.width,g.height,0,finderlabel) g.drawpicture p, 0, 0 end if Return true end if End EventHandler
EventHandler Sub Change() if me.ListIndex>=0 then dim i as IconMBS = me.CellTag(me.ListIndex,0) ShowIcon i end if End EventHandler
End Control
Control BigThumbnail Inherits IconCanvas
ControlInstance BigThumbnail Inherits IconCanvas
End Control
Control Thumbnail Inherits IconCanvas
ControlInstance Thumbnail Inherits IconCanvas
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) do if obj.folderItemavailable then List.ListIndex=-1 run obj.folderItem end if loop until not obj.nextItem End EventHandler
EventHandler Sub Open() me.acceptfileDrop "special/any" Add "ClipboardIcon", "CLIP" Add "ClippingUnknownTypeIcon", "clpu" Add "ClippingPictureTypeIcon", "clpp" Add "ClippingTextTypeIcon", "clpt" Add "ClippingSoundTypeIcon", "clps" Add "DesktopIcon", "desk" Add "FinderIcon", "FNDR" Add "ComputerIcon", "root" Add "FontSuitcaseIcon", "FFIL" Add "FullTrashIcon", "ftrh" Add "GenericApplicationIcon", "APPL" Add "GenericCDROMIcon", "cddr" Add "GenericControlPanelIcon", "APPC" Add "GenericControlStripModuleIcon", "sdev" Add "GenericComponentIcon", "thng" Add "GenericDeskAccessoryIcon", "APPD" Add "GenericDocumentIcon", "docu" Add "GenericEditionFileIcon", "edtf" Add "GenericExtensionIcon", "INIT" Add "GenericFileServerIcon", "srvr" Add "GenericFontIcon", "ffil" Add "GenericFontScalerIcon", "sclr" Add "GenericFloppyIcon", "flpy" Add "GenericHardDiskIcon", "hdsk" Add "GenericIDiskIcon", "idsk" Add "GenericRemovableMediaIcon", "rmov" Add "GenericMoverObjectIcon", "movr" Add "GenericPCCardIcon", "pcmc" Add "GenericPreferencesIcon", "pref" Add "GenericQueryDocumentIcon", "qery" Add "GenericRAMDiskIcon", "ramd" Add "GenericSharedLibaryIcon", "shlb" Add "GenericStationeryIcon", "sdoc" Add "GenericSuitcaseIcon", "suit" Add "GenericURLIcon", "gurl" Add "GenericWORMIcon", "worm" Add "InternationalResourcesIcon", "ifil" Add "KeyboardLayoutIcon", "kfil" Add "SoundFileIcon", "sfil" Add "SystemSuitcaseIcon", "zsys" Add "TrashIcon", "trsh" Add "TrueTypeFontIcon", "tfil" Add "TrueTypeFlatFontIcon", "sfnt" Add "TrueTypeMultiFlatFontIcon", "ttcf" Add "UserIDiskIcon", "udsk" Add "UnknownFSObjectIcon", "unfs" Add "InternationResourcesIcon", "ifil" Add "InternetLocationHTTPIcon", "ilht" Add "InternetLocationFTPIcon", "ilft" Add "InternetLocationAppleShareIcon", "ilaf" Add "InternetLocationAppleTalkZoneIcon", "ilat" Add "InternetLocationFileIcon", "ilfi" Add "InternetLocationMailIcon", "ilma" Add "InternetLocationNewsIcon", "ilnw" Add "InternetLocationNSLNeighborhoodIcon", "ilns" Add "InternetLocationGenericIcon", "ilge" Add "GenericFolderIcon", "fldr" Add "DropFolderIcon", "dbox" Add "MountedFolderIcon", "mntd" Add "OpenFolderIcon", "ofld" Add "OwnedFolderIcon", "ownd" Add "PrivateFolderIcon", "prvf" Add "SharedFolderIcon", "shfl" Add "SharingPrivsNotApplicableIcon", "shna" Add "SharingPrivsReadOnlyIcon", "shro" Add "SharingPrivsReadWriteIcon", "shrw" Add "SharingPrivsUnknownIcon", "shuk" Add "SharingPrivsWritableIcon", "writ" Add "UserFolderIcon", "ufld" Add "WorkgroupFolderIcon", "wfld" Add "GuestUserIcon", "gusr" Add "UserIcon", "user" Add "OwnerIcon", "susr" Add "GroupIcon", "grup" Add "AppearanceFolderIcon", "appr" Add "AppleExtrasFolderIcon", "aexƒ" Add "AppleMenuFolderIcon", "amnu" Add "ApplicationsFolderIcon", "apps" Add "ApplicationSupportFolderIcon", "asup" Add "AssistantsFolderIcon", "astƒ" Add "ColorSyncFolderIcon", "prof" Add "ContextualMenuItemsFolderIcon", "cmnu" Add "ControlPanelDisabledFolderIcon", "ctrD" Add "ControlPanelFolderIcon", "ctrl" Add "ControlStripModulesFolderIcon", "sdvƒ" Add "DocumentsFolderIcon", "docs" Add "ExtensionsDisabledFolderIcon", "extD" Add "ExtensionsFolderIcon", "extn" Add "FavoritesFolderIcon", "favs" Add "FontsFolderIcon", "font" Add "HelpFolderIcon", "ƒhlp" Add "InternetFolderIcon", "intƒ" Add "InternetPlugInFolderIcon", "ƒnet" Add "InternetSearchSitesFolderIcon", "issf" Add "LocalesFolderIcon", "ƒloc" Add "MacOSReadMeFolderIcon", "morƒ" Add "PublicFolderIcon", "pubf" Add "PreferencesFolderIcon", "prfƒ" Add "PrinterDescriptionFolderIcon", "ppdf" Add "PrinterDriverFolderIcon", "ƒprd" Add "PrintMonitorFolderIcon", "prnt" Add "RecentApplicationsFolderIcon", "rapp" Add "RecentDocumentsFolderIcon", "rdoc" Add "RecentServersFolderIcon", "rsrv" Add "ScriptingAdditionsFolderIcon", "ƒscr" Add "SharedLibrariesFolderIcon", "ƒlib" Add "ScriptsFolderIcon", "scrƒ" Add "ShutdownItemsDisabledFolderIcon", "shdD" Add "ShutdownItemsFolderIcon", "shdf" Add "SpeakableItemsFolder", "spki" Add "StartupItemsDisabledFolderIcon", "strD" Add "StartupItemsFolderIcon", "strt" Add "SystemExtensionDisabledFolderIcon", "macD" Add "SystemFolderIcon", "macs" Add "TextEncodingsFolderIcon", "ƒtex" Add "UsersFolderIcon", "usrƒ" Add "UtilitiesFolderIcon", "utiƒ" Add "VoicesFolderIcon", "fvoc" Add "AppleScriptBadgeIcon", "scrp" Add "LockedBadgeIcon", "lbdg" Add "MountedBadgeIcon", "mbdg" Add "SharedBadgeIcon", "sbdg" Add "AliasBadgeIcon", "abdg" Add "AlertCautionBadgeIcon", "cbdg" Add "AlertNoteIcon", "note" Add "AlertCautionIcon", "caut" Add "AlertStopIcon", "stop" Add "AppleTalkIcon", "atlk" Add "AppleTalkZoneIcon", "atzn" Add "AFPServerIcon", "afps" Add "FTPServerIcon", "ftps" Add "HTTPServerIcon", "htps" Add "GenericNetworkIcon", "gnet" Add "IPFileServerIcon", "isrv" Add "ToolbarCustomizeIcon", "tcus" Add "ToolbarDeleteIcon", "tdel" Add "ToolbarFavoritesIcon", "tfav" Add "ToolbarHomeIcon", "thom" Add "AppleLogoIcon", "capl" Add "AppleMenuIcon", "sapl" Add "BackwardArrowIcon", "baro" Add "FavoriteItemsIcon", "favr" Add "ForwardArrowIcon", "faro" Add "GridIcon", "grid" Add "HelpIcon", "help" Add "KeepArrangedIcon", "arng" Add "LockedIcon", "lock" Add "NoFilesIcon", "nfil" Add "NoFolderIcon", "nfld" Add "NoWriteIcon", "nwrt" Add "ProtectedApplicationFolderIcon", "papp" Add "ProtectedSystemFolderIcon", "psys" Add "RecentItemsIcon", "rcnt" Add "ShortcutIcon", "shrt" Add "SortAscendingIcon", "asnd" Add "SortDescendingIcon", "dsnd" Add "UnlockedIcon", "ulck" Add "ConnectToIcon", "cnct" Add "GenericWindowIcon", "gwin" Add "QuestionMarkIcon", "ques" Add "DeleteAliasIcon", "dali" Add "EjectMediaIcon", "ejec" Add "BurningIcon", "burn" Add "RightContainerArrowIcon", "rcar" End EventHandler
Sub Add(name as string, type as string) dim i as new IconMBS(type,"macs") if i.Valid then List.AddRow "" List.Cell(List.LastIndex,1)=name List.Cell(List.LastIndex,2)=type List.CellTag(List.LastIndex,0)=i end if End Sub
Sub ShowIcon(i as IconMBS) if i<>Nil then BigThumbnail.i=i Thumbnail.i=i huge.i=i big.i=i middle.i=i small.i=i refresh end if End Sub
Sub run(f as folderItem) ShowIcon new IconMBS(f) End Sub
Sub updatelabel() finderlabel=popupMenu1.listindex*256 if checkselected.value then finderLabel=finderLabel+&h4000 end if finderLabel=finderLabel+PopupMenu2.listindex dim c as integer = List.ListCount-1 for i as integer = 0 to c List.InvalidateCell i,0 next refresh End Sub
Property Protected i As iconMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class IconCanvas Inherits Canvas
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean if i<>nil and i.valid then if i.PointInIcon(x,y,0,0,width,height,0) then 'pic.mask.graphics.pixel(x,y)=rgb(0,0,0) pressed=true refresh return true end if end if exception e End EventHandler
EventHandler Sub MouseUp(X As Integer, Y As Integer) if i<>nil and i.valid then pressed=false refresh end if End EventHandler
EventHandler Sub Open() i=new iconMBS(type,creator) pic = new Picture(200,200,32) pic.mask.graphics.foreColor=rgb(255,255,255) pic.mask.graphics.fillrect 0,0,width,height pic.graphics.foreColor=rgb(255,0,0) pic.graphics.fillrect 0,0,width,height End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if i<>nil and i.valid then if pressed then i.drawIcon(g,left,top,g.width,g.height,0,bitwiseor(finderlabel,&h4000)) else i.drawIcon(g,left,top,g.width,g.height,0,finderlabel) end if else g.foreColor=rgb(0,0,0) g.drawline 4,4,g.width-4,g.height-4 g.drawline 4,g.height-4,g.width-4,4 end if 'g.drawpicture pic,0,0 End EventHandler
Property creator As string
Property i As iconMBS
Property Protected pic As picture
Property Protected pressed As boolean
Property type As string
End Class
Module Util
Property FinderLabel As integer
End Module
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS FileMaker Plugins