tx-gxx-linux/pc/code_twain/sln/hgjson/DlgAddWords.h

116 lines
3.0 KiB
C++

#pragma once
#include "afxdialogex.h"
// CDlgAddWords 对话框
#include <file/file_util.h>
#include <coding/coding.h>
#include <string>
#include <vector>
namespace sdk_util
{
typedef struct _lang_id
{
int id;
int cp;
std::string utf8;
bool operator==(int i)
{
return id == i;
}
bool operator<(struct _lang_id& r)
{
return id < r.id;
}
}LANGID;
typedef struct _lang_id_w
{
int id;
std::wstring unic;
bool operator==(int i)
{
return id == i;
}
bool operator==(const wchar_t* text)
{
return unic == text;
}
bool operator<(struct _lang_id& r)
{
return id < r.id;
}
}LANGIDW;
INTER_MODULE_CALLBACK(got_str);
INTER_MODULE_CALLBACK(got_wstr);
uint32_t make_string_id(const wchar_t* str, bool(*is_repeat)(uint32_t, void*), void* param);
void trim_left(std::wstring& str);
void trim_right(std::wstring& str);
unsigned pick_number(const wchar_t* str, const wchar_t** end, int type);
void convert_unicode(std::wstring& str);
LANGID* lang_info_from_cp(int cp);
LANGID* lang_info_from_ID(int id);
LANGID* lang_info_from_name(const char* utf8);
int save_2_lang_pak(HWND owner, std::vector<LANGID>& items, int cp = 936, std::string* raw_data = NULL, bool to_file = true);
bool parse_pak_digest(uint8_t* data, int* id);
bool parse_pak(uint8_t* data, std::vector<LANGIDW>& items);
bool load_lang_pak(const wchar_t* file, std::vector<LANGIDW>& items, int* id = NULL);
std::wstring get_wnd_text(HWND wnd);
std::wstring get_wnd_text(HWND dlg, UINT id);
enum
{
BOM_ANSI = 0,
BOM_UTF8,
BOM_UNICODE,
};
std::wstring load_file(const wchar_t* file, int* bom = NULL);
int save_file(const wchar_t* file, std::wstring& cont, int bom = BOM_UNICODE);
}
class CDlgAddWords : public CDialogEx
{
DECLARE_DYNAMIC(CDlgAddWords)
public:
CDlgAddWords(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgAddWords();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_BATCH_ADD_LANG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
void open_pak(int lan_id);
void set_lang_pak_file(const wchar_t* file, int lan_id = 0);
void set_code_file(const wchar_t* file, bool tip = true);
bool add_words(const wchar_t* pak_file, std::vector<int>& ids, std::string& cont, int lan_id, int src_col, bool init_id = false);
bool update_head_file(const wchar_t* file, const std::string& cont);
DECLARE_MESSAGE_MAP()
std::vector<sdk_util::LANGIDW> lan_hz_;
std::vector<sdk_util::LANGIDW> lan_hzt_;
std::vector<sdk_util::LANGIDW> lan_eng_;
public:
afx_msg void OnBnClickedButtonBrowseHz();
afx_msg void OnBnClickedButtonBrowseHzt();
afx_msg void OnBnClickedButtonBrowseEng();
afx_msg void OnBnClickedButtonBrowseCode();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnBnClickedButtonDel();
afx_msg void OnBnClickedButtonClear();
afx_msg void OnBnClickedButtonUpdate();
CListCtrl words_;
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
};