- lib/print/pavo/:PavoApiW_x64.dll 的 dart:ffi 绑定(结构体布局对齐 C#,W 后缀导出名回退兼容) - pavo_printer.dart:枚举(UTF-8/UTF-16 自动解码)/状态/色带信息/单卡直打/忙碌轮询(3 分钟超时)/LayerHolder 非托管内存管理 - pavo_backend.dart:全部 ffi 调用与像素转换跑在 Isolate.run,主 isolate HTTP 服务零阻塞 - lib/image/card_image.dart:PNG data URL → 纵横比选卡面 → 手动 alpha 铺白底 → BGR24/Gray8 紧凑像素(image 包 compositeImage 对全透明像素非 src-over 语义,改为逐像素混合对齐 C#) - windows/ 目录:从 Flutter SDK windows.tmpl 手动实例化(mac 上 flutter create 拒绝生成的绕过),窗口标题"饭卡打印助手" - windows/vendor/:收录 SDK 的 PavoApiW_x64.dll/PavoCardSDK_x64.dll/HeatTB3.dll/heatthcd.bin,CMake POST_BUILD 自动拷到 exe 旁 - backend.dart 工厂接通 Windows 分支;analyze 零问题、单测 12 个全过
103 lines
3.4 KiB
C++
103 lines
3.4 KiB
C++
#ifndef RUNNER_WIN32_WINDOW_H_
|
|
#define RUNNER_WIN32_WINDOW_H_
|
|
|
|
#include <windows.h>
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
// A class abstraction for a high DPI-aware Win32 Window. Intended to be
|
|
// inherited from by classes that wish to specialize with custom
|
|
// rendering and input handling
|
|
class Win32Window {
|
|
public:
|
|
struct Point {
|
|
unsigned int x;
|
|
unsigned int y;
|
|
Point(unsigned int x, unsigned int y) : x(x), y(y) {}
|
|
};
|
|
|
|
struct Size {
|
|
unsigned int width;
|
|
unsigned int height;
|
|
Size(unsigned int width, unsigned int height)
|
|
: width(width), height(height) {}
|
|
};
|
|
|
|
Win32Window();
|
|
virtual ~Win32Window();
|
|
|
|
// Creates a win32 window with |title| that is positioned and sized using
|
|
// |origin| and |size|. New windows are created on the default monitor. Window
|
|
// sizes are specified to the OS in physical pixels, hence to ensure a
|
|
// consistent size this function will scale the inputted width and height as
|
|
// as appropriate for the default monitor. The window is invisible until
|
|
// |Show| is called. Returns true if the window was created successfully.
|
|
bool Create(const std::wstring& title, const Point& origin, const Size& size);
|
|
|
|
// Show the current window. Returns true if the window was successfully shown.
|
|
bool Show();
|
|
|
|
// Release OS resources associated with window.
|
|
void Destroy();
|
|
|
|
// Inserts |content| into the window tree.
|
|
void SetChildContent(HWND content);
|
|
|
|
// Returns the backing Window handle to enable clients to set icon and other
|
|
// window properties. Returns nullptr if the window has been destroyed.
|
|
HWND GetHandle();
|
|
|
|
// If true, closing this window will quit the application.
|
|
void SetQuitOnClose(bool quit_on_close);
|
|
|
|
// Return a RECT representing the bounds of the current client area.
|
|
RECT GetClientArea();
|
|
|
|
protected:
|
|
// Processes and route salient window messages for mouse handling,
|
|
// size change and DPI. Delegates handling of these to member overloads that
|
|
// inheriting classes can handle.
|
|
virtual LRESULT MessageHandler(HWND window,
|
|
UINT const message,
|
|
WPARAM const wparam,
|
|
LPARAM const lparam) noexcept;
|
|
|
|
// Called when CreateAndShow is called, allowing subclass window-related
|
|
// setup. Subclasses should return false if setup fails.
|
|
virtual bool OnCreate();
|
|
|
|
// Called when Destroy is called.
|
|
virtual void OnDestroy();
|
|
|
|
private:
|
|
friend class WindowClassRegistrar;
|
|
|
|
// OS callback called by message pump. Handles the WM_NCCREATE message which
|
|
// is passed when the non-client area is being created and enables automatic
|
|
// non-client DPI scaling so that the non-client area automatically
|
|
// responds to changes in DPI. All other messages are handled by
|
|
// MessageHandler.
|
|
static LRESULT CALLBACK WndProc(HWND const window,
|
|
UINT const message,
|
|
WPARAM const wparam,
|
|
LPARAM const lparam) noexcept;
|
|
|
|
// Retrieves a class instance pointer for |window|
|
|
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
|
|
|
// Update the window frame's theme to match the system theme.
|
|
static void UpdateTheme(HWND const window);
|
|
|
|
bool quit_on_close_ = false;
|
|
|
|
// window handle for top level window.
|
|
HWND window_handle_ = nullptr;
|
|
|
|
// window handle for hosted content.
|
|
HWND child_content_ = nullptr;
|
|
};
|
|
|
|
#endif // RUNNER_WIN32_WINDOW_H_
|