#pragma once #include #include #include #include "sane/sane_ex.h" #include "base/HGDef.h" #include "base/HGDll.h" #include "twain/twain.h" typedef struct _dev_que_ui { int id; // ID,用户选中后返回该值 std::string name; // 设备名称 std::string sn; // 设备序列号 }DEVQUEUI; // 功能: 选择多个同型设备中的一个,模态 // // 参数: devs - 设备队列列表 // // 返回: 用户选择的设备所对应的,DEVQUE::id;或者-1代表用户放弃选择设备 HGEXPORT int choose_scanner(const std::vector& devs); // blocked. return selected DEVQUE::id or -1 if user cancelled // 功能: 应用当前设备对应的用户配置,同步 // // 参数: dev_name - 设备名称 // // device - 设备打开的句柄 // // api - sane_xxx API函数指针 // // 返回: 当前设备配置方案的名称。返回指针通过调用函数twain_ui_free来释放 HGEXPORT char* apply_current_config(const char* dev_name, SANE_Handle device, LPSANEAPI api); HGEXPORT int apply_given_config(const char* content, SANE_Handle device, LPSANEAPI api); // 应用指定的配置,content为配置数据流,返回0表示成功 // 功能: 获取配置文件内容 // // 参数: dev_name - 设备名称 // // name - 指定的文件内容,NULL表示获取默认方案的配置文件内容 // // 返回: 配置文件内容内存,调用twain_ui_free释放 HGEXPORT char* get_config_content(const char* dev_name, const char* name = NULL); // 功能: 释放由界面模块返回的动态分配的内存,同步 // // 参数: buf - 内存地址 // // 返回: 无 HGEXPORT void twain_ui_free(void* buf); enum ui_result { UI_RESULT_FAILED = -1, // 一般用于界面初始化失败 UI_RESULT_OK, // 界面正常显示 UI_RESULT_CLOSE_NORMAL, // 界面正常关闭 UI_RESULT_CLOSE_CANCEL, // 用户取消操作,如取消扫描…… UI_RESULT_START_SCAN, // 用户点击了开始扫描 UI_RESULT_CLOSE_SETTING, }; // 功能: 释放由界面模块返回的动态分配的内存,非模态 // // 参数: device - 当前打开的设备句柄 // // parent - 父窗口句柄 // // api - sane_xxx API函数指针 // // devName - 设备名称 // // with_scan - 是否显示“扫描”按钮 // // callback - 用户界面操作事件回调(主要为取消,扫描事件) // // 返回: ui_result 类型, UI_RESULT_FAILED or UI_RESULT_OK //int show_setting_ui(SANE_Handle device, HWND parent, LPSANEAPI api, const char *devName, bool with_scan/*是否显示“扫描”按钮*/); HGEXPORT int show_setting_ui(SANE_Handle device, HWND parent, LPSANEAPI api, const char* devName, bool with_scan, std::function callback, std::function* notify); // 功能: 显示扫描进度界面,非模态 // // 参数: parent - 父窗口句柄 // // callback - 用户界面操作事件回调(主要为取消扫描事件) // // notify - ui接收进度通知函数,外部通过该返回的函数来通知当前扫描进度或事件 // notify events: SANE_EVENT_WORKING - void*: unused, be NULL, flag - unused, be 0 // SANE_EVENT_SCAN_FINISHED - void*: (utf8*)message, flag - error code (0 is success) // SANE_EVENT_USB_DATA_RECEIVED- void* unused, be NULL, flag - unused, be 0 // SANE_EVENT_IMAGE_OK - void* unused, be NULL, flag - unused, be 0 // // 返回: ui_result 类型, UI_RESULT_FAILED or UI_RESULT_OK HGEXPORT int show_progress_ui(HWND parent, std::function callback, std::function* notify); // 功能: 不显示扫描进度界面,设备返回错误信息指示框,非模态 // // 参数: parent - 父窗口句柄 // // events - SANE_EVENT_SCAN_FINISHED // // void* - (utf8*)message, // // flag - error code (0 is success) // // 返回: ui_result 类型, UI_RESULT_FAILED or UI_RESULT_OK HGEXPORT int show_messagebox_ui(HWND parent,int event, void* msg, int flag); HGEXPORT int show_twain_srclist_ui(const TW_IDENTITY *vds, HGUInt count, const char* defDsName, HGWindow parent, TW_IDENTITY *ds); HGEXPORT int show_srclist_ui(const char **manuNames, const char **sanePaths, HGWindow parent, HGDll *dll, SANEAPI* saneApi, char *manuName, unsigned int maxLen); // 功能: 关闭界面 // // 参数: which - bit mask, 界面类型 // // 返回: 暂时未用,返回0即可。 enum which_ui { UI_NONE = 0, UI_INDICATOR = 1 << 0, UI_SETTING = 1 << 1, UI_MSG_BOX = 1 << 2, UI_UNLOAD_MODULE = -1, // this command is used to notify the module will be unloaded }; HGEXPORT int close_ui(int which); HGEXPORT void pump_ui_message(void* reserved); //功能:异常图片交互 // //参数:获取异常的图像 // //返回SANE_Abnormal_Image_Treat HGEXPORT int abnormal_image(SANE_Image *img);