-
Notifications
You must be signed in to change notification settings - Fork 2
/
ultralight_app.cpp
82 lines (69 loc) · 1.89 KB
/
ultralight_app.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "ultralight_hb.h"
#include <AppCore/App.h>
#include <AppCore/window.h>
HB_USHORT appClassId = 0;
using namespace ultralight;
/*
//DATA bOnUpdate
CONSTRUCTOR Create()
CONSTRUCTOR instance()
//ACCESS settings()
METHOD window() SETGET
ACCESS is_running()
ACCESS main_monitor()
ACCESS renderer()
METHOD Run()
METHOD Quit()
*/
class HBAppListener : public AppListener {
virtual void OnUpdate() {
hb_idleState();
}
} s_appListener;
HB_FUNC( ULTRALIGHT_APP_CREATE ) {
if(appClassId==0) {
appClassId = hb_clsFindClass("ULTRALIGHT_APP", NULL);
}
RefPtr<App> app = App::Create();
initUltralightObj(app.get(),appClassId);
app->set_listener(&s_appListener);
}
HB_FUNC( ULTRALIGHT_APP_INSTANCE ) {
hb_retUltralight(App::instance(), appClassId);
}
FORWARD_GETCLASSID(WINDOW);
HB_FUNC( ULTRALIGHT_APP_WINDOW ) {
App* app = (App*)hb_selfUltralight();
if(hb_pcount()>0) {
app->set_window(*((Window*)hb_parUltralight(1)));
hb_ret();
} else {
Window* wnd = app->window().get();
hb_retUltralight((RefCounted*)wnd,GETCLASSID(WINDOW));
}
}
FORWARD_GETCLASSID(RENDERER);
HB_FUNC( ULTRALIGHT_APP_RENDERER ) {
App* app = (App*)hb_selfUltralight();
hb_retUltralight(app->renderer().ptr(),GETCLASSID(RENDERER));
}
FORWARD_GETCLASSID(MONITOR);
void hb_retMonitor(Monitor*);
HB_FUNC( ULTRALIGHT_APP_MAIN_MONITOR ) {
App* app = (App*)hb_selfUltralight();
hb_retMonitor(app->main_monitor());
}
HB_FUNC( ULTRALIGHT_APP_RUN ) {
App* app = (App*)hb_selfUltralight();
app->Run();
hb_ret();
}
HB_FUNC( ULTRALIGHT_APP_IS_RUNNING ) {
App* app = (App*)hb_selfUltralight();
hb_retl(app->is_running());
}
HB_FUNC( ULTRALIGHT_APP_QUIT ) {
App* app = (App*)hb_selfUltralight();
app->Quit();
hb_ret();
}