Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/DockMeter/Dock Meter
Required plugins for this example: MBS ChartDirector Plugin, MBS MacBase Plugin, MBS MacCF Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/DockMeter/Dock Meter
This example is the version from Tue, 25th May 2015.
Project "Dock Meter.rbp"
Class App Inherits Application
EventHandler Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean If eventID="rapp" Then MainWindow.Show End EventHandler
End Class
Class MainWindow Inherits Window
Control MainTimer Inherits Timer
ControlInstance MainTimer Inherits Timer
EventHandler Sub Action() update End EventHandler
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub Open() MainTimer.Period = Me.Value * 1000 End EventHandler
EventHandler Sub ValueChanged() MainTimer.Period = Me.Value * 1000 Label3.Text = Str(Me.Value) End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
EventHandler Function CancelClose(appQuitting as Boolean) As Boolean If appQuitting Then Return False Else self.Hide Return True End If End EventHandler
EventHandler Sub Open() self.Hide #if TargetCocoa then dim w as NSWindowMBS = self.NSWindowMBS w.FrameAutosaveName = App.LongVersion + " Main Window" #Else self.Top = (Screen(0).AvailableHeight/2)-(self.Height/2) self.Left = (Screen(0).AvailableWidth/2)-(self.Width/2) #endif Render Update End EventHandler
Function AboutItem() As Boolean NSApplicationMBS.sharedApplication.orderFrontStandardAboutPanel Return True End Function
Sub Render() Dim f As FolderItem f = App.ExecutableFile.Parent.Parent.Child("Resources").Child("BackgroundImage.png") dim m as new CDAngularMeterMBS(256, 256, CDBaseChartMBS.kTransparent, CDBaseChartMBS.kTransparent, 0) m.setMeter(128, 128, 108, -135, 135) m.setScale(0, 100, 10) m.setLineWidth(0, 3, 0) If f<>Nil Then If f.Exists Then m.setWallpaper(f) End If End If call m.addPointer(value, &c19191900, &c19191900) Dim CPUChartPicture As Picture = m.makeChartPicture Dim CPUChartMask as Picture = CPUChartPicture.mask CPUChartMask.Graphics.ForeColor = &cFFFFFF CPUChartMask.Graphics.FillRect(0,0, CPUChartMask.Width, CPUChartMask.Height) CPUChartMask.Graphics.ForeColor = &c000000 CPUChartMask.Graphics.FillOval(2, 2, 252, 252) dim g as Graphics = App.DockItem.Graphics g.ClearRect(0, 0, g.Width, g.Height) g.DrawPicture(CPUChartPicture, 0, 0, g.Width, g.Height) App.DockItem.UpdateNow #if DebugBuild then 'DebugWindow.Backdrop = CPUChartPicture #endif End Sub
Sub update() dim totalticks,systicks, idleticks, niceticks, userticks as integer dim d as DarwinVMStatisticsMBS if last=nil then last=GetDarwinVMStatisticsMBS else d=GetDarwinVMStatisticsMBS systicks =abs(d.CPUTicksSystem-last.CPUTicksSystem) userticks=abs(d.CPUTicksUser-last.CPUTicksUser) idleticks=abs(d.CPUTicksIdle-last.CPUTicksIdle) niceticks=abs(d.CPUTicksNice-last.CPUTicksNice) totalticks=userticks+idleticks+niceticks+systicks value = (systicks/totalticks) * 100 last=d Render end if End Sub
Property Protected last As darwinVMStatisticsMBS
Property value As Double
End Class
MenuBar MainMenu
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "&Delete"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem FileQuit = "&Quit"
End MenuBar
Class DebugWindow Inherits Window
End Class
End Project

Feedback, Comments & Corrections

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

MBS FileMaker Plugins