2022-06-23 06:01:28 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "DlgPage.h"
|
|
|
|
|
|
|
|
|
|
// CDlgIndicator 对话框
|
|
|
|
|
|
|
|
|
|
class dlg_area: public dlg_base
|
|
|
|
|
{
|
|
|
|
|
enum paper_unit
|
|
|
|
|
{
|
|
|
|
|
PAPER_UNIT_MM = 0,
|
|
|
|
|
PAPER_UNIT_INCH,
|
|
|
|
|
PAPER_UNIT_PIXEL,
|
|
|
|
|
};
|
|
|
|
|
enum drag_pos
|
|
|
|
|
{
|
|
|
|
|
DRAG_POS_NONE = 0,
|
|
|
|
|
DRAG_POS_LT,
|
|
|
|
|
DRAG_POS_MT,
|
|
|
|
|
DRAG_POS_RT,
|
|
|
|
|
DRAG_POS_LM,
|
|
|
|
|
DRAG_POS_RM,
|
|
|
|
|
DRAG_POS_LB,
|
|
|
|
|
DRAG_POS_MB,
|
|
|
|
|
DRAG_POS_RB,
|
|
|
|
|
DRAG_POS_MOVE,
|
|
|
|
|
};
|
|
|
|
|
typedef struct _drag_block : RECT
|
|
|
|
|
{
|
|
|
|
|
drag_pos pos;
|
|
|
|
|
}DRAGRECT;
|
|
|
|
|
std::wstring paper_;
|
|
|
|
|
paper_unit unit_;
|
|
|
|
|
float paper_w_0_;
|
|
|
|
|
float paper_h_0_;
|
|
|
|
|
float paper_w_;
|
|
|
|
|
float paper_h_;
|
|
|
|
|
float dpi_;
|
|
|
|
|
float x_;
|
|
|
|
|
float y_;
|
|
|
|
|
float w_;
|
|
|
|
|
float h_;
|
|
|
|
|
int exit_code_;
|
|
|
|
|
|
|
|
|
|
RECT whole_;
|
|
|
|
|
RECT user_sel_;
|
|
|
|
|
float ratio_; // mm / pixel
|
|
|
|
|
drag_pos drag_;
|
|
|
|
|
POINT move_;
|
|
|
|
|
bool in_set_func_;
|
|
|
|
|
const wchar_t* cursor_;
|
|
|
|
|
|
|
|
|
|
static int area_min_pixel;
|
|
|
|
|
|
|
|
|
|
BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp) override;
|
|
|
|
|
void handle_command(WORD code, WORD id, HANDLE ctrl);
|
|
|
|
|
|
|
|
|
|
float as_mm(float v);
|
2022-07-05 09:00:55 +00:00
|
|
|
|
float from_mm(float v);
|
2022-06-23 06:01:28 +00:00
|
|
|
|
float as_inches(float v);
|
|
|
|
|
float as_pixels(float v);
|
|
|
|
|
std::wstring format_number(float v);
|
|
|
|
|
void refresh_paper_info(void);
|
|
|
|
|
void to_unit(paper_unit unit);
|
|
|
|
|
void clear_area(void);
|
|
|
|
|
void drag_blocks(std::vector<DRAGRECT>& blocks);
|
|
|
|
|
float pos_2_area(int val, bool x);
|
|
|
|
|
void valid_x(int& x, bool left);
|
|
|
|
|
void valid_y(int& y, bool top);
|
|
|
|
|
|
|
|
|
|
void on_unit_changed(HWND wnd);
|
|
|
|
|
void on_paint(HDC hdc);
|
|
|
|
|
void on_mouse_move(DWORD key, int x, int y);
|
|
|
|
|
void on_lbutton_down(int x, int y);
|
|
|
|
|
void on_lbutton_up(int x, int y);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
dlg_area(HWND parent);
|
|
|
|
|
~dlg_area();
|
|
|
|
|
|
|
|
|
|
static float mm_2_pixel(float mm, float dpi);
|
|
|
|
|
static float mm_2_inches(float mm);
|
|
|
|
|
static float inches_2_pixel(float inch, float dpi);
|
|
|
|
|
static float inches_2_mm(float inch);
|
|
|
|
|
static float pixel_2_mm(float px, float dpi);
|
|
|
|
|
static float pixel_2_inches(float px, float dpi);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void set_paper(const wchar_t* name, float width_mm, float height_mm, float dpi);
|
2022-07-05 09:00:55 +00:00
|
|
|
|
void set_area(float x, float y, float w, float h);
|
2022-06-23 06:01:28 +00:00
|
|
|
|
int do_modal(HWND parent); // return IDOK or IDCANCEL
|
2022-07-05 09:00:55 +00:00
|
|
|
|
float x_in_mm(void);
|
|
|
|
|
float y_in_mm(void);
|
|
|
|
|
float w_in_mm(void);
|
|
|
|
|
float h_in_mm(void);
|
2022-06-23 06:01:28 +00:00
|
|
|
|
};
|