LCUI, A small C library for building user interfaces with C, XML and CSS

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Posts: 216
Joined: Oct 11, 2005 10:46

LCUI, A small C library for building user interfaces with C, XML and CSS

Postby oyster » Jul 14, 2020 11:44

the following code can display the widgets. but again, I don't know how to deal with the callback function

why not sciter for GUI? 2 reasons, 1. size; 2. license

Code: Select all


'~ sub OnBtnClick(LCUI_Widget self, LCUI_WidgetEvent e, void *arg)
   '~ wchar_t str[256];
   '~ LCUI_Widget edit = LCUIWidget_GetById("edit");
   '~ LCUI_Widget txt = LCUIWidget_GetById("text-hello");

   '~ TextEdit_GetTextW(edit, 0, 255, str);
   '~ TextView_SetTextW(txt, str);
'~ end sub

type LCUI_Widget as any pointer

'~ LCUI_API void LCUI_InitBase(void);
Declare sub LCUI_Init Cdecl Lib "LCUI" Alias "LCUI_Init" ()

'~ LCUI_API int LCUI_Main(void);
Declare function LCUI_Main Cdecl Lib "LCUI" Alias "LCUI_Main" () as integer

'~ LCUI_API LCUI_Widget LCUIWidget_GetRoot(void);
Declare function LCUIWidget_GetRoot Cdecl Lib "LCUI" Alias "LCUIWidget_GetRoot" () as LCUI_Widget

'~ LCUI_API LCUI_Widget LCUIBuilder_LoadFile(const char *filepath);
Declare function LCUIBuilder_LoadFile Cdecl Lib "LCUI" Alias "LCUIBuilder_LoadFile" (filepath as zstring ptr) as LCUI_Widget

'~ LCUI_API int Widget_Append(LCUI_Widget container, LCUI_Widget widget);
Declare function Widget_Append Cdecl Lib "LCUI" Alias "Widget_Append" (container as LCUI_Widget, widget as LCUI_Widget) as integer

'~ LCUI_API int Widget_Unwrap(LCUI_Widget widget);
Declare function Widget_Unwrap Cdecl Lib "LCUI" Alias "Widget_Unwrap" (widget as LCUI_Widget) as integer

'~ LCUI_API LCUI_Widget LCUIWidget_GetById(const char *idstr);
Declare function LCUIWidget_GetById Cdecl Lib "LCUI" Alias "LCUIWidget_GetById" (idstr as zstring ptr) as LCUI_Widget

'~ typedef void(*LCUI_WidgetEventFunc)(LCUI_Widget, LCUI_WidgetEvent, void*);
'~ type LCUI_WidgetEventFunc as FUNCTION(a as LCUI_Widget, b as LCUI_WidgetEvent, c as any pointer)

'~ LCUI_API int Widget_BindEventById(LCUI_Widget widget, int event_id,
              '~ LCUI_WidgetEventFunc func, void *data,
              '~ void(*destroy_data)(void*));
' ??how to

function main() as integer
   dim as LCUI_Widget root, pack, btn

   root = LCUIWidget_GetRoot()
   pack = LCUIBuilder_LoadFile("helloworld.xml")
   '~ if (not pack) then
      '~ return -1
   '~ end if
   Widget_Append(root, pack)
   btn = LCUIWidget_GetById("btn")
    print btn
   '~ Widget_BindEvent(btn, "click", OnBtnClick, NULL, NULL)

   return LCUI_Main()
end function


Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 2 guests