https://github.com/lc-soft/LCUI
I don't know how many HTML/HTML5 elements are supported, how complex an app can go.
Just a reminder, since it supplies DLL, I think purebasic can use it on windows/linux
LCUI, A small C library for building user interfaces with C
Re: LCUI, A small C library for building user interfaces wi
Hey... I checked this out and tried a lot of versions.
It workes great, but you need different DLL/Libs for your System.
For example there are 4 Versions for Windows and not every Version works on the System.
On my Surfe only the UWP Version workes. On My Desktop only the "plain" Version.
example1.xml
It workes great, but you need different DLL/Libs for your System.
For example there are 4 Versions for Windows and not every Version works on the System.
On my Surfe only the UWP Version workes. On My Desktop only the "plain" Version.
Code: Select all
EnableExplicit
#LCUI_VERSION=21
;#LCUI_VERSION=20
;#LCUI_VERSION=13
Macro MM
"
EndMacro
Macro _getFunction(function)
LCUI_#function=GetFunction(_lcuilib,MM#function#MM)
If LCUI_#function=0
MessageRequester("Fehler",MM#Methode '#function' konnte nicht geladen werden.MM,#PB_MessageRequester_Error)
result=#False
EndIf
EndMacro
Enumeration _widgetState
#LCUI_WSTATE_CREATED
#LCUI_WSTATE_UPDATED
#LCUI_WSTATE_LAYOUTED
#LCUI_WSTATE_READY
#LCUI_WSTATE_NORMAL
#LCUI_WSTATE_DELETED
EndEnumeration
Structure LCUI_Widget Align #PB_Structure_AlignC
hash.l
state.l
*id
*type
*classes.String
*status
*title
EndStructure
Structure LCUI_WidgetEvent Align #PB_Structure_AlignC
type.i
*data
*target.LCUI_Widget
cancel_bubble.u
EndStructure
Structure LCUI_Rect Align #PB_Structure_AlignC
x.i
y.i
w.i
h.i
EndStructure
Structure LCUI_MetricsRec Align #PB_Structure_AlignC
dpi.f
density.f
scaled_density.f
scale.f
EndStructure
Enumeration LCUI_DensityLevel
#DENSITY_LEVEL_SMALL
#DENSITY_LEVEL_NORMAL
#DENSITY_LEVEL_LARGE
#DENSITY_LEVEL_BIG
EndEnumeration
Enumeration LCUI_LoggerLevel
#LOGGER_LEVEL_ALL
#LOGGER_LEVEL_DEBUG
#LOGGER_LEVEL_INFO
#LOGGER_LEVEL_WARNING
#LOGGER_LEVEL_ERROR
#LOGGER_LEVEL_OFF
EndEnumeration
Global _lcuilib
Prototype PROTO_Event(*self.LCUI_Widget,*event.LCUI_WidgetEvent,*arg)
PrototypeC ProtoLCUI_Init()
PrototypeC ProtoLCUI_InitCSSParser()
PrototypeC.i ProtoLCUI_Main()
PrototypeC.c ProtoLCUI_GetVersion()
PrototypeC ProtoLCUIWidget_GetRoot()
PrototypeC ProtoLCUIBuilder_LoadFile(pfad.p-ascii)
PrototypeC ProtoLCUI_LoadCSSFile(pfad.p-ascii)
PrototypeC ProtoLCUIWidget_GetById(pfad.p-ascii)
PrototypeC ProtoWidget_Append(*root.LCUI_Widget,*pack.LCUI_Widget)
PrototypeC ProtoWidget_Unwrap(*pack.LCUI_Widget)
PrototypeC ProtoWidget_BindEvent(*pack.LCUI_Widget,eventname.p-ascii,*procedure.PROTO_Event,*arg1,*arg2)
PrototypeC ProtoTextEdit_GetTextW(*pack.LCUI_Widget,start,size,*data)
PrototypeC ProtoTextEdit_GetTextLength(*pack.LCUI_Widget)
PrototypeC ProtoTextView_SetTextW(*pack.LCUI_Widget,text.p-unicode)
PrototypeC ProtoWidget_UpdateStyle(*pack.LCUI_Widget,arg)
PrototypeC ProtoLCUIMetrics_SetDensityLevel(level.i);LCUI_DensityLevel
PrototypeC ProtoLCUIMetrics_SetScaledDensityLevel(level.i);LCUI_DensityLevel
PrototypeC ProtoLCUIMetrics_SetScale(scale.f)
PrototypeC ProtoLCUIMetrics_SetDpi(dpi.f)
PrototypeC ProtoLCUIWidget_RefreshStyle()
PrototypeC ProtoLCUIDisplay_InvalidateArea(*area.LCUI_Rect)
CompilerIf #LCUI_VERSION>=20
PrototypeC ProtoLCUI_GetMetrics()
CompilerEndIf
PrototypeC ProtoLCUI_InitMetrics()
PrototypeC ProtoLCUIBuilder_LoadString(str.p-ascii,size)
PrototypeC ProtoLCUI_Destroy()
PrototypeC ProtoLCUI_Quit()
PrototypeC ProtoLCUIWidget_Update()
PrototypeC ProtoLCUI_Exit(code)
PrototypeC ProtoLogger_SetLevel(level);LCUI_LoggerLevel
PrototypeC ProtoWidget_SetTitleW(*root.LCUI_Widget,title.p-unicode)
PrototypeC ProtoWidget_AddClass(*root.LCUI_Widget,title.p-unicode)
PrototypeC ProtoWidget_HasClass(*root.LCUI_Widget,title.p-unicode)
PrototypeC ProtoWidget_RemoveClass(*root.LCUI_Widget,title.p-unicode)
Global LCUI_LCUI_Init.ProtoLCUI_Init
Global LCUI_LCUI_InitCSSParser.ProtoLCUI_InitCSSParser
Global LCUI_LCUI_Main.ProtoLCUI_Main
Global LCUI_LCUI_GetVersion.ProtoLCUI_GetVersion
Global LCUI_LCUIWidget_GetRoot.ProtoLCUIWidget_GetRoot
Global LCUI_LCUIBuilder_LoadFile.ProtoLCUIBuilder_LoadFile
Global LCUI_LCUI_LoadCSSFile.ProtoLCUI_LoadCSSFile
Global LCUI_LCUIWidget_GetById.ProtoLCUIWidget_GetById
Global LCUI_Widget_Append.ProtoWidget_Append
Global LCUI_Widget_Unwrap.ProtoWidget_Unwrap
Global LCUI_Widget_BindEvent.ProtoWidget_BindEvent
Global LCUI_TextEdit_GetTextW.ProtoTextEdit_GetTextW
Global LCUI_TextView_SetTextW.ProtoTextView_SetTextW
Global LCUI_Widget_UpdateStyle.ProtoWidget_UpdateStyle
Global LCUI_LCUIMetrics_SetDensityLevel.ProtoLCUIMetrics_SetDensityLevel
Global LCUI_LCUIMetrics_SetScaledDensityLevel.ProtoLCUIMetrics_SetScaledDensityLevel
Global LCUI_LCUIMetrics_SetScale.ProtoLCUIMetrics_SetScale
Global LCUI_LCUIMetrics_SetDpi.ProtoLCUIMetrics_SetDpi
Global LCUI_LCUIWidget_RefreshStyle.ProtoLCUIWidget_RefreshStyle
Global LCUI_LCUIDisplay_InvalidateArea.ProtoLCUIDisplay_InvalidateArea
CompilerIf #LCUI_VERSION>=20
Global LCUI_LCUI_GetMetrics.ProtoLCUI_GetMetrics
CompilerEndIf
Global LCUI_LCUI_InitMetrics.ProtoLCUI_InitMetrics
Global LCUI_LCUIBuilder_LoadString.ProtoLCUIBuilder_LoadString
Global LCUI_LCUI_Destroy.ProtoLCUI_Destroy
Global LCUI_LCUI_Exit.ProtoLCUI_Exit
Global LCUI_LCUI_Quit.ProtoLCUI_Quit
Global LCUI_Logger_SetLevel.ProtoLogger_SetLevel
Global LCUI_Widget_SetTitleW.ProtoWidget_SetTitleW
Global LCUI_TextEdit_GetTextLength.ProtoTextEdit_GetTextLength
Global LCUI_LCUIWidget_Update.ProtoLCUIWidget_Update
Global LCUI_Widget_AddClass.ProtoWidget_AddClass
Global LCUI_Widget_HasClass.ProtoWidget_HasClass
Global LCUI_Widget_RemoveClass.ProtoWidget_RemoveClass
Procedure.b LCUI_Init()
_lcuilib=OpenLibrary(#PB_Any,"LCUI_"+#LCUI_VERSION+".dll")
Protected result.b=#False
If _lcuilib
result=#True
_getFunction(LCUI_Init)
_getFunction(LCUI_InitCSSParser)
_getFunction(LCUI_Main)
_getFunction(LCUI_GetVersion)
_getFunction(LCUIWidget_GetRoot)
_getFunction(LCUIBuilder_LoadFile)
_getFunction(LCUI_LoadCSSFile)
_getFunction(LCUIWidget_GetById)
_getFunction(Widget_Append)
_getFunction(Widget_Unwrap)
_getFunction(Widget_BindEvent)
_getFunction(TextEdit_GetTextW)
_getFunction(TextView_SetTextW)
_getFunction(Widget_UpdateStyle)
_getFunction(LCUIMetrics_SetDensityLevel)
_getFunction(LCUIMetrics_SetScaledDensityLevel)
_getFunction(LCUIMetrics_SetScale)
_getFunction(LCUIMetrics_SetDpi)
_getFunction(LCUIWidget_RefreshStyle)
_getFunction(LCUIDisplay_InvalidateArea)
CompilerIf #LCUI_VERSION>=20
_getFunction(LCUI_GetMetrics)
CompilerEndIf
_getFunction(LCUI_InitMetrics)
_getFunction(LCUIBuilder_LoadString)
_getFunction(LCUI_Destroy)
_getFunction(LCUI_Quit)
_getFunction(LCUI_Exit)
_getFunction(Logger_SetLevel)
_getFunction(Widget_SetTitleW)
_getFunction(TextEdit_GetTextLength)
_getFunction(LCUIWidget_Update)
_getFunction(Widget_AddClass)
_getFunction(Widget_HasClass)
_getFunction(Widget_RemoveClass)
Else
MessageRequester("Fehler","LCUI.dll konnte nicht geladen werden",#PB_MessageRequester_Error)
EndIf
ProcedureReturn result
EndProcedure
Procedure LCUI_Close()
If IsLibrary(_lcuilib)
CloseLibrary(_lcuilib)
EndIf
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
#EXAMPLE=2
CompilerSelect #EXAMPLE
CompilerCase 2
Procedure OnBtnClick(*self.LCUI_Widget,*event.LCUI_WidgetEvent,*arg)
Protected *edit.LCUI_Widget = LCUI_LCUIWidget_GetById("edit")
Protected *txt.LCUI_Widget = LCUI_LCUIWidget_GetById("text-hello")
Protected l=LCUI_TextEdit_GetTextLength(*edit)
Debug PeekS(*txt\classes,-1,#PB_Ascii)
If l>0
Protected *str=AllocateMemory(l)
LCUI_TextEdit_GetTextW(*edit, 0, l, *str)
LCUI_TextView_SetTextW(*txt, PeekS(*str))
Else
LCUI_TextView_SetTextW(*txt, "")
EndIf
EndProcedure
CompilerCase 3
Enumeration _t
#TYPE_DENSITY
#TYPE_SCALED_DENSITY
#TYPE_SCALE
#TYPE_DPI
EndEnumeration
Structure _tdat
type.i
level.i
EndStructure
Procedure OnDebugClick(*self.LCUI_Widget,*event.LCUI_WidgetEvent,*arg)
CompilerIf #LCUI_VERSION>=20
Protected *dat.LCUI_MetricsRec=LCUI_LCUI_GetMetrics()
Debug *dat\dpi
Debug *dat\density
Debug *dat\scale
Debug *dat\scaled_density
CompilerElse
Debug "Erst ab Version 2"
CompilerEndIf
EndProcedure
Procedure OnButtonClick(*self.LCUI_Widget,*event.LCUI_WidgetEvent,*arg)
Protected *dat._tdat=*event\data
Select *dat\type
Case #TYPE_DENSITY:
LCUI_LCUIMetrics_SetDensityLevel(*dat\level)
Case #TYPE_SCALED_DENSITY:
LCUI_LCUIMetrics_SetScaledDensityLevel(*dat\level)
Case #TYPE_SCALE:
LCUI_LCUIMetrics_SetScale(*dat\level / 100.0)
Case #TYPE_DPI:
LCUI_LCUIMetrics_SetDpi(*dat\level )
EndSelect
LCUI_LCUIWidget_RefreshStyle()
LCUI_LCUIDisplay_InvalidateArea(#Null)
EndProcedure
Procedure SetButton(id.s,type,level)
Protected *btn.LCUI_Widget
Protected *dat._tdat= AllocateStructure(_tdat)
*dat\level=level
*dat\type=type
*btn = LCUI_LCUIWidget_GetById(id)
LCUI_Widget_BindEvent(*btn, "click", @OnButtonClick(), *dat, #Null)
EndProcedure
Procedure InitButtons()
SetButton("btn-density-small", #TYPE_DENSITY, #DENSITY_LEVEL_SMALL)
SetButton("btn-density-normal", #TYPE_DENSITY, #DENSITY_LEVEL_NORMAL)
SetButton("btn-density-large", #TYPE_DENSITY, #DENSITY_LEVEL_LARGE)
SetButton("btn-density-big", #TYPE_DENSITY, #DENSITY_LEVEL_BIG)
SetButton("btn-scaled-density-small", #TYPE_SCALED_DENSITY, #DENSITY_LEVEL_SMALL)
SetButton("btn-scaled-density-normal", #TYPE_SCALED_DENSITY,#DENSITY_LEVEL_NORMAL)
SetButton("btn-scaled-density-large", #TYPE_SCALED_DENSITY, #DENSITY_LEVEL_LARGE)
SetButton("btn-scaled-density-big", #TYPE_SCALED_DENSITY,#DENSITY_LEVEL_BIG)
SetButton("btn-scale-small", #TYPE_SCALE, 75)
SetButton("btn-scale-normal", #TYPE_SCALE, 100)
SetButton("btn-scale-large", #TYPE_SCALE, 150)
SetButton("btn-scale-big", #TYPE_SCALE, 200)
SetButton("btn-dpi-small", #TYPE_DPI, 75)
SetButton("btn-dpi-normal", #TYPE_DPI, 100)
SetButton("btn-dpi-large", #TYPE_DPI, 150)
SetButton("btn-dpi-big", #TYPE_DPI, 200)
EndProcedure
CompilerCase 6
Procedure OnTabChange(*self.LCUI_Widget,*event.LCUI_WidgetEvent,*arg)
Protected *tab.LCUI_Widget = LCUI_LCUIWidget_GetById("browser-tabbar")
Debug LCUI_Widget_HasClass(*self,"active")
EndProcedure
CompilerEndSelect
If LCUI_Init()
LCUI_LCUI_Init()
CompilerSelect #EXAMPLE
CompilerCase 1
Debug LCUI_LCUI_GetVersion()
LCUI_LCUI_Destroy()
CompilerDefault
CompilerSelect #EXAMPLE
CompilerCase 2
Define.LCUI_Widget *root, *pack, *btn
*root = LCUI_LCUIWidget_GetRoot()
*pack = LCUI_LCUIBuilder_LoadFile("example1\example1.xml")
If Not *pack
LCUI_LCUI_Destroy()
End
EndIf
LCUI_Widget_Append(*root, *pack)
LCUI_Widget_Unwrap(*pack)
*btn = LCUI_LCUIWidget_GetById("btn")
LCUI_Widget_BindEvent(*btn, "click", @OnBtnClick(), #Null, #Null)
LCUI_Widget_SetTitleW(*root,"Test")
LCUI_LCUI_Main()
CompilerCase 3
Define.LCUI_Widget *root, *pack, *btn
*root = LCUI_LCUIWidget_GetRoot()
*pack = LCUI_LCUIBuilder_LoadFile("example2\example2.xml")
If Not *pack
LCUI_LCUI_Destroy()
End
EndIf
LCUI_LCUI_InitMetrics()
LCUI_Widget_UpdateStyle(*root, #True)
LCUI_Widget_Append(*root, *pack)
LCUI_Widget_Unwrap(*pack)
InitButtons()
*btn = LCUI_LCUIWidget_GetById("btn-dpi-debug")
LCUI_Widget_BindEvent(*btn, "click", @OnDebugClick(), #Null, #Null)
LCUI_LCUI_Main()
CompilerCase 4
Define.LCUI_Widget *root, *pack, *btn
*root = LCUI_LCUIWidget_GetRoot()
*pack = LCUI_LCUIBuilder_LoadFile("example3\example3.xml")
If Not *pack
LCUI_LCUI_Destroy()
End
EndIf
LCUI_Widget_Append(*root, *pack)
LCUI_Widget_Unwrap(*pack)
LCUI_LCUI_Main()
CompilerCase 5
Define.LCUI_Widget *root, *pack, *btn
*root = LCUI_LCUIWidget_GetRoot()
*pack = LCUI_LCUIBuilder_LoadFile("example1a\example1a.xml")
If Not *pack
LCUI_LCUI_Destroy()
End
EndIf
LCUI_Widget_Append(*root, *pack)
LCUI_Widget_Unwrap(*pack)
LCUI_LCUI_Main()
CompilerIf #LCUI_VERSION>=20
CompilerCase 6
LCUI_Logger_SetLevel(#LOGGER_LEVEL_INFO)
Define.LCUI_Widget *root, *pack, *btab
*root = LCUI_LCUIWidget_GetRoot()
*pack = LCUI_LCUIBuilder_LoadFile("example4\example4.xml")
LCUI_Widget_SetTitleW(*root,"test flex layout")
*btab = LCUI_LCUIWidget_GetById("browser-tabbar")
LCUI_Widget_BindEvent(*btab, "click", @OnTabChange(), #Null, #Null)
If Not *pack
LCUI_LCUI_Destroy()
End
EndIf
LCUI_Widget_Append(*root, *pack)
LCUI_Widget_Unwrap(*pack)
LCUI_LCUIWidget_Update()
LCUI_LCUI_Main()
CompilerEndIf
CompilerEndSelect
CompilerEndSelect
LCUI_Close()
EndIf
CompilerEndIf
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<lcui-app>
<resource type="text/css">
textview.text-hello {
font-size: 18px;
font-family: "Segoe UI";
text-align: center;
padding: 25px;
margin: 25px;
border: 1px solid #eee;
background-color: #f8f9fa;
}
#btn, #edit {
margin: 0 0 0 25px;
}
</resource>
<ui>
<textview id="text-hello" type="textview" class="text-hello">
[i][color=#f00]Hello[/color][/i], [b][color=#fff][bgcolor=#f00]World![/bgcolor][/color][/b]
</textview>
<textedit id="edit">[i][color=#f00]Hello[/color][/i], [b][color=#fff][bgcolor=#f00]World![/bgcolor][/color][/b]</textedit>
<button id="btn">Change</button>
</ui>
</lcui-app>
Re: LCUI, A small C library for building user interfaces wi
that is a nice binding