Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Unified Bars Example
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Unified Bars Example
This example is the version from Fri, 13th Dec 2018.
Project "Unified Bars Example.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
EventHandler Sub Open() Me.LoadURL("https://www.mbs-plugins.de") End EventHandler
End Control
EventHandler Sub Open() If not (AddUnifiedTopAndBottomBars(Self, 50, 23, True)) Then //an error occurred, failed to add the unified top and bottom bars End If End EventHandler
Function AddUnifiedTopAndBottomBars(w as Window, TopHeight as Integer, BottomHeight as Integer, MovableByTopBarUnderCocoa as Boolean = False) As Boolean #If TargetCocoa Then //calculate the style mask value depending on the properties of the passed Window object Dim CustomStyleMask as Integer = NSWindowMBS.NSTexturedBackgroundWindowMask + NSWindowMBS.NSTitledWindowMask If w.CloseButton Then CustomStyleMask = Bitwise.BitOr(CustomStyleMask, NSWindowMBS.NSClosableWindowMask) End If If w.MinimizeButton Then CustomStyleMask = Bitwise.BitOr(CustomStyleMask, NSWindowMBS.NSMiniaturizableWindowMask) End If If w.Resizeable Then //note: if the Resizeable property of the passed Window object is set to True, the maximize button will be enabled (the MaximizeButton property will be ignored) CustomStyleMask = Bitwise.BitOr(CustomStyleMask, NSWindowMBS.NSResizableWindowMask) End If dim win as NSWindowMBS = w.NSWindowMBS if win = nil then Return false //apply the calculated style mask value to the window win.styleMask = CustomStyleMask win.titlebarAppearsTransparent = true //set the title of the NSWindow object to the title of the passed Window object to make it appear win.Title = w.Title //set whether the window should be movable by the top bar or not (default is set to False, see the optional parameter MovableByTopBarUnderCocoa) win.isMovableByWindowBackground = MovableByTopBarUnderCocoa //disable auto-recalculating the height of the top bar win.setAutorecalculatesContentBorderThickness(False, NSWindowMBS.NSMaxYEdge) //disable auto-recalculating the height of the bottom bar win.setAutorecalculatesContentBorderThickness(False, NSWindowMBS.NSMinYEdge) //set the height of the top bar win.setContentBorderThickness(TopHeight, NSWindowMBS.NSMaxYEdge) //set the height of the bottom bar win.setContentBorderThickness(BottomHeight, NSWindowMBS.NSMinYEdge) Return True #endif Exception Return False End Function
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

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins