- 用紙設計キャンバス(1/100mm 基準)・テキスト/画像/矩形/直線アイテム - コピー/複製/Zオーダー/整列/グリッドスナップ、原紙(下絵)読込と印刷可否 - GDI 直接印刷、.otz 保存/再読込(版数つき) - MFC/CRT 静的リンクで VS2022 IDE から F5 デバッグ可
64 lines
2.7 KiB
C++
64 lines
2.7 KiB
C++
// LabelLayout.h : ラベルレイアウトのデータモデル(Doc/View に依存しない)
|
|
// 全印刷領域(用紙サイズ)と複数の印刷アイテムを保持し、.otz の保存/読込を行う。
|
|
#pragma once
|
|
|
|
#include "PrintItem.h"
|
|
|
|
class CImageItem;
|
|
|
|
class CLabelLayout
|
|
{
|
|
public:
|
|
CLabelLayout();
|
|
~CLabelLayout();
|
|
|
|
// 全印刷領域(用紙サイズ, 1/100mm)
|
|
int m_paperWidthHu;
|
|
int m_paperHeightHu;
|
|
int m_dpi; // 想定プリンタ解像度(プリセット情報)
|
|
int m_marginHu; // 四辺一律の内側余白(1/100mm, 0=なし)
|
|
|
|
// 原紙(位置合わせ用の背景画像)。用紙全体に敷く下絵。
|
|
// 画面では常に薄く表示し、印刷は m_printTemplate のときだけ行う。
|
|
CImageItem* m_pTemplate; // nullptr = 原紙なし
|
|
BOOL m_printTemplate;// 原紙自身を印刷するか(既定 FALSE)
|
|
|
|
CObArray m_items; // CPrintItem* (描画順 = z オーダー)
|
|
|
|
void AddItem(CPrintItem* p);
|
|
void DeleteItem(CPrintItem* p);
|
|
void RemoveAll();
|
|
int GetItemCount() const { return (int)m_items.GetCount(); }
|
|
CPrintItem* GetItem(int i) const { return (CPrintItem*)m_items.GetAt(i); }
|
|
CPrintItem* HitTest(const CPoint& huPt) const; // 最前面優先。無ければ nullptr
|
|
|
|
// 余白を考慮した内側矩形(整列の基準・ガイド描画用)。余白0なら用紙全体。
|
|
CRect ContentRect() const;
|
|
|
|
// 原紙(背景下絵)操作
|
|
BOOL LoadTemplate(LPCTSTR path); // 読込(用紙全体に敷く)。失敗で FALSE
|
|
void ClearTemplate(); // 原紙を破棄
|
|
CImageItem* Template() const { return m_pTemplate; }
|
|
BOOL HasTemplate() const { return m_pTemplate != nullptr; }
|
|
void SyncTemplateRect(); // 原紙の矩形を現在の用紙サイズに合わせる
|
|
|
|
// 原紙の画素サイズ/埋め込みDPI(取得可なら TRUE)
|
|
BOOL GetTemplatePixelSize(int& w, int& h) const;
|
|
BOOL GetTemplateDpi(double& dx, double& dy) const;
|
|
// 原紙の画素数から用紙サイズを設定。useEmbeddedDpi=TRUE で画像の埋め込み
|
|
// DPI、FALSE(または埋め込み無し)で m_dpi を基準に px→1/100mm 換算する。
|
|
void SetPaperSizeFromTemplate(BOOL useEmbeddedDpi);
|
|
|
|
// z オーダー操作(m_items 内の位置を入替)
|
|
void BringToFront(CPrintItem* p);
|
|
void SendToBack(CPrintItem* p);
|
|
void BringForward(CPrintItem* p);
|
|
void SendBackward(CPrintItem* p);
|
|
|
|
void Reset(); // 既定の空レイアウトに戻す
|
|
|
|
void Serialize(CArchive& ar);
|
|
BOOL SaveToFile(LPCTSTR path);
|
|
BOOL LoadFromFile(LPCTSTR path);
|
|
};
|