It's not a bug. It's simply not implemented in PB's EditorGadget to center the text.marcoagpinto wrote:The text doesn't appear centred (old bug).
To center the whole text in the EditorGadget in Windows you have to use the flag ES_CENTER when creating the EditorGadget. In Linux and MacOS you have to use the following API functions to center the whole text in an existing EditorGadget:
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_text_view_set_justification_(GadgetID(Editor), #GTK_JUSTIFY_CENTER)
CompilerCase #PB_OS_MacOS
CocoaMessage(0, GadgetID(Editor), "setAlignment:", #NSCenterTextAlignment)
CompilerEndSelect
- Linux Mint 18.1 "Serena" x64 with PB 5.61 x64 in GTK2 und GTK3

- MacOS 10.13.1 "High Sierra" with PB 5.61 x86 and x64
- MacOS 10.6.8 "Snow Leopard" with PB 5.61 x86

- Windows 7 x64 SP1 with PB 5.61 x86 und x64

Code: Select all
EnableExplicit
UsePNGImageDecoder()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
; ----- Only necessary for extracting PureBasic's 48x48 icon from
; PureBasic.Exe
ImportC ""
SHGetImageList_(ImageType.I, ImageListID.I, *ImageList) As "SHGetImageList"
EndImport
DataSection
IID_IImageList:
Data.L $46EB5926
Data.W $582E, $4017
Data.B $9F, $DF, $E8, $99, $8D, $AA, $09, $50
EndDataSection
CompilerEndIf
Procedure DisplayAboutWindow()
Protected AboutWindow.I
Protected Editor.I
Protected EditorFlags.I
Protected FontArialBold.I
Protected FontSize.I
Protected Height.I
Protected PBLogo.I
Protected PBIcon.I
Protected PBVersion.S
Protected Text.S
Protected Width.I
EditorFlags = #PB_Editor_ReadOnly | #PB_Editor_WordWrap
PBVersion = Str(#PB_Compiler_Version)
PBVersion = Left(PBVersion, Len(PBVersion) - 2) + "." + Right(PBVersion, 2)
AboutWindow = OpenWindow(#PB_Any, 0, 0, 1, 1, "About PureBasic",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
; ----- Load PureBasic's big logo with 381x68 pixels
PBLogo = LoadImage(#PB_Any, #PB_Compiler_Home +
"examples/3d/Data/PureBasicLogo.bmp")
ImageGadget(#PB_Any, 10, 10, ImageWidth(PBLogo), ImageHeight(PBLogo),
ImageID(PBLogo))
; ----- Load PureBasic's Z logo with 48x48 pixels
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
PBIcon = LoadImage(#PB_Any, #PB_Compiler_Home + "logo.png")
FontSize = 13
CompilerCase #PB_OS_MacOS
PBIcon = LoadImage(#PB_Any, #PB_Compiler_Home + "logo.png")
FontSize = 16
CompilerCase #PB_OS_Windows
; ----- In PB's Windows version the file logo.png is missing, so the
; PureBasic icon has to be extracted from PureBasic.Exe
Protected FileInfo.SHFILEINFO
Protected IconHandle.I
Protected ImageList.iImageList
Protected Shell32.I
SHGetFileInfo_(#PB_Compiler_Home + "PureBasic.Exe", -1, @FileInfo,
SizeOf(SHFILEINFO), #SHGFI_SYSICONINDEX)
Shell32 = OpenLibrary(#PB_Any, "Shell32.DLL")
If Shell32
If CallFunction(Shell32, "SHGetImageList", #SHIL_EXTRALARGE,
?IID_IImageList, @ImageList) = 0
ImageList\GetIcon(FileInfo\iIcon, #ILD_TRANSPARENT, @IconHandle)
PBIcon = CreateImage(#PB_Any, 48, 48, 32, #PB_Image_Transparent)
If StartDrawing(ImageOutput(PBIcon))
DrawImage(IconHandle, 0, 0, 48, 48)
DestroyIcon_(IconHandle)
StopDrawing()
EndIf
CloseLibrary(Shell32)
EndIf
EndIf
FontSize = 13
; ----- Add Windows flag to center text in EditorGadget
EditorFlags | #ES_CENTER
CompilerEndSelect
ImageGadget(#PB_Any, ImageWidth(PBLogo) + 20, 20, ImageWidth(PBIcon),
ImageWidth(PBIcon), ImageID(PBIcon))
Width = ImageWidth(PBLogo) + ImageWidth(PBIcon) + 20
Editor = EditorGadget(#PB_Any, 10, ImageHeight(PBLogo) + 10, Width, 130,
EditorFlags)
Height = ImageHeight(PBLogo) + GadgetHeight(Editor)
FontArialBold = LoadFont(#PB_Any, "Arial", FontSize, #PB_Font_Bold)
If FontArialBold
SetGadgetFont(Editor, FontID(FontArialBold))
EndIf
Text = #LF$ +
"Coded/Compiled with PureBasic " + PBVersion + #LF$ +
Chr(34) + "Feel the ..Pure.. Power" + Chr(34) + #LF$ + #LF$ +
"© 1998-" + FormatDate("%yyyy", #PB_Compiler_Date) +
" Fantaisie Software." + #LF$ +
"www.purebasic.com"
SetGadgetText(Editor, Text)
; ----- Center contents of EditorGadget
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_text_view_set_justification_(GadgetID(Editor), #GTK_JUSTIFY_CENTER)
CompilerCase #PB_OS_MacOS
CocoaMessage(0, GadgetID(Editor), "setAlignment:", #NSCenterTextAlignment)
CompilerEndSelect
; ----- Resize window to contain images and EditorGadget
ExamineDesktops()
ResizeWindow(AboutWindow, (DesktopWidth(0) - Width + 20) / 2,
(DesktopHeight(0) - Height + 20) / 2, Width + 20, Height + 20)
HideWindow(AboutWindow, #False)
SetActiveGadget(-1)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndProcedure
DisplayAboutWindow()