code_production/app/HGProductionTool/ui_helper.h

96 lines
2.1 KiB
C
Raw Normal View History

2022-12-15 03:00:46 +00:00
#include <Windows.h>
#include "sane/sane_ex.h"
#include <string>
#include <memory>
#include <vector>
#pragma once
class ref
{
volatile long ref_;
public:
ref() : ref_(1)
{}
protected:
virtual ~ref()
{}
public:
long add_ref(void)
{
return _InterlockedIncrement(&ref_);
}
long release(void)
{
long r = _InterlockedDecrement(&ref_);
if (r == 0)
delete this;
return r;
}
};
class parameter : public ref
{
public:
parameter()
{}
protected:
virtual ~parameter()
{}
public:
virtual size_t get_size(void) =0;
virtual void* get_data(void) = 0; // return data pointer, bool*, int*, double*, (wchar_t*)
};
class ui_helper : public ref
{
public:
2022-12-15 06:05:53 +00:00
ui_helper();
2022-12-15 03:00:46 +00:00
public:
virtual ~ui_helper()
{}
public:
enum data_from
{
DATA_FROM_KNOWN = 0, // pre-defined data name, i.e. resulotion, paper, bright, ...
DATA_FROM_USER, // need a window for user inputing
};
enum value_type
{
VAL_TYPE_BOOL = 0,
VAL_TYPE_INT,
VAL_TYPE_FLOAT,
VAL_TYPE_STRING,
VAL_TYPE_CUSTOM, // custom data, such as gamma table ...
};
// get testing parameter ...
virtual parameter* get_user_input(data_from from, value_type type
, const wchar_t* title // window title when from == DATA_FROM_USER, or parameter name when from == DATA_FROM_KNOWN
, const wchar_t* desc = NULL // description of the parameter if from was DATA_FROM_USER, unused in DATA_FROM_KNOWN
) =0;
enum test_event
{
TEST_EVENT_TIPS = 0, // messages in testing process, data is (wchar_t*), flag is unused
TEST_EVENT_xxx, // should be complemented ...
TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass
};
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag)=0 ;
// register/unregister sane callback, the sane_callback in UI module should dispatch the events to these registered callback
virtual int register_sane_callback(sane_callback cb, void* param) =0;
virtual int unregister_sane_callback(sane_callback cb) =0;
// All IO operations are blocking
virtual int io_control(unsigned long code, void* data, unsigned* len) =0;
};