通常情况下,GUI程序都是由事件驱动的、需要有一个事件循环。 GUIEvtLoop 为GUI程序提供了一个事件循环。
GUIEvtLoop 管理着GUI程序的执行流程、负责GUI程序在总体上、全局上的基本设置。一个GUI程序应当有且仅有一个 GUIEvtLoop 对象。
在你软件代码的任何地方,你可以使用 uiEvtLp
这个全局变量来访问 GUIEvtLoop 对象。 作为一个最佳实践,用户可以创建一个 GUIEvtLoop 的子类(比如命名为GUIApplication),然后把所有事关软件总体、和全局的初始化等操作放在这个GUIApplication子类中。
更多...
#include <gUIEvtLoop.h>
继承自 GObject .
|
static int | enterLoop () |
| 对事件循环进行递归。不要调用它,除非你是专家。 更多...
|
|
static int | exitLoop (int level, int code=0) |
| 退出事件循环。不要调用它,除非你是专家。 更多...
|
|
static int | quit (int code=0) |
| 让程序退出; 更多...
|
|
static int | postEvent (GEvent *event, int priority=SYS_EVT_PRIORITY, GObject *receiver=NULL) |
| 将一个事件加入事件循环。如果你不需要指定接收者和优先级,那么你调用这个函数会比较方便。 更多...
|
|
static int | postEvent (GEvent *event, GObject *receiver, int priority=SYS_EVT_PRIORITY) |
| 将一个事件加入事件循环。如果你不需要指定优先级,那么你调用这个函数会比较方便。 更多...
|
|
static void | setImageDB (const GImageAttr *p, const uint16_t nums) |
| 该函数用于设置软件所需要的图片数据;用户必须在构造GUIEvtLoop对象之前调用setImageDB。举例如下:
更多...
|
|
template<class Receiver , typename... Args> |
static int | connect (GObject *sender, GSignal< void(Args...)> &signal, Receiver *receiver, void(Receiver::*SlotFunc)(Args...)) |
| 将信号和槽建立连接。
Receiver代表接收者的类型 Args是槽函数/信号的参数列表。 更多...
|
|
template<class Receiver , typename... Args> |
static int | disconnect (GObject *sender, GSignal< void(Args...)> &signal, Receiver *receiver, void(Receiver::*SlotFunc)(Args...)) |
| 将信号和槽断开连接。
Receiver代表接收者的类型 Args是槽函数/信号的参数列表。 更多...
|
|
static bool | isObjectExist (GObject *obj) |
| 判断对象是否已经被析构掉了。 更多...
|
|
通常情况下,GUI程序都是由事件驱动的、需要有一个事件循环。 GUIEvtLoop 为GUI程序提供了一个事件循环。
GUIEvtLoop 管理着GUI程序的执行流程、负责GUI程序在总体上、全局上的基本设置。一个GUI程序应当有且仅有一个 GUIEvtLoop 对象。
在你软件代码的任何地方,你可以使用 uiEvtLp
这个全局变量来访问 GUIEvtLoop 对象。 作为一个最佳实践,用户可以创建一个 GUIEvtLoop 的子类(比如命名为GUIApplication),然后把所有事关软件总体、和全局的初始化等操作放在这个GUIApplication子类中。
- 作者
- 明心
- 版本
- 1.0.0
- 日期
- 2019-2-4
GUIEvtLoop::GUIEvtLoop |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
使用argv和argc作为命令行参数,构造一个GUI事件循环对象。举例如下:
char* param[] = {
NULL, //这个位置放置的是程序的文件名,直接置为NULL也是可以的
(char*)"gCtrlMsgBox", //这个位置放置的是(运行本软件的)设备型号,本软件将根据这个设备型号去寻找相关资源比如图片等
(char*)"Hello Giveda",//这个位置放置的是设备的显示名称,
(char*)"36000",//这个位置放置的是设备端(即server端)所打开的TCP和UDP端口号,远程显示客户端会去连接TCP和UDP的这个端口号;UDP用于实现设备的搜索发现、TCP用于提供实际的远程显示服务;用户应当确保在此传入的端口号没有被其它软件占用。
};
argc = sizeof(param)/sizeof(char*);
GUIEvtLoop a( argc, param );//定义UI的事件循环
- 参数
-
virtual GUIEvtLoop::~GUIEvtLoop |
( |
| ) |
|
|
virtual |
析构GUIEvtLoop,并设置全局变量uiEvtLp为0
template<class Receiver , typename... Args>
int GObject::connect |
( |
GObject * |
sender, |
|
|
GSignal< void(Args...)> & |
signal, |
|
|
Receiver * |
receiver, |
|
|
void(Receiver::*)(Args...) |
SlotFunc |
|
) |
| |
|
staticinherited |
将信号和槽建立连接。
Receiver代表接收者的类型 Args是槽函数/信号的参数列表。
- 参数
-
sender | 指向发射者的指针 |
signal | 指向信号的引用。 |
receiver | 指向接收者的指针 |
SlotFunc | 指向槽函数的指针 |
- 返回
- 0代表成功;非0代表失败
const GString& GUIEvtLoop::deviceModel |
( |
| ) |
const |
const GString& GUIEvtLoop::deviceTittle |
( |
| ) |
const |
template<class Receiver , typename... Args>
int GObject::disconnect |
( |
GObject * |
sender, |
|
|
GSignal< void(Args...)> & |
signal, |
|
|
Receiver * |
receiver, |
|
|
void(Receiver::*)(Args...) |
SlotFunc |
|
) |
| |
|
staticinherited |
将信号和槽断开连接。
Receiver代表接收者的类型 Args是槽函数/信号的参数列表。
- 参数
-
sender | 指向发射者的指针 |
signal | 指向信号的引用。 |
receiver | 指向接收者的指针 |
SlotFunc | 指向槽函数的指针 |
- 返回
- 0代表成功;非0代表失败
static int GUIEvtLoop::enterLoop |
( |
| ) |
|
|
static |
对事件循环进行递归。不要调用它,除非你是专家。
- 返回
- int 0代表成功,非0代表失败
virtual bool GObject::event |
( |
GEvent * |
| ) |
|
|
virtualinherited |
static int GUIEvtLoop::exitLoop |
( |
int |
level, |
|
|
int |
code = 0 |
|
) |
| |
|
static |
退出事件循环。不要调用它,除非你是专家。
- 参数
-
level | 指定事件循环的级别 |
code | 事件循环的退出码 |
- 返回
- int 0代表成功,非0代表失败
static bool GObject::isObjectExist |
( |
GObject * |
obj | ) |
|
|
staticinherited |
判断对象是否已经被析构掉了。
- 参数
-
- 返回
- bool true表示对象健在,false表示对象已经被析构掉了
virtual void GUIEvtLoop::keyPressEvent |
( |
GKeyEvent * |
| ) |
|
|
virtual |
int32_t GUIEvtLoop::loopLevel |
( |
| ) |
const |
返回当前的事件循环级别。不要调用它,除非你是专家。
- 返回
- int
const char* GObject::name |
( |
| ) |
const |
|
inherited |
将一个事件加入事件循环。如果你不需要指定接收者和优先级,那么你调用这个函数会比较方便。
- 参数
-
event | 事件 |
receiver | 如果为空则代表事件由系统处理,如果不为空,则事件会直接分发给接收者进行处理。 |
priority | 事件处理的优先级;值越高说明事件越紧急、需要优先处理。 |
- 返回
- int 0代表成功,非0代表失败
将一个事件加入事件循环。如果你不需要指定优先级,那么你调用这个函数会比较方便。
- 参数
-
event | 事件 |
receiver | 如果为空则代表事件由系统处理,如果不为空,则事件会直接分发给接收者进行处理。 |
priority | 事件处理的优先级;值越高说明事件越紧急、需要优先处理。 |
- 返回
- int 0代表成功,非0代表失败
static int GUIEvtLoop::quit |
( |
int |
code = 0 | ) |
|
|
static |
让程序退出;
- 参数
-
code | 指定程序的退出code,这个code将作为 exec() 的返回值 |
- 返回
- int 0代表成功,非0代表失败
int8_t GUIEvtLoop::screenCounts |
( |
| ) |
const |
返回目前的屏幕总数量,包括所有虚拟远程屏幕和真实硬件屏幕。
- 返回
- int8_t
static void GUIEvtLoop::setImageDB |
( |
const GImageAttr * |
p, |
|
|
const uint16_t |
nums |
|
) |
| |
|
static |
该函数用于设置软件所需要的图片数据;用户必须在构造GUIEvtLoop对象之前调用setImageDB。举例如下:
#include <gUIEvtLoop.h>
#include "gImgApp.h" //这个头文件由Giveda框架自动生成,用户在需要使用时include进来即可
int main( int argc, char** argv )
{
//在定义GUIEvtLoop对象之前,先执行setImageDB;
//其中用到的imageDB(), GIMG_APP_NUM_MAX均在gImgApp.h中定义
GUIEvtLoop::setImageDB( imageDB(), GIMG_APP_NUM_MAX);
GUIEvtLoop a( argc, param );//定义UI的事件循环
//用户在此进行自己需要的其它操作
//进入事件循环
return a.exec();
}
- 参数
-
p | 直接传递imageDB()即可 |
nums | 直接传递GIMG_APP_NUM_MAX即可 |
- 返回
- void
设置GUI窗口系统的宽高,以像素为单位。建议用户将GUI窗口系统的宽高设置为自己屏幕的分辨率。
- 参数
-
- 返回
- void
GUIEvtLoopPriv* GUIEvtLoop::uiEvtLpPriv |
( |
| ) |
|
GSignal<void(void)> GObject::sigDestroyed |
|
inherited |
该类的文档由以下文件生成: