Awtk memo

Download node-v16.14.0-x64.msi from
https://nodejs.org/en/
or for win7 is
https://nodejs.org/download/release/v13.6.0
install it in Adminstrator cmd console.

Official repository:
https://github.com/zlgopen/awtk

1
2
3
4
5
6
python -m pip install pywin32
python -m pip install scons
 
cd awtk-master
scons
bin\demoui

Debug after attach demoui.exe,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
awtk-master\demos\demo_ui_app.c
 application_init
  WIDGET_FOR_EACH_CHILD_BEGIN(window_manager(), root, i)
   init_children_widget(root, (void*)win)
    widget_foreach(widget, init_widget, ctx)
     widget_on(widget, EVT_CLICK, on_menu_bar_open, win)
      on_menu_bar_open
       open_menu_bar
 
label_paint_text
 widget_draw_text_in_rect
 
window_create
 edit_create
 button_create
 label_create
  widget_set_text
window_close
dialog_create_simple
 dialog_set_title

Ui and style,

1
2
3
4
5
6
7
8
9
#doc/theme.md
bin/themegen input.xml output.bin -
 
#doc/ui_desc.md
bin/preview_ui demos/assets/raw/ui/main.xml
bin/xml_to_ui window1.xml window1.data
#include "res/ui/window1.data"
assets_manager_add((const asset_info_t*)ui_window1);
widget_t* win = window_open(name);

Message box,

my_msgbox.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef _MSG_BOX_H_
#define _MSG_BOX_H_
 
#include "awtk.h"
 
typedef enum my_msgbox_btn_t {
	MB_BTN_OK = 1,
	MB_BTN_CANCEL = 1 << 1,
	MB_BTN_NO = 1 << 2
} my_msgbox_btn_t;
 
my_msgbox_btn_t my_msgbox(widget_t* parent, const wchar_t* msg, my_msgbox_btn_t btns);
 
#endif

my_msgbox.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "my_msgbox.h"
 
static ret_t on_msgbox(void* ctx, event_t* evt)
{
	widget_t* dlg = widget_get_window(WIDGET(evt->target));
	dialog_quit(dlg, (my_msgbox_btn_t)ctx);
 
	return RET_OK;
}
 
my_msgbox_btn_t my_msgbox(widget_t* parent, const wchar_t* msg, my_msgbox_btn_t btns)
{
	widget_t* ok = NULL;
	widget_t* cancel = NULL;
	widget_t* label = NULL;
 
	widget_t* dlg = dialog_create_simple(NULL, 0, 0, 240, 160);
 
//	dialog_set_title(dlg, "Dialog");
 
	ok = button_create(dialog_get_client(dlg), 20, 80, 80, 30);
	widget_set_text(ok, L"是");
 
	cancel = button_create(dialog_get_client(dlg), 140, 80, 80, 30);
	widget_set_text(cancel, L"取消");
 
	label = label_create(dialog_get_client(dlg), 10, 30, 200, 30);
	widget_set_text(label, msg);
 
	widget_on(ok, EVT_CLICK, on_msgbox, (void*)MB_BTN_OK);
	widget_on(cancel, EVT_CLICK, on_msgbox, (void*)MB_BTN_NO);
 
	return (my_msgbox_btn_t)dialog_modal(dlg);
}

refresh file_browser_view_t,

1
2
3
	file_browser_view_t* file_browser_view = FILE_BROWSER_VIEW(widget);
	file_browser_refresh(file_browser_view->fb);
	file_browser_view_reload(file_browser_view);

refer to:
WNs_ACE - Installation
WNs_ACE - Tutorial
WNs_ACE - Custom Widget