/*乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//
    bolfro.h
//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗*/

#define  WINAPI  __stdcall
#define  WINAPIV __cdecl

#define  LOCALF  static __stdcall
#define  LOCALFV static __cdecl

#ifdef __cplusplus
extern "C" {
#endif

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

typedef POINT *pPOINT;
typedef const POINT *rPOINT, *PCPOINT;

typedef POINTS *pPOINTS;
typedef const POINTS *rPOINTS, *PCPOINTS;

typedef RECT *pRECT;
typedef const RECT *rRECT, *PCRECT;

#define  HBMP  HBITMAP
#define  HBRS  HBRUSH
#define  HFNT  HFONT

#define  BGRC  COLORREF

#define  lft  left
#define  rgt  right
#define  btm  bottom

#define  MoveTo(hdc, x, y)  MoveToEx(hdc, x, y, NULL)

typedef LOGFONT *pLOGFONT;
typedef const LOGFONT *rLOGFONT, *PCLOGFONT;

#define  MMPI  25.4
#define  PTPI  72.0

#define  DEFDPI   96
#define  PRNDPI  300

#define  PT2MM(pt)  ((pt) * MMPI / PTPI)

#define  PT2DOTS(pt)  ((I4B)((pt) * DEFDPI / PTPI + 0.5))

#define  DIB_24BITS    0x00000000
#define  DIB_32BITS    0x00000020
#define  DIB_BOTTOMUP  0x00000000
#define  DIB_TOPDOWN   0x00000080

#define  DIB_24B  DIB_24BITS
#define  DIB_32B  DIB_32BITS
#define  DIB_BUP  DIB_BOTTOMUP
#define  DIB_TDN  DIB_TOPDOWN

typedef struct { pANY bi;} HDIB_;
typedef HDIB_ *HDIB;

HDIB WINAPI CreateDIB(I4B w, I4B h, I4B flg);

#define  DIB_WIDTH(bm)       DIB_WID(bm)
#define  DIB_HEIGHT(bm)      DIB_HEI(bm)
#define  DIB_BITS(bm)        DIB_BTS(bm)
#define  DIB_IMAGE_SIZE(bm)  DIB_ISZ(bm)
#define  DIB_LINE_SIZE(bm)   DIB_LSZ(bm)
#define  DIB_IMAGE(bm)       DIB_IMG(bm)

I4B  WINAPI DIB_WID(HDIB bm);
I4B  WINAPI DIB_HEI(HDIB bm);
I4B  WINAPI DIB_BTS(HDIB bm);
I4B  WINAPI DIB_ISZ(HDIB bm);
I4B  WINAPI DIB_LSZ(HDIB bm);
pBIN WINAPI DIB_IMG(HDIB bm);

HDIB WINAPI CreateCompatibleDIB(HDIB bm);
HDIB WINAPI DuplicateDIB(HDIB bm);
void WINAPI DeleteDIB(HDIB bm);
HDIB WINAPI MoveDIB(HDIB bm, HDIB bx);

//typedef struct {
//  I4B   cx;
//  I4B   cy;
//} SIZE;
typedef SIZE *pSIZE; // *PSIZE
typedef const SIZE *rSIZE;

pSIZE WINAPI GetDIBSize(pSIZE sz, HDIB bm);

HDIB WINAPI LoadDIB(HDIB bm, rSTR nam);
BOOL WINAPI SaveDIB(HDIB bm, rSTR nam);

BOOL WINAPI ConvertDIB(HDIB bm, I4B flg);

HDIB WINAPI LoadBMP(HDIB bm, rSTR nam);
BOOL WINAPI SaveBMP(HDIB bm, rSTR nam);

HDIB WINAPI CreateDIBFromIMG(HIMG im);
HIMG WINAPI CreateIMGFromDIB(HDIB bm);

BOOL WINAPI ChangeDIBColor(HDIB bm, FCVT fcvt, uANY pa);
BOOL WINAPI SuperposeDIB(HDIB bm, HDIB bx, I4B x, I4B y, FOPR fopr, uANY pa);
BOOL WINAPI PasteDIB(HDIB bm, HDIB bx, I4B x, I4B y);
BOOL WINAPI TrimDIB(HDIB bm, I4B x, I4B y, I4B w, I4B h, RGBC cb);
BOOL WINAPI TransformDIBX(HDIB bm, I4B w, I4B h, FXFM fxfm, uANY pa, RGBC cb);
BOOL WINAPI TransformDIB(HDIB bm, rXFMQ q, RGBC cb);

#define  DIB_HORIZONTAL  IMG_HORIZONTAL
#define  DIB_VERTICAL    IMG_VERTICAL

#define  DIB_HRZ  DIB_HORIZONTAL
#define  DIB_VRT  DIB_VERTICAL

BOOL WINAPI InvertDIB(HDIB bm, I4B sw);
BOOL WINAPI RotateDIB(HDIB bm, F8B dg, RGBC cb);

#define  DIB_MEAN    IMG_MEAN
#define  DIB_LINEAR  IMG_LINEAR
#define  DIB_SMOOTH  IMG_SMOOTH
#define  DIB_SHARP   IMG_SHARP

#define  DIB_MEA  DIB_MEAN
#define  DIB_LIN  DIB_LINEAR
#define  DIB_SMO  DIB_SMOOTH
#define  DIB_SHA  DIB_SHARP

BOOL WINAPI ResizeDIBX(HDIB bm, I4B w, I4B h, I4B sw);

#define  ResizeDIB(bm, w, h)  ResizeDIBX(bm, w, h, DIB_MEA)

HDIB WINAPI CaptureDIB(HDIB bm, HDC hdc, rRECT pr);

HDIB WINAPI CreateDIBFromDDB(HBMP hbmp);
HBMP WINAPI CreateDDBFromDIB(HDIB bm);

#define  DT_FORCETOP      0x00000004
//#define  DT_LEFT          0x00000000
//#define  DT_CENTER        0x00000001
//#define  DT_RIGHT         0x00000002
#define  DT_DEFAULT       0x00000000
//#define  DT_BOTTOM        0x00000008
//#define  DT_CALCRECT      0x00000400
#define  DT_ADJUSTWIDTH   0x02000000
#define  DT_ADJUSTHEIGHT  0x04000000
#define  DT_GRAYED        0x08000000
#define  DT_STRETCH      (DT_ADJUSTWIDTH|DT_ADJUSTHEIGHT)
#define  DT_CLIP          0x40000000

#define  DT_FRC  DT_FORCETOP
#define  DT_LFT  DT_LEFT
#define  DT_CEN  DT_CENTER
#define  DT_RGT  DT_RIGHT
#define  DT_MID  DT_DEFAULT
#define  DT_BTM  DT_BOTTOM
#define  DT_CAL  DT_CALCRECT
#define  DT_AJW  DT_ADJUSTWIDTH
#define  DT_AJH  DT_ADJUSTHEIGHT
#define  DT_GRY  DT_GRAYED
#define  DT_STB  DT_STRETCH
#define  DT_CLP  DT_CLIP

#define  DTisMID(fmt)  (!(fmt & (DT_FRC|DT_BTM)))

BOOL WINAPI DrawDIB(HDC hdc, pRECT pr, HDIB bm, I4B fmt);
BOOL WINAPI DrawDDB(HDC hdc, pRECT pr, HBMP hbmp, I4B fmt);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

RGBC WINAPI BGR2RGB(BGRC cr);
#define  RGB2BGR(cr)  BGR2RGB(cr)
BGRC WINAPI BKG2TXT(BGRC cr);
BGRC WINAPI lighten(BGRC cr, uANY pa);

#define  CID_WINDOWTEXT     0
#define  CID_RED            2
#define  CID_WINDOW         7
#define  CID_3DSHADOW       8
#define  CID_3DFACE        15
#define  CID_3DDKSHADOW    16
#define  CID_3DHILIGHT     23
#define  CID_CELLPTR       24
#define  CID_INDEXPTR      31
#define  CID_HIGHLIGHT     32
#define  CID_HIGHLIGHTTEXT 40
#define  CID_3DLIGHT       48
#define  CID_BLACK         49
#define  CID_GRAY          55
#define  CID_WHITE         63
#define  CID_GRAYTEXT      16
#define  CID_INFOBK        38
#define  CID_APPWORKSPACE  58
#define  CID_ACTBORDER     16
#define  CID_INACTBORDER   60

#define  CID_TXT  CID_WINDOWTEXT
#define  CID_WIN  CID_WINDOW
#define  CID_3DS  CID_3DSHADOW
#define  CID_3DF  CID_3DFACE
#define  CID_3DD  CID_3DDKSHADOW
#define  CID_3DH  CID_3DHILIGHT
#define  CID_PTR  CID_CELLPTR
#define  CID_IDX  CID_INDEXPTR
#define  CID_HIL  CID_HIGHLIGHT
#define  CID_HIT  CID_HIGHLIGHTTEXT
#define  CID_3DL  CID_3DLIGHT
#define  CID_BLK  CID_BLACK
#define  CID_GRY  CID_GRAY
#define  CID_WHI  CID_WHITE
#define  CID_GTX  CID_GRAYTEXT
#define  CID_INF  CID_INFOBK
#define  CID_WRK  CID_APPWORKSPACE
#define  CID_ACT  CID_ACTBORDER
#define  CID_INA  CID_INACTBORDER

I4B  WINAPI NAppColors(void);
void WINAPI SetAppColor(I4B cid, BGRC col);
BGRC WINAPI AppColor(I4B cid);
I1B  WINAPI AppColorChar(I4B cid);
I4B  WINAPI AppColorIndex(I1B ch);
I4B  WINAPI NearestAppColorIndex(BGRC col);

HIMG WINAPI CreateIMGFromSTR(I4B w, I4B h, rSTR bi);
HDIB WINAPI CreateDIBFromSTR(I4B w, I4B h, rSTR bi);
HBMP WINAPI CreateDDBFromSTR(I4B w, I4B h, rSTR bi);

HPEN WINAPI AppPen(I4B cid);
HBRS WINAPI AppBrush(I4B cid);

#define  TFF_BOLD       0x0070
#define  TFF_ITALIC     0x0100
#define  TFF_UNDERLINE  0x0200
#define  TFF_STRIKEOUT  0x0400
#define  TFF_VERTICAL   0x1000

#define  TFF_BLD  TFF_BOLD
#define  TFF_ITA  TFF_ITALIC
#define  TFF_UND  TFF_UNDERLINE
#define  TFF_STO  TFF_STRIKEOUT
#define  TFF_VRT  TFF_VERTICAL

pLOGFONT WINAPI SetLOGFONT(pLOGFONT lf, rSTR face, I4B ch, I4B flg);

void WINAPI GetTextSize(pSIZE sz, HDC hdc, rLOGFONT lf, rSTR st, I4B cb);
void WINAPI GetAveCharSize(pSIZE sz, HDC hdc, rLOGFONT lf);
void WINAPI GetZenCharSize(pSIZE sz, HDC hdc, rLOGFONT lf);

#define  FID_DIALOG       0
#define  FID_SYSTEM       1
#define  FID_DEFAULT      2
#define  FID_MONOSPACE    3
#define  FID_WEBDINGS     4
#define  FID_WINGDINGS    5
#define  FID_USER         6

#define  FID_DLG  FID_DIALOG
#define  FID_SYS  FID_SYSTEM
#define  FID_DEF  FID_DEFAULT
#define  FID_MON  FID_MONOSPACE
#define  FID_WEB  FID_WEBDINGS
#define  FID_WIN  FID_WINGDINGS
#define  FID_USR  FID_USER

I4B  WINAPI NAppFonts(void);
void WINAPI SetAppFont(I4B fid, HFNT hfnt);
HFNT WINAPI AppFont(I4B fid);

#define  MNUBMPW  16
#define  MNUBMPH  16

#define  BID_BLANK    0
#define  BID_NEW      1
#define  BID_OPEN     2
#define  BID_CLOSE    3
#define  BID_SAVE     4
#define  BID_SAVEAS   5
#define  BID_PRINT    6
#define  BID_SETUP    7
#define  BID_CUT      8
#define  BID_COPY     9
#define  BID_PASTE   10
#define  BID_SEARCH  11
#define  BID_SORT    12
#define  BID_FILTER  13
#define  BID_SUMMARY 14
#define  BID_CHECK   15
#define  BID_PREV    16
#define  BID_NEXT    17
#define  BID_INVERT  18
#define  BID_ZOOMIN  19
#define  BID_ZOOMOUT 20
#define  BID_SAME    21
#define  BID_WHOLE   22
#define  BID_PREVWIN 23
#define  BID_NEXTWIN 24
#define  BID_VIEW    25
#define  BID_ARRANGE 26
#define  BID_EDIT    27
#define  BID_ADD     28
#define  BID_INSERT  29
#define  BID_DELETE  30
#define  BID_COMPILE 31

#define  MNDBMPW  32
#define  MNDBMPH  32

#define  BID_DUMMY   48
#define  BID_INPUT   49
#define  BID_TABLE   50
#define  BID_EXECUTE 51
#define  BID_REPORT  52
#define  BID_TEXT    53
#define  BID_SYSTEM  54
#define  BID_EXIT    55
#define  BID_BACK    56

I4B  WINAPI NAppDDBs(void);
void WINAPI SetAppDDB(I4B bid, HBMP hbmp);
HBMP WINAPI AppDDB(I4B bid);

void WINAPI SetMenuItemDDB(I4B idm, HBMP hbmp);
HBMP WINAPI MenuItemDDB(I4B idm);

#define  DLGFACE  "MS UI Gothic"
#define  DLGPTSZ  9

#define  DEFFACE  "俵俽 俹僑僔僢僋"
#define  DEFPTSZ  11

#define  MONFACE  "俵俽 僑僔僢僋"
#define  MONPTSZ  11

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

typedef struct { I4B unused;} HCVS_;
typedef HCVS_ *HCVS;

HCVS WINAPI CreateCanvas(HDC hdc, U4B xsz);
void WINAPI DeleteCanvas(HCVS cv);

HDC  WINAPI SetCanvasHDC(HCVS cv, HDC hdc, I4B dpi);
HDC  WINAPI CanvasHDC(HCVS cv);
HDC  WINAPI CanvasHIC(HCVS cv);
BOOL WINAPI EnableCanvas(HCVS cv);
BOOL WINAPI DisableCanvas(HCVS cv);
pLOGFONT WINAPI CanvasLOGFONT(pLOGFONT lf, HCVS cv);

void WINAPI SetOrigin(HCVS cv, F8B xorg, F8B yorg);
F8B  WINAPI OriginX(HCVS cv);
F8B  WINAPI OriginY(HCVS cv);
void WINAPI SetScale(HCVS cv, F8B xscl, F8B yscl);
F8B  WINAPI ScaleX(HCVS cv);
F8B  WINAPI ScaleY(HCVS cv);

I4B  WINAPI c2dW(HCVS cv, F8B w);
I4B  WINAPI c2dH(HCVS cv, F8B h);
I4B  WINAPI c2dX(HCVS cv, F8B x);
I4B  WINAPI c2dY(HCVS cv, F8B y);
F8B  WINAPI d2cW(HCVS cv, I4B w);
F8B  WINAPI d2cH(HCVS cv, I4B h);
F8B  WINAPI d2cX(HCVS cv, I4B x);
F8B  WINAPI d2cY(HCVS cv, I4B y);

typedef struct {
  F8B   x1;
  F8B   y1;
  F8B   x2;
  F8B   y2;
} CELL;
typedef CELL *pCELL, *PCELL;
typedef const CELL *rCELL, *PCCELL;

pCELL WINAPI SetCell(pCELL pc, F8B x1, F8B y1, F8B x2, F8B y2);

pRECT WINAPI c2dRect(pRECT pr, HCVS cv, rCELL pc);
pCELL WINAPI d2cCell(pCELL pc, HCVS cv, rRECT pr);

pCELL WINAPI MoveCell(pCELL pc, F8B dx, F8B dy);
pCELL WINAPI ResizeCell(pCELL pc, F8B dx, F8B dy);
pCELL WINAPI ReshapeCell(pCELL pc, F8B lm, F8B tm, F8B rm, F8B bm);

void WINAPI SetCellMargin(HCVS cv, F8B hcmg, F8B vcmg);
#define  CellMarginHD(cv)  c2dW(cv, CellMarginH(cv))
F8B  WINAPI CellMarginH(HCVS cv);
#define  CellMarginVD(cv)  c2dH(cv, CellMarginV(cv))
F8B  WINAPI CellMarginV(HCVS cv);

#define  LST_NULL        0x00
#define  LST_THIN        0x01
#define  LST_REGULAR     0x02
#define  LST_MEDIUM      0x03
#define  LST_THICK       0x04
#define  LST_EXTRATHICK  0x05
#define  LST_DASH        0x10
#define  LST_DOT         0x20
#define  LST_DASHDOT     0x30
#define  LST_DASHDOTDOT  0x40

#define  LST_NUL  LST_NULL
#define  LST_THN  LST_THIN
#define  LST_REG  LST_REGULAR
#define  LST_MED  LST_MEDIUM
#define  LST_THK  LST_THICK
#define  LST_XTK  LST_EXTRATHICK
#define  LST_DSH  LST_DASH
#define  LST_DSD  LST_DASHDOT
#define  LST_DDD  LST_DASHDOTDOT

#define  lstN  LST_NUL
#define  lstI  LST_THN
#define  lstR  LST_REG
#define  lstM  LST_MED
#define  lstB  LST_THK
#define  lstX  LST_XTK
#define  lstD  LST_DOT

I4B  WINAPI SetLineStyle(HCVS cv, I4B lst);
BGRC WINAPI SetLineColor(HCVS cv, BGRC col);

#define  SetTextFontD(cv, face, ch, flg, col)  SetTextFont(cv, face, d2cH(cv, ch), flg, col)
void WINAPI SetTextFont(HCVS cv, rSTR face, F8B ch, I4B flg, BGRC col);
#define  SetTextStyleD(cv, cw, ch, cd, face)  SetTextStyle(cv, d2cW(cv, cw), d2cH(cv, ch), d2cW(cv, cd), face)
void WINAPI SetTextStyle(HCVS cv, F8B cw, F8B ch, F8B cd, rSTR face);

typedef struct {
  F8B   w;
  F8B   h;
} WHSZ;
typedef WHSZ *pWHSZ, *PWHSZ;

pWHSZ WINAPI TextSize(pWHSZ sz, HCVS cv, rSTR st, I4B cb);
pSIZE WINAPI TextSizeD(pSIZE sz, HCVS cv, rSTR st, I4B cb);
pWHSZ WINAPI AveCharSize(pWHSZ sz, HCVS cv);
pSIZE WINAPI AveCharSizeD(pSIZE sz, HCVS cv);
pWHSZ WINAPI ZenCharSize(pWHSZ sz, HCVS cv);
pSIZE WINAPI ZenCharSizeD(pSIZE sz, HCVS cv);

void WINAPI DrawLineD(HCVS cv, I4B x1, I4B y1, I4B x2, I4B y2);
void WINAPI DrawLine(HCVS cv, F8B x1, F8B y1, F8B x2, F8B y2);
#define  DrawCircD(cv, xc, yc, rc, t1, t2)  DrawCirc(cv, d2cX(cv, xc), d2cY(cv, yc), d2cW(cv, rc), t1, t2)
void WINAPI DrawCirc(HCVS cv, F8B xc, F8B yc, F8B rc, F8B t1, F8B t2);

#define  RST_NULL                 0
#define  RST_DEFAULT            (-1)
#define  RST_THIN        0x01010101
#define  RST_REGULAR     0x02020202
#define  RST_MEDIUM      0x03030303
#define  RST_THICK       0x04040404
#define  RST_EXTRATHICK  0x05050505
#define  RST_DASH        0x10101010
#define  RST_DOT         0x20202020
#define  RST_DASHDOT     0x30303030
#define  RST_DASHDOTDOT  0x40404040

#define  RST_NUL  RST_NULL
#define  RST_DEF  RST_DEFAULT
#define  RST_THN  RST_THIN
#define  RST_REG  RST_REGULAR
#define  RST_MED  RST_MEDIUM
#define  RST_THK  RST_THICK
#define  RST_XTK  RST_EXTRATHICK
#define  RST_DSH  RST_DASH
#define  RST_DSD  RST_DASHDOT
#define  RST_DDD  RST_DASHDOTDOT

#define  RST(llst, tlst, rlst, blst)  OCTVAL(llst, tlst, rlst, blst)

void WINAPI DrawCellD(HCVS cv, rRECT pr, I4B rst);
void WINAPI DrawCell(HCVS cv, rCELL pc, I4B rst);
void WINAPI FillCellD(HCVS cv, rRECT pr, I4B rst, BGRC col);
void WINAPI FillCell(HCVS cv, rCELL pc, I4B rst, BGRC col);

typedef struct {
  F8B   x;
  F8B   y;
} XYPT;
typedef XYPT *pXYPT, *PXYPT;
typedef const XYPT *rXYPT, *PCXYPT;

void WINAPI FillPolyD(HCVS cv, rPOINT pt, I4B np, BGRC col);
void WINAPI FillPoly(HCVS cv, rXYPT pt, I4B np, BGRC col);
#define  FillCircD(cv, xc, yc, rc, t1, t2, col)  FillCirc(cv, d2cX(cv, xc), d2cY(cv, yc), d2cW(cv, rc), t1, t2, col)
void WINAPI FillCirc(HCVS cv, F8B xc, F8B yc, F8B rc, F8B t1, F8B t2, BGRC col);

#define  DT_FORCETOP      0x00000004
//#define  DT_LEFT          0x00000000
//#define  DT_CENTER        0x00000001
//#define  DT_RIGHT         0x00000002
#define  DT_DEFAULT       0x00000000
//#define  DT_BOTTOM        0x00000008
//#define  DT_CALCRECT      0x00000400
//#define  DT_PATH_ELLIPSIS 0x00004000
//#define  DT_END_ELLIPSIS  0x00008000
#define  DT_MULTILINE     0x01000000
#define  DT_JUSTIFY       0x02000000
#define  DT_AUTONARROWING 0x04000000
#define  DT_PREFIX        0x08000000
#define  DT_CLIP          0x40000000

#define  DT_FRC  DT_FORCETOP
#define  DT_LFT  DT_LEFT
#define  DT_CEN  DT_CENTER
#define  DT_RGT  DT_RIGHT
#define  DT_MID  DT_DEFAULT
#define  DT_BTM  DT_BOTTOM
#define  DT_CAL  DT_CALCRECT
#define  DT_PEL  DT_PATH_ELLIPSIS
#define  DT_EEL  DT_END_ELLIPSIS
#define  DT_MUL  DT_MULTILINE
#define  DT_JST  DT_JUSTIFY
#define  DT_AUT  DT_AUTONARROWING
#define  DT_PRE  DT_PREFIX
#define  DT_CLP  DT_CLIP

void WINAPI CellTextD(HCVS cv, pRECT pc, rSTR st, I4B fmt);
void WINAPI CellText(HCVS cv, pCELL pc, rSTR st, I4B fmt);

#define  VT_LEFT          0x00000001
#define  VT_CENTER        0x00000000
#define  VT_RIGHT         0x00000002
#define  VT_TOP           0x00000000
#define  VT_VCENTER       0x00000004
#define  VT_BOTTOM        0x00000008
#define  VT_CALCRECT      0x00000400

#define  VT_LFT  VT_LEFT
#define  VT_CEN  VT_CENTER
#define  VT_RGT  VT_RIGHT
#define  VT_MID  VT_VCENTER
#define  VT_BTM  VT_BOTTOM
#define  VT_CAL  VT_CALCRECT

void WINAPI VCellTextD(HCVS cv, pRECT pc, rSTR st, I4B fmt);
void WINAPI VCellText(HCVS cv, pCELL pc, rSTR st, I4B fmt);

typedef struct {
  F8B   x0;
  F8B   y0;
  F8B   dcw;
  F8B   drh;
  F8B   *cw;
  I4B   nc;
  F8B   *rh;
  I4B   nr;
} GRID;
typedef GRID *pGRID, *PGRID;
typedef const GRID *rGRID, *PCGRID;

void WINAPI SetGrid0(pGRID gr, F8B x0, F8B y0, I4B nc, I4B nr, F8B dcw, F8B drh);
void WINAPI SetGrid1(pGRID gr, F8B x0, F8B y0, I4B nc, I4B nr, F8B *cw, F8B drh);
void WINAPI SetGrid2(pGRID gr, F8B x0, F8B y0, I4B nc, I4B nr, F8B dcw, F8B *rh);
void WINAPI SetGrid3(pGRID gr, F8B x0, F8B y0, I4B nc, I4B nr, F8B *cw, F8B *rh);

pGRID WINAPI AdjustGrid(HCVS cv, pGRID gr);
pCELL WINAPI GridCell(pCELL pc, rGRID gr, I4B ir, I4B ic);

#define  RST_THIN_REGULAR       (-2)
#define  RST_THIN_MEDIUM        (-3)
#define  RST_THIN_THICK         (-4)
#define  RST_REGULAR_MEDIUM     (-5)
#define  RST_REGULAR_THICK      (-6)
#define  RST_REGULAR_EXTRATHICK (-7)

#define  RST_I_R  RST_THIN_REGULAR
#define  RST_I_M  RST_THIN_MEDIUM
#define  RST_I_B  RST_THIN_THICK
#define  RST_R_M  RST_REGULAR_MEDIUM
#define  RST_R_B  RST_REGULAR_THICK
#define  RST_R_X  RST_REGULAR_EXTRATHICK

void WINAPI DrawGridCell(HCVS cv, rGRID gr, I4B ir, I4B ic, I4B rst);
void WINAPI GridCellText(HCVS cv, rGRID gr, I4B ir, I4B ic, I4B rst, rSTR st, I4B fmt);

typedef struct {
  I4B   sty;
  rSTR  st1;
  rSTR  st2;
  rSTR  st3;
  F8B   dc;
} STMP;
typedef STMP *pSTMP, *PSTMP;
typedef const STMP *rSTMP, *PCSTMP;

void WINAPI SetStamp0(pSTMP ps, F8B dc, rSTR st);
void WINAPI SetStamp1(pSTMP ps, F8B dc, rSTR st);
void WINAPI SetStamp2(pSTMP ps, F8B dc, rSTR st1, rSTR st2);
void WINAPI SetStamp3(pSTMP ps, F8B dc, rSTR st1, rSTR st2, rSTR st3);

void WINAPI CellStampD(HCVS cv, rRECT pr, rSTMP ps);
void WINAPI CellStamp(HCVS cv, rCELL pc, rSTMP ps);

void WINAPI CellImageD(HCVS cv, pRECT pc, HDIB bm, I4B fmt);
void WINAPI CellImage(HCVS cv, pCELL pc, HDIB bm, I4B fmt);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

//#define  WS_OVERLAPPED       0x00000000
//#define  WS_POPUP            0x80000000
//#define  WS_CHILD            0x40000000
//#define  WS_MINIMIZE         0x20000000
//#define  WS_VISIBLE          0x10000000
//#define  WS_DISABLED         0x08000000
//#define  WS_CLIPSIBLINGS     0x04000000
//#define  WS_CLIPCHILDREN     0x02000000
//#define  WS_MAXIMIZE         0x01000000
//#define  WS_CAPTION          0x00C00000
//#define  WS_BORDER           0x00800000
//#define  WS_DLGFRAME         0x00400000
//#define  WS_VSCROLL          0x00200000
//#define  WS_HSCROLL          0x00100000
//#define  WS_SYSMENU          0x00080000
//#define  WS_THICKFRAME       0x00040000
//#define  WS_GROUP            0x00020000
//#define  WS_TABSTOP          0x00010000
//#define  WS_MINIMIZEBOX      0x00020000
//#define  WS_MAXIMIZEBOX      0x00010000
//#define  WS_OVERLAPPEDWINDOW 0x00CF0000
//#define  WS_POPUPWINDOW      0x80880000

//#define  DS_MODALFRAME       0x0080

#define  ws_    0
#define  wsT    WS_TABSTOP
#define  wsG    WS_GROUP
#define  wsGT   (WS_GROUP|WS_TABSTOP)
#define  wsH    WS_HSCROLL
#define  wsV    WS_VSCROLL
#define  wsHV   (WS_HSCROLL|WS_VSCROLL)
#define  wsB    WS_BORDER
#define  wsBV   (WS_BORDER|WS_VSCROLL)
#define  wsBH   (WS_BORDER|WS_HSCROLL)
#define  wsBHV  (WS_BORDER|WS_HSCROLL|WS_VSCROLL)
#define  wsC    (WS_CHILD|WS_VISIBLE)
#define  wsCV   (WS_CHILD|WS_VISIBLE|WS_VSCROLL)
#define  wsCH   (WS_CHILD|WS_VISIBLE|WS_HSCROLL)
#define  wsCHV  (WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL)
#define  wsCB   (WS_CHILD|WS_VISIBLE|WS_BORDER)
#define  wsCBV  (WS_CHILD|WS_VISIBLE|WS_BORDER|WS_VSCROLL)
#define  wsCBH  (WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL)
#define  wsCBHV (WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL)
#define  wsD    WS_DISABLED
#define  wsDlg  (WS_POPUP|WS_CAPTION|WS_SYSMENU|DS_MODALFRAME)
#define  wsMls  (wsDlg|WS_VISIBLE)

#define  WindowInstance(hwnd)       (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE)
#define  WindowID(hwnd)             GetWindowLong(hwnd, GWL_ID)
#define  WindowStyle(hwnd)          (U4B)GetWindowLong(hwnd, GWL_STYLE)
#define  WindowExStyle(hwnd)        (U4B)GetWindowLong(hwnd, GWL_EXSTYLE)

#define  SubclassWindow(hwnd, lpfn)    (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (iANY)(lpfn))
#define  ResizeWindow(hwnd, cx, cy)    SetWindowPos(hwnd, NULL, 0, 0, cx, cy, SWP_NOMOVE|SWP_NOZORDER)
#define  EnableDlgItem(hdlg, id, sw)   EnableWindow(GetDlgItem(hdlg, id), sw)

iANY WINAPI ParentNotify(HWND hwnd, I4B nc, iANY lpa);

rSTR WINAPI WindowText(HWND hwnd);
rSTR WINAPI ClassName(HWND hwnd);

void WINAPI CenterWindow(HWND hwnd, HWND hown);
void WINAPI AdjustWindow(HWND hwnd, rRECT pr);

I4B  WINAPI SetHScrollBar(HWND hwnd, I4B min, I4B max, I4B psz, I4B pos);
I4B  WINAPI SetVScrollBar(HWND hwnd, I4B min, I4B max, I4B psz, I4B pos);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

//#define  MF_ENABLED          0x00000000
//#define  MF_GRAYED           0x00000001
//#define  MF_CHECKED          0x00000008
//#define  MF_POPUP            0x00000010
//#define  MF_END              0x00000080

#define  mf_    MF_ENABLED
#define  mfG    MF_GRAYED
#define  mfC    MF_CHECKED
#define  mfP    MF_POPUP
#define  mfE    MF_END
#define  mfPE   (MF_POPUP|MF_END)
#define  mfGE   (MF_GRAYED|MF_END)

typedef struct {
  I4B   flg;
  I4B   idm;
  rSTR  txt;
  U4B   rsv;
} MNUI;
typedef MNUI *pMNUI, *PMNUI;
typedef const MNUI *rMNUI, *PCMNUI;

typedef struct {
  pMNUI mi;
  I4B   ni;
} MNUS;
typedef MNUS *pMNUS, *PMNUS;
typedef const MNUS *rMNUS, *PCMNUS;

HMENU WINAPI CreateMenuBar(rMNUS ms);
BOOL WINAPI ChangeMenuBar(HMENU hmnu, I4B pos, rMNUS ms);

void WINAPI MenuSlice(pI4B p1, pI4B p2, rMNUS ms, I4B pos);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

typedef struct {
  I4B   x, y;
  rSTR  txt;
} TIPI;
typedef TIPI *pTIPI, *PTIPI;
typedef const TIPI *rTIPI, *PCTIPI;

HWND WINAPI CreateToolTip(HWND hwnd, rTIPI pi);

#define  TOBM_GETNITEMS        (WM_USER + 0x01)
#define  TOBM_GETITEMINFO      (WM_USER + 0x02)
#define  TOBM_RESETITEMS       (WM_USER + 0x03)

#define  TOBI_SPACE   0
#define  TOBI_VLINE   1
#define  TOBI_BUTTON  2
#define  TOBI_SLEFT   3
#define  TOBI_SCENTER 4
#define  TOBI_SRIGHT  5

#define  tbfV  TOBI_VLINE
#define  tbfB  TOBI_BUTTON

#define  tbfS(w)  MKU4B(TOBI_SPACE, w)
#define  tbfL(w)  MKU4B(TOBI_SLEFT, w)
#define  tbfC(w)  MKU4B(TOBI_SCENTER, w)
#define  tbfR(w)  MKU4B(TOBI_SRIGHT, w)

#define  TOBWINH  28
#define  STBWINH  22
#define  TOBSEPW   6
#define  TOBMGNW   2
#define  TOBBTNW  24
#define  TOBBTNH  24
#define  TOBSTAH  16

typedef struct {
  I4B   flg;
  I4B   idm;
  rSTR  txt;
  U4B   rsv;
} TOBI;
typedef TOBI *pTOBI, *PTOBI;
typedef const TOBI *rTOBI, *PCTOBI;

typedef struct {
  pTOBI pi;
  I4B   ni;
} TOBS;
typedef TOBS *pTOBS, *PTOBS;
typedef const TOBS *rTOBS, *PCTOBS;

HWND WINAPI CreateToolBar(HWND hwnd, I4B id, rTOBS ts);
HWND WINAPI CreateStatBar(HWND hwnd, I4B id, rTOBS ss);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

#define  SetSSTR(hdlg, id, st)  SetDlgItemText(hdlg, id, st)
#define  GetSSTR(hdlg, id, st, len)  GetDlgItemText(hdlg, id, st, len)

#define  SetBSTR(hdlg, id, st)  SetSSTR(hdlg, id, st)
#define  GetBSTR(hdlg, id, st, len)  GetSSTR(hdlg, id, st, len)

void WINAPI SetBFLG(HWND hdlg, I4B id, BOOL va);
BOOL WINAPI GetBFLG(HWND hdlg, I4B id);

#define  SetBSEL(hdlg, id, va)  SetBFLG(hdlg, id, va)
#define  GetBSEL(hdlg, id)  GetBFLG(hdlg, id)

#define  SetESTR(hdlg, id, st)  SetSSTR(hdlg, id, st)
#define  GetESTR(hdlg, id, st, len)  GetSSTR(hdlg, id, st, len)

void WINAPI SetEINT(HWND hdlg, I4B id, I4B va);
I4B  WINAPI GetEINT(HWND hdlg, I4B id);

void WINAPI SetEDBL(HWND hdlg, I4B id, F8B va);
F8B  WINAPI GetEDBL(HWND hdlg, I4B id);

void WINAPI SetLSEL(HWND hdlg, I4B id, I4B ir, rENMS ls);
I4B  WINAPI GetLSEL(HWND hdlg, I4B id);

void WINAPI SetCSEL(HWND hdlg, I4B id, I4B ir, rENMS ls);
I4B  WINAPI GetCSEL(HWND hdlg, I4B id);

void WINAPI SetCCOD(HWND hdlg, I4B id, I4B va, rCODS ls);
I4B  WINAPI GetCCOD(HWND hdlg, I4B id, rCODS ls);

void WINAPI SetCSTR(HWND hdlg, I4B id, rSTR st, rENMS ls);
#define  GetCSTR(hdlg, id, st, len)  GetSSTR(hdlg, id, st, len)

//#define  SS_LEFT             0x0000
//#define  SS_CENTER           0x0001
//#define  SS_RIGHT            0x0002
//#define  SS_ICON             0x0003
//#define  SS_OWNERDRAW        0x000d
//#define  SS_BITMAP           0x000e
//#define  SS_CENTERIMAGE      0x0200

#define  ssL    (SS_CENTERIMAGE|SS_LEFT)
#define  ssC    (SS_CENTERIMAGE|SS_CENTER)
#define  ssR    (SS_CENTERIMAGE|SS_RIGHT)
#define  ssM    SS_LEFT
#define  ssI    SS_ICON
#define  ssO    SS_OWNERDRAW
#define  ssB    SS_BITMAP

//#define  BS_PUSHBUTTON       0x0000
//#define  BS_DEFPUSHBUTTON    0x0001
//#define  BS_AUTOCHECKBOX     0x0003
//#define  BS_GROUPBOX         0x0007
//#define  BS_AUTORADIOBUTTON  0x0009
//#define  BS_OWNERDRAW        0x000b
//#define  BS_FLAT             0x8000

#define  bsP    BS_PUSHBUTTON
#define  bsD    BS_DEFPUSHBUTTON
#define  bsC    BS_AUTOCHECKBOX
#define  bsR    BS_AUTORADIOBUTTON
#define  bsG    BS_GROUPBOX
#define  bsO    BS_OWNERDRAW
#define  bsF    BS_FLAT

//#define  ES_LEFT             0x0000
//#define  ES_CENTER           0x0001
//#define  ES_RIGHT            0x0002
//#define  ES_MULTILINE        0x0004
//#define  ES_PASSWORD         0x0020
//#define  ES_AUTOVSCROLL      0x0040
//#define  ES_AUTOHSCROLL      0x0080
//#define  ES_READONLY         0x0800
//#define  ES_WANTRETURN       0x1000

#define  esV    ES_AUTOVSCROLL
#define  esH    ES_AUTOHSCROLL
#define  esP    ES_PASSWORD
#define  esC    ES_CENTER
#define  esR    ES_RIGHT
#define  esM    (ES_MULTILINE|ES_WANTRETURN)

//#define  LBS_NOTIFY          0x0001
//#define  LBS_USETABSTOPS     0x0080

#define  lbsNT  (LBS_NOTIFY|LBS_USETABSTOPS)

//#define  CBS_DROPDOWN        0x0002
//#define  CBS_DROPDOWNLIST    0x0003
//#define  CBS_AUTOHSCROLL     0x0040

#define  cbsL   CBS_DROPDOWNLIST
#define  cbsDH  (CBS_DROPDOWN|CBS_AUTOHSCROLL)

//#define  PSH_PROPSHEETPAGE   0x0008
//#define  PSH_WIZARD          0x0020
//#define  PSH_NOAPPLYNOW      0x0080

#define  pshP   PSH_PROPSHEETPAGE
#define  pshW   PSH_WIZARD
#define  pshN   PSH_NOAPPLYNOW

#define  C_SLFT  "static", wsC | ssL
#define  C_SCEN  "static", wsC | ssC
#define  C_SRGT  "static", wsC | ssR
#define  C_SMUL  "static", wsC | ssM
#define  C_SICO  "static", wsC | ssI
#define  C_SOWN  "static", wsC | ssO
#define  C_SBMP  "static", wsC | ssB
#define  C_BPSH  "button", wsC | bsP
#define  C_BDEF  "button", wsC | bsD
#define  C_BFLG  "button", wsC | bsC
#define  C_BSEL  "button", wsC | bsR
#define  C_BGRP  "button", wsC | bsG
#define  C_BOWN  "button", wsC | bsO
#define  C_BFLT  "button", wsC | bsF
#define  C_ENUM  "edit", wsCB | esR
#define  C_ESTR  "edit", wsCB | esH
#define  C_EPWD  "edit", wsCB | esP
#define  C_EMUL  "edit", wsCBV | esM | esV
#define  C_LSEL  "listbox", wsCBV
#define  C_LTBL  "listbox", wsCBV | lbsNT
#define  C_CSEL  "combobox", wsCBV | cbsL
#define  C_CSTR  "combobox", wsCBV | cbsDH

typedef struct {
  rSTR  cls;
  I4B   sty;
  U2B   x, y;
  U2B   w, h;
  I4B   id;
  rSTR  txt;
} DLGI;
typedef DLGI *pDLGI, *PDLGI;
typedef const DLGI *rDLGI, *PCDLGI;

typedef struct {
  pDLGI di;
  I4B   ni;
  U2B   x, y;
  U2B   w, h;
  rSTR  tit;
} DLGS;
typedef DLGS *pDLGS, *PDLGS;
typedef const DLGS *rDLGS, *PCDLGS;

void WINAPI SetDLGI(pDLGI di, rSTR cls, I4B sty, U2B x, U2B y, U2B w, U2B h, I4B id, rSTR txt);

I4B  WINAPI DlgBoxInput(HWND hwnd, rDLGS ds, DLGPROC lpfn, iANY lpa);
HWND WINAPI CreateDlgBox(HWND hwnd, rDLGS ds, DLGPROC lpfn, iANY lpa);

#define  IDPSH  900

typedef struct {
  rDLGS ds;
  DLGPROC lpfn;
  iANY  lpa;
  U4B   psz;
} PSHI;
typedef PSHI *pPSHI, *PPSHI;
typedef const PSHI *rPSHI, *PCRSHI;

typedef struct {
  pPSHI pp;
  I4B   np;
} PSHS;
typedef PSHS *pPSHS, *PPSHS;
typedef const PSHS *rPSHS, *PCPSHS;

I4B  WINAPI PropSheetInput(HWND hwnd, rPSHS ps, I4B ip);

//typedef struct { I4B unused;} HWND_;
//typedef HWND_ *HWND;

//#define  IDOK      1
//#define  IDCANCEL  2
//#define  IDABORT   3
//#define  IDRETRY   4
//#define  IDIGNORE  5
//#define  IDYES     6
//#define  IDNO      7

I4B  WINAPI MsgBox(HWND hwnd, rSTR st, rSTR ca, I4B flg);

I4B  WINAPI OkBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI OkCanBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI YesNoBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI YesNoCanBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI ErrorBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI WarningBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI AlertBox(HWND hwnd, rSTR st, rSTR ca);
I4B  WINAPI ResultBox(HWND hwnd, rSTR st, rSTR ca, BOOL re);


//#define  OFN_READONLY        0x00000001
//#define  OFN_OVERWRITEPROMPT 0x00000002
//#define  OFN_HIDEREADONLY    0x00000004
//#define  OFN_NOCHANGEDIR     0x00000008

typedef struct {
  rSTR  fil;
  I4B   idx;
  pSTR  nam;
  I4B   flg;
} OFNS;
typedef OFNS *pOFNS, *POFNS;

BOOL WINAPI OpenFileDlgBox(HWND hwnd, pOFNS os);
BOOL WINAPI SaveFileDlgBox(HWND hwnd, pOFNS os);

//#define  PD_ALLPAGES         0x00000000
//#define  PD_SELECTION        0x00000001
//#define  PD_PAGENUMS         0x00000002
//#define  PD_NOSELECTION      0x00000004
//#define  PD_NOPAGENUMS       0x00000008
//#define  PD_RETURNDC         0x00000100
//#define  PD_RETURNDEFAULT    0x00000400

typedef struct {
  HDC   hdc;
  I4B   flg;
  U2B   nf, nt;
  U2B   np, nc;
  U2B   psz, ori;
  U2B   wid, len;
} PRDS;
typedef PRDS *pPRDS, *PPRDS;

BOOL WINAPI PrintDlgBox(HWND hwnd, pPRDS ps);

typedef struct {
  I4B   adj;
  I4B   apw;
  I4B   opw, oph;
  I4B   ppw, pph;
  I4B   lpm, tpm, rpm, bpm;
} PSDS;
typedef PSDS *pPSDS, *PPSDS;
typedef const PSDS *rPSDS, *PCPSDS;

BOOL WINAPI PageSetupDlgBox(HWND hwnd, pPSDS ps);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

#define  REPM_SKIPPAGE   0
#define  REPM_DRAWPAGE   1
#define  REPM_STARTPRINT 2
#define  REPM_ENDPRINT   3
#define  REPM_SETUP      4
#define  REPM_PAGESETUP  5
#define  REPM_CREATE     6
#define  REPM_DESTROY    7

typedef HCVS  HREP;

typedef BOOL (CALLBACK *FREP)(HREP rp, I4B msg, I4B pg, uANY pa);

#define  PSZ_A3_PORTRAIT   0x00
#define  PSZ_A3_LANDSCAPE  0x08
#define  PSZ_B4_PORTRAIT   0x01
#define  PSZ_B4_LANDSCAPE  0x09
#define  PSZ_A4_PORTRAIT   0x02
#define  PSZ_A4_LANDSCAPE  0x0a
#define  PSZ_B5_PORTRAIT   0x03
#define  PSZ_B5_LANDSCAPE  0x0b
#define  PSZ_A5_PORTRAIT   0x04
#define  PSZ_A5_LANDSCAPE  0x0c
#define  PSZ_B6_PORTRAIT   0x05
#define  PSZ_B6_LANDSCAPE  0x0d
#define  PSZ_A6_PORTRAIT   0x06
#define  PSZ_A6_LANDSCAPE  0x0e

#define  PSZ_A3P  PSZ_A3_PORTRAIT
#define  PSZ_A3L  PSZ_A3_LANDSCAPE
#define  PSZ_B4P  PSZ_B4_PORTRAIT
#define  PSZ_B4L  PSZ_B4_LANDSCAPE
#define  PSZ_A4P  PSZ_A4_PORTRAIT
#define  PSZ_A4L  PSZ_A4_LANDSCAPE
#define  PSZ_B5P  PSZ_B5_PORTRAIT
#define  PSZ_B5L  PSZ_B5_LANDSCAPE
#define  PSZ_A5P  PSZ_A5_PORTRAIT
#define  PSZ_A5L  PSZ_A5_LANDSCAPE
#define  PSZ_B6P  PSZ_B6_PORTRAIT
#define  PSZ_B6L  PSZ_B6_LANDSCAPE
#define  PSZ_A6P  PSZ_A6_PORTRAIT
#define  PSZ_A6L  PSZ_A6_LANDSCAPE

#define  PMG_REGULAR          0x00
#define  PMG_MIDWIDE          0x10
#define  PMG_WIDE             0x20
#define  PMG_EXTRAWIDE        0x30
#define  PMG_EXTRAEXTRAWIDE   0x40
#define  PMG_MIDNARROW        0x90
#define  PMG_NARROW           0xa0
#define  PMG_EXTRANARROW      0xb0
#define  PMG_EXTRAEXTRANARROW 0xc0

#define  PMG_REG  PMG_REGULAR
#define  PMG_MWD  PMG_MIDWIDE
#define  PMG_WID  PMG_WIDE
#define  PMG_XWD  PMG_EXTRAWIDE
#define  PMG_XXW  PMG_EXTRAEXTRAWIDE
#define  PMG_MNR  PMG_MIDNARROW
#define  PMG_NAR  PMG_NARROW
#define  PMG_XNR  PMG_EXTRANARROW
#define  PMG_XXN  PMG_EXTRAEXTRANARROW

typedef struct {
  rSTR  tit;
  I4B   flg;
  FREP  frep;
  uANY  pa;
} REPI;
typedef REPI *pREPI, *PREPI;
typedef const REPI *rREPI, *PCREPI;

HREP WINAPI CreateReport(rREPI ri);
void WINAPI DeleteReport(HREP rp);

HWND WINAPI hWND(HREP rp);

void WINAPI SetReportInfo(HREP rp, rSTR tit, rSTR usr, I4B sr, I4B tm);
rSTR WINAPI ReportTitle(HREP rp);
rSTR WINAPI ReportAuthor(HREP rp);
I4B  WINAPI ReportDate(HREP rp);
I4B  WINAPI ReportTime(HREP rp);

void WINAPI SetReportExtra(HREP rp, U4B pa);
uANY WINAPI ReportExtra(HREP rp);

void WINAPI SetNPages(HREP rp, I4B npg);
I4B  WINAPI NPages(HREP rp);

void WINAPI SetPaperSize(HREP rp, F8B w, F8B h, F8B scl);
F8B  WINAPI PaperWidth(HREP rp);
F8B  WINAPI PaperHeight(HREP rp);

void WINAPI SetPageSize(HREP rp, F8B w, F8B h);
F8B  WINAPI PageWidth(HREP rp);
F8B  WINAPI PageHeight(HREP rp);
F8B  WINAPI PageLeft(HREP rp);
F8B  WINAPI PageTop(HREP rp);
F8B  WINAPI PageRight(HREP rp);
F8B  WINAPI PageBottom(HREP rp);

void WINAPI SetPageMargin(HREP rp, F8B lm, F8B tm, F8B rm, F8B bm);
F8B  WINAPI BodyWidth(HREP rp);
F8B  WINAPI BodyHeight(HREP rp);
F8B  WINAPI BodyLeft(HREP rp);
F8B  WINAPI BodyTop(HREP rp);
F8B  WINAPI BodyRight(HREP rp);
F8B  WINAPI BodyBottom(HREP rp);

void WINAPI SetHeaderHeight(HREP rp, F8B hh);
void WINAPI SetFooterHeight(HREP rp, F8B fh);
#define  HeaderWidth(rp)  BodyWidth(rp)
F8B  WINAPI HeaderHeight(HREP rp);
#define  HeaderLeft(rp)   BodyLeft(rp)
F8B  WINAPI HeaderTop(HREP rp);
#define  HeaderRight(rp)  BodyRight(rp)
#define  HeaderBottom(rp) BodyTop(rp)
#define  FooterWidth(rp)  BodyWidth(rp)
F8B  WINAPI FooterHeight(HREP rp);
#define  FooterLeft(rp)   BodyLeft(rp)
#define  FooterTop(rp)    BodyBottom(rp)
#define  FooterRight(rp)  BodyRight(rp)
F8B  WINAPI FooterBottom(HREP rp);

#define  RSW_AUTOSETTING    0x01
#define  RSW_SKIPPAGESETUP  0x02

#define  RSW_AUT  RSW_AUTOSETTING
#define  RSW_SKP  RSW_SKIPPAGESETUP

void WINAPI SetReqBodyWidth(HREP rp, F8B w, I4B sw);
F8B  WINAPI ReqBodyWidth(HREP rp);

pCELL WINAPI PageCell(pCELL pc, HREP rp);
pCELL WINAPI BodyCell(pCELL pc, HREP rp);
pCELL WINAPI HeaderCell(pCELL pc, HREP rp);
pCELL WINAPI FooterCell(pCELL pc, HREP rp);

void WINAPI SetLineBreakTag(U2B lbt);
U2B  WINAPI LineBreakTag(void);
void WINAPI SetPageBreakTag(U2B pbt);
U2B  WINAPI PageBreakTag(void);
void WINAPI SetBrackets(U2B lbr, U2B rbr);
U2B  WINAPI BracketL(void);
U2B  WINAPI BracketR(void);
void WINAPI CloseBrackets(rSTR *pp, BOOL sw);

void WINAPI SetSpacingFactor(HREP rp, F8B csf, F8B lsf);
F8B  WINAPI SpacingFactorC(HREP rp);
F8B  WINAPI SpacingFactorL(HREP rp);
pWHSZ WINAPI SpaceSize(pWHSZ sz, HREP rp);

typedef struct {
  I1B   face[32];
  F8B   ch;
  I4B   flg;
  BGRC  col;
  F8B   bph;
  F8B   aph;
  F8B   fiw;
  F8B   liw;
  F8B   riw;
} PFMI;
typedef PFMI *pPFMI, *PPFMI;
typedef const PFMI *rPFMI, *PCPFMI;

BOOL WINAPI RegisterParagraphFormat(I4B id, rSTR tag, rPFMI fi);

F8B  WINAPI ParagraphSpacingB(HREP rp);
F8B  WINAPI ParagraphSpacingA(HREP rp);
I4B  WINAPI ParagraphAlignment(HREP rp);
F8B  WINAPI ParagraphIndentationF(HREP rp);
F8B  WINAPI ParagraphIndentationL(HREP rp);
F8B  WINAPI ParagraphIndentationR(HREP rp);

#define  STA_ENDOFLINE       0x10
#define  STA_ENDOFPARAGRAPH  0x20
#define  STA_ENDOFPAGE       0x40

#define  STA_LIN  STA_ENDOFLINE
#define  STA_PAR  STA_ENDOFPARAGRAPH
#define  STA_END  STA_ENDOFPAGE

void WINAPI SetFlowTextStatus(HREP rp, I4B sta);
I4B  WINAPI FlowTextStatus(HREP rp);
void WINAPI StartFlowText(HREP rp);

typedef void (CALLBACK *FPAR)(HREP rp, rSTR *pp);
typedef void (CALLBACK *FCHR)(HREP rp, rSTR *pp, rCELL pc, pWHSZ sz);

typedef struct {
  rSTR  nam;
  FPAR  fpar;
  FCHR  fchr;
} FTEI;
typedef FTEI *pFTEI, *PFTEI;
typedef const FTEI *rFTEI, *PCFTEI;

typedef struct {
  pFTEI pi;
  I4B   ni;
} FTES;
typedef FTES *pFTES, *PFTES;
typedef const FTES *rFTES, *PCFTES;

BOOL WINAPI RegisterFlowTextTags(rFTES ps);

void WINAPI FlowText(HREP rp, rSTR *pp, rCELL pc);

pPSDS WINAPI PageSetupInfo(HREP rp);

void WINAPI StartPrint(HREP rp, HDC hdc, I4B dpi);
void WINAPI EndPrint(HREP rp);
void WINAPI DrawPage(HREP rp, I4B pg);
void WINAPI SkipPage(HREP rp, I4B pg);

BOOL WINAPI ReportSetup(HWND hwnd, HREP rp);
BOOL WINAPI PageSetup(HWND hwnd, HREP rp);
BOOL WINAPI PrintReport(HWND hwnd, HREP rp);

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

U4B  WINAPI BOLFROVer(void);

BOOL WINAPI InitBOLFRO(uANY pa);
void WINAPI TermBOLFRO(void);

#ifdef __cplusplus
}
#endif

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//
