2022-06-20 07:17:55 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <CommCtrl.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <sane/sane_ex.h>
|
|
|
|
|
#include <sane/sane_option_definitions.h>
|
|
|
|
|
|
|
|
|
|
// CDlgIndicator 对话框
|
2022-07-01 07:24:58 +00:00
|
|
|
|
#define RECT_W(r) (r.right - r.left)
|
|
|
|
|
#define RECT_H(r) (r.bottom - r.top)
|
2022-06-20 07:17:55 +00:00
|
|
|
|
#define WM_REFRESH_OPTION WM_USER + 111 // WPARAM: source option SN, LPARAM: unused now
|
2022-07-01 07:24:58 +00:00
|
|
|
|
#define WM_GET_CONFIG_OBJ WM_USER + 112 // WPARAM: not use, LPARAM: to receive the gb::sane_config* object
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
2022-06-23 06:01:28 +00:00
|
|
|
|
enum ui_event
|
|
|
|
|
{
|
|
|
|
|
UI_EVENT_CLOSE_NORMAL = 0,
|
|
|
|
|
UI_EVENT_CLOSE_CANCEL,
|
2022-07-01 07:24:58 +00:00
|
|
|
|
UI_EVENT_BEGIN_SCANNING, // setting ui notify button 'scan' clicked
|
|
|
|
|
UI_EVENT_SCAN_WORKING, // scanner thread notify working
|
2022-06-23 06:01:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-06-20 07:17:55 +00:00
|
|
|
|
extern HMODULE g_my_inst;
|
2022-07-01 07:24:58 +00:00
|
|
|
|
namespace gb
|
|
|
|
|
{
|
|
|
|
|
class sane_config;
|
|
|
|
|
}
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
|
|
|
|
class dlg_base
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
HWND hwnd_;
|
|
|
|
|
HWND parent_;
|
|
|
|
|
UINT idd_;
|
2022-06-27 01:38:12 +00:00
|
|
|
|
void(__stdcall* ui_event_notify_)(ui_event uev, void* sender, void* param);
|
|
|
|
|
void* ui_notify_param_;
|
2022-06-20 07:17:55 +00:00
|
|
|
|
static std::wstring prop_name;
|
|
|
|
|
static BOOL CALLBACK dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
|
|
|
|
|
|
|
|
|
|
virtual BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp);
|
|
|
|
|
virtual void on_font_changed(void);
|
|
|
|
|
void create(void);
|
2022-06-27 01:38:12 +00:00
|
|
|
|
void notify_ui_event(ui_event ev);
|
2022-07-01 07:24:58 +00:00
|
|
|
|
gb::sane_config* get_config(void);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
dlg_base(HWND parent, UINT idd);
|
|
|
|
|
virtual ~dlg_base();
|
|
|
|
|
|
|
|
|
|
static bool get_max_size(SIZE& dst, const SIZE& src); // return whether changed dst
|
|
|
|
|
static bool get_max_size(SIZE& dst, int cx, int cy); // return whether changed dst
|
|
|
|
|
|
|
|
|
|
public:
|
2022-06-27 01:38:12 +00:00
|
|
|
|
void set_ui_event_notify(void(__stdcall* notify)(ui_event, void*, void*), void* param);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
HWND hwnd(void);
|
2022-07-01 07:24:58 +00:00
|
|
|
|
void show(bool visible);
|
2022-06-27 01:38:12 +00:00
|
|
|
|
void enable(bool enable);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
void screen_2_client(LPRECT r);
|
|
|
|
|
void client_2_screen(LPRECT r);
|
|
|
|
|
HWND get_item(UINT id);
|
|
|
|
|
BOOL set_font(HFONT font);
|
|
|
|
|
HFONT get_font(void);
|
2022-06-21 09:23:26 +00:00
|
|
|
|
int get_string_width(const wchar_t* str);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class dlg_page : public dlg_base
|
|
|
|
|
{
|
|
|
|
|
std::wstring name_;
|
|
|
|
|
SIZE size_;
|
|
|
|
|
UINT ctrl_id_;
|
|
|
|
|
POINT pos_;
|
2022-06-21 09:23:26 +00:00
|
|
|
|
SANEAPI sane_;
|
|
|
|
|
SANE_Handle dev_;
|
|
|
|
|
bool done_;
|
|
|
|
|
std::vector<HWND> ctrls_;
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
2022-06-23 06:01:28 +00:00
|
|
|
|
int id_dpi_;
|
|
|
|
|
float dpi_;
|
|
|
|
|
int id_paper_;
|
|
|
|
|
std::wstring paper_;
|
|
|
|
|
|
|
|
|
|
int id_custom_area_;
|
|
|
|
|
int id_custom_left_;
|
|
|
|
|
int id_custom_right_;
|
|
|
|
|
int id_custom_top_;
|
|
|
|
|
int id_custom_bottom_;
|
|
|
|
|
int id_custom_gamma_;
|
|
|
|
|
|
2022-06-21 09:23:26 +00:00
|
|
|
|
static std::wstring property_type;
|
|
|
|
|
static std::wstring property_host;
|
|
|
|
|
static std::wstring property_size;
|
2022-06-20 07:17:55 +00:00
|
|
|
|
static UINT dyn_id_base;
|
|
|
|
|
static int gap_x;
|
|
|
|
|
static int gap_y;
|
2022-06-21 09:23:26 +00:00
|
|
|
|
static int spin_w;
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
2022-07-01 07:24:58 +00:00
|
|
|
|
|
2022-06-20 07:17:55 +00:00
|
|
|
|
BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp) override;
|
|
|
|
|
void on_font_changed(void) override;
|
2022-06-21 09:23:26 +00:00
|
|
|
|
|
|
|
|
|
HWND create_label(int sn, const wchar_t* title, int x, int y, SIZE size);
|
|
|
|
|
HWND create_slider(int sn, int x, int y, double lower, double upper, double step, double pos, LPSIZE size, bool is_double);
|
|
|
|
|
HWND create_edit(int sn, int x, int y, int h, int w = 50);
|
|
|
|
|
HWND create_combox(int sn, int x, int y, std::vector<std::wstring>& vals, const wchar_t* cur_val, LPSIZE size);
|
|
|
|
|
HWND create_spin(int sn, HWND edit, double pos, double lower, double upper, bool is_double);
|
|
|
|
|
|
|
|
|
|
HWND create_control_bool(int sn, const SANE_Option_Descriptor* desc, void* cur_val, const wchar_t* title, LPSIZE text_size);
|
|
|
|
|
HWND create_control_int(int sn, const SANE_Option_Descriptor* desc, void* cur_val, const wchar_t* title, LPSIZE text_size);
|
|
|
|
|
HWND create_control_float(int sn, const SANE_Option_Descriptor* desc, void* cur_val, const wchar_t* title, LPSIZE text_size);
|
|
|
|
|
HWND create_control_string(int sn, const SANE_Option_Descriptor* desc, void* cur_val, const wchar_t* title, LPSIZE text_size);
|
|
|
|
|
HWND create_control_button(int sn, const SANE_Option_Descriptor* desc, void* cur_val, const wchar_t* title, LPSIZE text_size);
|
|
|
|
|
|
|
|
|
|
void handle_command(WORD code, WORD id, HANDLE ctrl);
|
|
|
|
|
BOOL on_notify(int ctrl_id, LPNMHDR pnmh);
|
|
|
|
|
|
|
|
|
|
void* value_from_ctrl(HWND ctrl, SANE_Value_Type* type); // call free_ctrl_value to free the returned value, data according to SANE-standard
|
|
|
|
|
void set_ctrl_value(HWND ctrl, SANE_Value_Type type, void* val, bool only_me, bool skip_ctrl = false);
|
|
|
|
|
void free_ctrl_value(void* val);
|
|
|
|
|
int find_control_ind(HWND wnd);
|
|
|
|
|
void control_action(HWND wnd);
|
|
|
|
|
BOOL on_mouse_wheel(WORD vkey, short delta, short x, short y);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2022-06-21 09:23:26 +00:00
|
|
|
|
dlg_page(HWND parent, const wchar_t* name, LPSANEAPI api, SANE_Handle dev);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
~dlg_page();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool add_control(int sn, const SANE_Option_Descriptor* desc, void* cur_val);
|
2022-06-21 09:23:26 +00:00
|
|
|
|
void add_control_done(void);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
SIZE desired_size(void);
|
|
|
|
|
void show(void);
|
|
|
|
|
void hide(void);
|
2022-06-21 09:23:26 +00:00
|
|
|
|
bool refresh(int sn, const SANE_Option_Descriptor* desc, void* cur_val);
|
2022-06-20 07:17:55 +00:00
|
|
|
|
const wchar_t* name(void);
|
|
|
|
|
};
|
2022-06-23 06:01:28 +00:00
|
|
|
|
|
|
|
|
|
|