Code: Select all
;-TOP
; Workaround PB v5.60
; Version : v1.0
; Create : 24.08.2018
; Update :
; -----------------------------------------------------------------------------
;- Global
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
; Ubuntu Compiler bug
ImportC "-no-pie" : EndImport
CompilerEndSelect
; -----------------------------------------------------------------------------
;- Module
DeclareModule __Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Declare FixResizeGadget(Gadget, x, y, width, height)
Declare FixSetGadgetFont(Gadget, FontID)
Declare FixAddGadgetItem(Gadget, Position, Text.s, Image=0, Flags=0)
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
Declare FixWriteData(file, *adress, length)
CompilerEndSelect
EndDeclareModule
Module __Workaround
EnableExplicit
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
; Link https://www.purebasic.fr/english/viewtopic.php?f=24&t=71269
; Canvas Gadget Container Bugfix
Procedure FixResizeGadget(Gadget, x, y, width, height)
ResizeGadget(Gadget, x, y, width, height)
Protected rect.NSRect, sv, container
If GadgetType(Gadget) <> #PB_GadgetType_Canvas
ProcedureReturn 1
EndIf
sv = CocoaMessage(0, GadgetID(Gadget), "subviews")
If CocoaMessage(0, sv, "count")
container = CocoaMessage(0, sv, "objectAtIndex:", 0)
If container
CocoaMessage(@rect, GadgetID(Gadget), "frame")
rect\origin\x = 0
rect\origin\y = 0
CocoaMessage(0, container, "setFrame:@", @rect)
EndIf
EndIf
EndProcedure
; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68571
Procedure FixSetGadgetFont(Gadget, FontID)
SetGadgetFont(Gadget, #PB_Default)
SetGadgetFont(Gadget, FontID)
EndProcedure
; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68494
Procedure FixAddGadgetItem(Gadget, Position, Text.s, Image=0, Flags=0)
Protected font
AddGadgetItem(Gadget, Position, Text, Image, Flags)
If GadgetType(Gadget) = #PB_GadgetType_Editor
font = GetGadgetFont(Gadget)
If font
SetGadgetFont(Gadget, font)
EndIf
EndIf
EndProcedure
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
; Link http://www.purebasic.fr/english/viewtopic.php?f=23&t=68630
Procedure FixWriteData(file, *adress, length) ; Workaround for Linux PB560
Protected write_data_pointer=Loc(file)
Protected writen_data=WriteData(file, *adress, length)
FileSeek(file, write_data_pointer+writen_data)
ProcedureReturn writen_data
EndProcedure
CompilerEndSelect
EndModule
; -----------------------------------------------------------------------------
;- Macro
DeclareModule Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Macro ResizeGadget(Gadget, x, y, width, height)
__Workaround::FixResizeGadget(Gadget, x, y, width, height)
EndMacro
Macro SetGadgetFont(Gadget, FontID)
__Workaround::FixSetGadgetFont(Gadget, FontID)
EndMacro
Macro AddGadgetItem(Gadget, Position, Text, Image=0, Flags=0)
__Workaround::FixAddGadgetItem(Gadget, Position, Text, Image, Flags)
EndMacro
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
Macro WriteData(File, Buffer, Size)
__Workaround::FixWriteData(File, Buffer, Size)
EndMacro
CompilerEndSelect
EndDeclareModule
Module Workaround
EndModule
; -----------------------------------------------------------------------------