diff --git a/CMakeLists.txt b/CMakeLists.txt index 285f398..fffb255 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,18 +45,24 @@ endif() # 设置头文件搜索路径 target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib/include + ${CMAKE_SOURCE_DIR}/libs/IUP/include ) -# 设置库文件搜索路径 +# 设置库文件搜索路径(IUP 库和 CD 库) target_link_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib + ${CMAKE_SOURCE_DIR}/libs/IUP + ${CMAKE_SOURCE_DIR}/libs/CD ) # 链接所需库 target_link_libraries(${PROJECT_NAME} PRIVATE + iupcontrols + iupimglib iup iupcd + cd + freetype6 + zlib1 gdi32 comdlg32 comctl32 @@ -65,11 +71,17 @@ target_link_libraries(${PROJECT_NAME} PRIVATE advapi32 ) -# 编译完成后,将 DLL 文件复制到构建输出目录 -file(GLOB IUP_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/libs/iup-3.31_Win64_dllw6_lib/*.dll") +# 编译完成后,将所需的 DLL 文件复制到构建输出目录 +# 我们只复制当前程序真正依赖的 DLL,避免 build 文件夹臃肿 add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${IUP_DLLS} + "${CMAKE_SOURCE_DIR}/libs/IUP/iup.dll" + "${CMAKE_SOURCE_DIR}/libs/IUP/iupimglib.dll" + "${CMAKE_SOURCE_DIR}/libs/IUP/iupcontrols.dll" + "${CMAKE_SOURCE_DIR}/libs/IUP/iupcd.dll" + "${CMAKE_SOURCE_DIR}/libs/CD/cd.dll" + "${CMAKE_SOURCE_DIR}/libs/CD/freetype6.dll" + "${CMAKE_SOURCE_DIR}/libs/CD/zlib1.dll" "$" - COMMENT "Copying DLLs to build directory..." + COMMENT "Copying essential DLLs to build directory..." ) diff --git a/dist/installer.iss b/dist/installer.iss index e2b4605..9681dfb 100644 --- a/dist/installer.iss +++ b/dist/installer.iss @@ -38,7 +38,13 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ [Files] Source: "d:\Code\doing_exercises\programs\PathEditor\build\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "d:\Code\doing_exercises\programs\PathEditor\build\*.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\iup.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\iupimglib.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\iupcontrols.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\iupcd.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\cd.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\freetype6.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "d:\Code\doing_exercises\programs\PathEditor\build\zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] diff --git a/include/cb_edit.h b/include/cb_edit.h index c8c5143..ac34154 100644 --- a/include/cb_edit.h +++ b/include/cb_edit.h @@ -6,7 +6,8 @@ // 编辑相关回调 int btn_new_cb(Ihandle *self); int btn_edit_cb(Ihandle *self); -int list_dblclick_cb(Ihandle *self, int item, char *text); +int list_dblclick_cb(Ihandle *self, int lin, int col, char *status); +int matrix_edition_cb(Ihandle *self, int lin, int col, int mode, int update); int btn_del_cb(Ihandle *self); int btn_up_cb(Ihandle *self); int btn_down_cb(Ihandle *self); diff --git a/include/cb_main.h b/include/cb_main.h index 1d00154..a11d8b1 100644 --- a/include/cb_main.h +++ b/include/cb_main.h @@ -6,7 +6,7 @@ // 主界面交互回调 int txt_search_cb(Ihandle *self); int list_k_any_cb(Ihandle *self, int c); -int list_motion_cb(Ihandle *self, int x, int y, char *status); +int list_motion_cb(Ihandle *self, int lin, int col); int dialog_k_any_cb(Ihandle *self, int c); int btn_ok_cb(Ihandle *self); int btn_cancel_cb(Ihandle *self); diff --git a/libs/CD/cd.dll b/libs/CD/cd.dll new file mode 100644 index 0000000..a94b3d2 Binary files /dev/null and b/libs/CD/cd.dll differ diff --git a/libs/CD/cdcairo.dll b/libs/CD/cdcairo.dll new file mode 100644 index 0000000..d479695 Binary files /dev/null and b/libs/CD/cdcairo.dll differ diff --git a/libs/CD/cdcontextplus.dll b/libs/CD/cdcontextplus.dll new file mode 100644 index 0000000..cac0407 Binary files /dev/null and b/libs/CD/cdcontextplus.dll differ diff --git a/libs/CD/cddirect2d.dll b/libs/CD/cddirect2d.dll new file mode 100644 index 0000000..4df33f4 Binary files /dev/null and b/libs/CD/cddirect2d.dll differ diff --git a/libs/CD/cdgl.dll b/libs/CD/cdgl.dll new file mode 100644 index 0000000..eee94ba Binary files /dev/null and b/libs/CD/cdgl.dll differ diff --git a/libs/CD/cdim.dll b/libs/CD/cdim.dll new file mode 100644 index 0000000..2789108 Binary files /dev/null and b/libs/CD/cdim.dll differ diff --git a/libs/CD/cdpdf.dll b/libs/CD/cdpdf.dll new file mode 100644 index 0000000..be685ad Binary files /dev/null and b/libs/CD/cdpdf.dll differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/freetype6.dll b/libs/CD/freetype6.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/freetype6.dll rename to libs/CD/freetype6.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/ftgl.dll b/libs/CD/ftgl.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/ftgl.dll rename to libs/CD/ftgl.dll diff --git a/libs/CD/include/cd.h b/libs/CD/include/cd.h new file mode 100644 index 0000000..3ebfae1 --- /dev/null +++ b/libs/CD/include/cd.h @@ -0,0 +1,556 @@ +/** \file + * \brief User API + * CD - Canvas Draw + * Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil + * http://www.tecgraf.puc-rio.br/cd + * mailto:cd@tecgraf.puc-rio.br + * + * See Copyright Notice at the end of this file + */ + +#ifndef __CD_H +#define __CD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define CD_NAME "CD - A 2D Graphics Library" +#define CD_DESCRIPTION "Vector Graphics Toolkit with Device Independent Output" +#define CD_COPYRIGHT "Copyright (C) 1994-2020 Tecgraf/PUC-Rio" +#define CD_VERSION "5.14" /* bug fixes are reported only by cdVersion functions */ +#define CD_VERSION_NUMBER 514000 +#define CD_VERSION_DATE "2020/07/30" /* does not include bug fix releases */ + +typedef struct _cdContext cdContext; +typedef struct _cdCanvas cdCanvas; +typedef struct _cdCanvas cdState; +typedef struct _cdImage cdImage; + +/* client images using bitmap structure */ +typedef struct _cdBitmap { + int w; + int h; + int type; + void *data; +} cdBitmap; + + +/* library */ +char* cdVersion(void); +char* cdVersionDate(void); +int cdVersionNumber(void); + +/* canvas init */ +cdCanvas* cdCreateCanvas(cdContext *context, void *data); +cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...); +void cdKillCanvas(cdCanvas* canvas); + +cdContext* cdCanvasGetContext(cdCanvas* canvas); +int cdCanvasActivate(cdCanvas* canvas); +void cdCanvasDeactivate(cdCanvas* canvas); +int cdUseContextPlus(int use); +void cdInitContextPlus(void); /* need an external library */ +void cdFinishContextPlus(void); /* need an external library */ + +/* context */ +typedef int (*cdCallback)(cdCanvas* canvas, ...); +int cdContextRegisterCallback(cdContext *context, int cb, cdCallback func); +unsigned long cdContextCaps(cdContext *context); +int cdContextIsPlus(cdContext *context); +int cdContextType(cdContext *context); + +/* control */ +int cdCanvasSimulate(cdCanvas* canvas, int mode); +void cdCanvasFlush(cdCanvas* canvas); +void cdCanvasClear(cdCanvas* canvas); +cdState* cdCanvasSaveState(cdCanvas* canvas); +void cdCanvasRestoreState(cdCanvas* canvas, cdState* state); +void cdReleaseState(cdState* state); +void cdCanvasSetAttribute(cdCanvas* canvas, const char* name, char* data); +void cdCanvasSetfAttribute(cdCanvas* canvas, const char* name, const char* format, ...); +char* cdCanvasGetAttribute(cdCanvas* canvas, const char* name); + +/* interpretation */ +int cdCanvasPlay(cdCanvas* canvas, cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data); + +/* coordinate transformation */ +void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm); +int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y); +double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y); +int cdCanvasInvertYAxis(cdCanvas* canvas, int y); +double cdfCanvasInvertYAxis(cdCanvas* canvas, double y); +void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy); +void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy); +void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy); +void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy); +void cdCanvasOrigin(cdCanvas* canvas, int x, int y); +void cdfCanvasOrigin(cdCanvas* canvas, double x, double y); +void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y); +void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y); +void cdCanvasTransform(cdCanvas* canvas, const double* matrix); +double* cdCanvasGetTransform(cdCanvas* canvas); +void cdCanvasTransformMultiply(cdCanvas* canvas, const double* matrix); +void cdCanvasTransformRotate(cdCanvas* canvas, double angle); +void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy); +void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy); +void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty); +void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty); + +/* clipping */ +int cdCanvasClip(cdCanvas* canvas, int mode); +void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); + +/* clipping region */ +int cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y); +void cdCanvasOffsetRegion(cdCanvas* canvas, int x, int y); +void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +int cdCanvasRegionCombineMode(cdCanvas* canvas, int mode); + +/* primitives */ +void cdCanvasPixel(cdCanvas* canvas, int x, int y, long color); +void cdCanvasMark(cdCanvas* canvas, int x, int y); +void cdfCanvasPixel(cdCanvas* canvas, double x, double y, long color); +void cdfCanvasMark(cdCanvas* canvas, double x, double y); + +void cdCanvasBegin(cdCanvas* canvas, int mode); +void cdCanvasPathSet(cdCanvas* canvas, int action); +void cdCanvasEnd(cdCanvas* canvas); + +void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2); +void cdCanvasVertex(cdCanvas* canvas, int x, int y); +void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); +void cdCanvasText(cdCanvas* canvas, int x, int y, const char* s); + +void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void cdfCanvasVertex(cdCanvas* canvas, double x, double y); +void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void cdfCanvasText(cdCanvas* canvas, double x, double y, const char* s); + +/* attributes */ +void cdCanvasSetBackground(cdCanvas* canvas, long color); +void cdCanvasSetForeground(cdCanvas* canvas, long color); +long cdCanvasBackground(cdCanvas* canvas, long color); +long cdCanvasForeground(cdCanvas* canvas, long color); +int cdCanvasBackOpacity(cdCanvas* canvas, int opacity); +int cdCanvasWriteMode(cdCanvas* canvas, int mode); +int cdCanvasLineStyle(cdCanvas* canvas, int style); +void cdCanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count); +int cdCanvasLineWidth(cdCanvas* canvas, int width); +int cdCanvasLineJoin(cdCanvas* canvas, int join); +int cdCanvasLineCap(cdCanvas* canvas, int cap); +int cdCanvasInteriorStyle(cdCanvas* canvas, int style); +int cdCanvasHatch(cdCanvas* canvas, int style); +void cdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char* stipple); +unsigned char* cdCanvasGetStipple(cdCanvas* canvas, int *n, int *m); +void cdCanvasPattern(cdCanvas* canvas, int w, int h, long const int *pattern); +long* cdCanvasGetPattern(cdCanvas* canvas, int* n, int* m); +int cdCanvasFillMode(cdCanvas* canvas, int mode); +int cdCanvasFont(cdCanvas* canvas, const char* type_face, int style, int size); +void cdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, int *size); +char* cdCanvasNativeFont(cdCanvas* canvas, const char* font); +int cdCanvasTextAlignment(cdCanvas* canvas, int alignment); +double cdCanvasTextOrientation(cdCanvas* canvas, double angle); +int cdCanvasMarkType(cdCanvas* canvas, int type); +int cdCanvasMarkSize(cdCanvas* canvas, int size); + +/* vector text */ +void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* s); +void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* s); + +/* vector text attributes */ +char* cdCanvasVectorFont(cdCanvas* canvas, const char *filename); +void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2); +double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix); +void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s); +int cdCanvasVectorCharSize(cdCanvas* canvas, int size); +void cdCanvasVectorFontSize(cdCanvas* canvas, double size_x, double size_y); +void cdCanvasGetVectorFontSize(cdCanvas* canvas, double *size_x, double *size_y); + +/* vector text properties */ +void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, int *x, int *y); +void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, int x, int y, int *rect); +void cdCanvasGetVectorTextBox(cdCanvas* canvas, int x, int y, const char *s, int *xmin, int *xmax, int *ymin, int *ymax); + +void cdfCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void cdfCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* s); +void cdfCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, double *x, double *y); +double cdfCanvasVectorCharSize(cdCanvas* canvas, double size); +void cdfCanvasVectorText(cdCanvas* canvas, double x, double y, const char* s); +void cdfCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* s); +void cdfCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, double x, double y, double *rect); +void cdfCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char *s, double *xmin, double *xmax, double *ymin, double *ymax); + +/* properties */ +void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent); +void cdCanvasGetTextSize(cdCanvas* canvas, const char* s, int *width, int *height); +void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax); +void cdfCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char *s, double *xmin, double *xmax, double *ymin, double *ymax); +void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char* s, int *rect); +void cdfCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char *s, double *rect); +int cdCanvasGetColorPlanes(cdCanvas* canvas); + +/* color */ +void cdCanvasPalette(cdCanvas* canvas, int n, const long *palette, int mode); + +/* client images */ +void cdCanvasGetImageRGB(cdCanvas* canvas, unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int iw, int ih); + +void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + +void cdfCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void cdfCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void cdfCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + +/* server images - deprecated (use double buffer drivers) */ +cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h); +void cdKillImage(cdImage* image); +void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y); +void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); +void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); + +/* bitmap - deprecated (use imImage) */ +cdBitmap* cdCreateBitmap(int w, int h, int type); +cdBitmap* cdInitBitmap(int w, int h, int type, ...); +void cdKillBitmap(cdBitmap* bitmap); +unsigned char* cdBitmapGetData(cdBitmap* bitmap, int dataptr); +void cdBitmapSetRect(cdBitmap* bitmap, int xmin, int xmax, int ymin, int ymax); +void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y, int w, int h); +void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* bitmap, int x, int y); +void cdBitmapRGB2Map(cdBitmap* bitmap_rgb, cdBitmap* bitmap_map); + +/* color */ +long cdEncodeColor(unsigned char red, unsigned char green, unsigned char blue); +long cdEncodeColorAlpha(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha); +long cdEncodeAlpha(long color, unsigned char alpha); +void cdDecodeColor(long color, unsigned char* red, unsigned char* green, unsigned char* blue); +void cdDecodeColorAlpha(long color, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha); +unsigned char cdDecodeAlpha(long color); + +#define cdAlpha(_) (unsigned char)(~(((_) >> 24) & 0xFF)) +#define cdReserved(_) (unsigned char)(((_) >> 24) & 0xFF) +#define cdRed(_) (unsigned char)(((_) >> 16) & 0xFF) +#define cdGreen(_) (unsigned char)(((_) >> 8) & 0xFF) +#define cdBlue(_) (unsigned char)(((_) >> 0) & 0xFF) + +/* client image color conversion */ +void cdRGB2Map(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, int pal_size, long *color); + + +/* CD Values */ + +#define CD_QUERY -1 /* query value */ + +enum { /* bitmap type */ + CD_RGB, /* these definitions are compatible with the IM library */ + CD_MAP, + CD_RGBA = 0x100 +}; + +enum { /* bitmap data */ + CD_IRED, + CD_IGREEN, + CD_IBLUE, + CD_IALPHA, + CD_INDEX, + CD_COLORS +}; + +enum { /* status report */ + CD_ERROR = -1, + CD_OK = 0 +}; + +enum { /* clip mode */ + CD_CLIPOFF, + CD_CLIPAREA, + CD_CLIPPOLYGON, + CD_CLIPREGION, + CD_CLIPPATH +}; + +enum { /* region combine mode */ + CD_UNION, + CD_INTERSECT, + CD_DIFFERENCE, + CD_NOTINTERSECT +}; + +enum { /* polygon mode (begin...end) */ + CD_FILL, + CD_OPEN_LINES, + CD_CLOSED_LINES, + CD_CLIP, + CD_BEZIER, + CD_REGION, + CD_PATH +}; + +#define CD_POLYCUSTOM 10 + +enum { /* path actions */ + CD_PATH_NEW, + CD_PATH_MOVETO, + CD_PATH_LINETO, + CD_PATH_ARC, + CD_PATH_CURVETO, + CD_PATH_CLOSE, + CD_PATH_FILL, + CD_PATH_STROKE, + CD_PATH_FILLSTROKE, + CD_PATH_CLIP +}; + +enum { /* fill mode */ + CD_EVENODD, + CD_WINDING +}; + +enum { /* line join */ + CD_MITER, + CD_BEVEL, + CD_ROUND +}; + +enum { /* line cap */ + CD_CAPFLAT, + CD_CAPSQUARE, + CD_CAPROUND +}; + +enum { /* background opacity mode */ + CD_OPAQUE, + CD_TRANSPARENT +}; + +enum { /* write mode */ + CD_REPLACE, + CD_XOR, + CD_NOT_XOR +}; + +enum { /* color allocation mode (palette) */ + CD_POLITE, + CD_FORCE +}; + +enum { /* line style */ + CD_CONTINUOUS, + CD_DASHED, + CD_DOTTED, + CD_DASH_DOT, + CD_DASH_DOT_DOT, + CD_CUSTOM +}; + +enum { /* marker type */ + CD_PLUS, + CD_STAR, + CD_CIRCLE, + CD_X, + CD_BOX, + CD_DIAMOND, + CD_HOLLOW_CIRCLE, + CD_HOLLOW_BOX, + CD_HOLLOW_DIAMOND +}; + +enum { /* hatch type */ + CD_HORIZONTAL, + CD_VERTICAL, + CD_FDIAGONAL, + CD_BDIAGONAL, + CD_CROSS, + CD_DIAGCROSS +}; + +enum { /* interior style */ + CD_SOLID, + CD_HATCH, + CD_STIPPLE, + CD_PATTERN, + CD_HOLLOW, + CD_CUSTOMPATTERN /* used only in ContextPlus drivers */ +}; + +enum { /* text alignment */ + CD_NORTH, + CD_SOUTH, + CD_EAST, + CD_WEST, + CD_NORTH_EAST, + CD_NORTH_WEST, + CD_SOUTH_EAST, + CD_SOUTH_WEST, + CD_CENTER, + CD_BASE_LEFT, + CD_BASE_CENTER, + CD_BASE_RIGHT +}; + +enum { /* style */ + CD_PLAIN = 0, + CD_BOLD = 1, + CD_ITALIC = 2, + CD_UNDERLINE = 4, + CD_STRIKEOUT = 8 +}; + +#define CD_BOLD_ITALIC (CD_BOLD|CD_ITALIC) /* compatibility name */ + +enum { /* some font sizes */ + CD_SMALL = 8, + CD_STANDARD = 12, + CD_LARGE = 18 +}; + +/* Context Capabilities */ +#define CD_CAP_NONE 0x00000000 +#define CD_CAP_FLUSH 0x00000001 +#define CD_CAP_CLEAR 0x00000002 +#define CD_CAP_PLAY 0x00000004 +#define CD_CAP_YAXIS 0x00000008 +#define CD_CAP_CLIPAREA 0x00000010 +#define CD_CAP_CLIPPOLY 0x00000020 +#define CD_CAP_REGION 0x00000040 +#define CD_CAP_RECT 0x00000080 +#define CD_CAP_CHORD 0x00000100 +#define CD_CAP_IMAGERGB 0x00000200 +#define CD_CAP_IMAGERGBA 0x00000400 +#define CD_CAP_IMAGEMAP 0x00000800 +#define CD_CAP_GETIMAGERGB 0x00001000 +#define CD_CAP_IMAGESRV 0x00002000 +#define CD_CAP_BACKGROUND 0x00004000 +#define CD_CAP_BACKOPACITY 0x00008000 +#define CD_CAP_WRITEMODE 0x00010000 +#define CD_CAP_LINESTYLE 0x00020000 +#define CD_CAP_LINEWITH 0x00040000 +#define CD_CAP_FPRIMTIVES 0x00080000 +#define CD_CAP_HATCH 0x00100000 +#define CD_CAP_STIPPLE 0x00200000 +#define CD_CAP_PATTERN 0x00400000 +#define CD_CAP_FONT 0x00800000 +#define CD_CAP_FONTDIM 0x01000000 +#define CD_CAP_TEXTSIZE 0x02000000 +#define CD_CAP_TEXTORIENTATION 0x04000000 +#define CD_CAP_PALETTE 0x08000000 +#define CD_CAP_LINECAP 0x10000000 +#define CD_CAP_LINEJOIN 0x20000000 +#define CD_CAP_PATH 0x40000000 +#define CD_CAP_BEZIER 0x80000000 +#define CD_CAP_ALL 0xFFFFFFFF + +/* Context Types */ +enum { + CD_CTX_WINDOW, + CD_CTX_DEVICE, + CD_CTX_IMAGE, + CD_CTX_FILE +}; + +/* cdPlay definitions */ +#define CD_SIZECB 0 /* size callback */ +typedef int(*cdSizeCB)(cdCanvas *canvas, int w, int h, double w_mm, double h_mm); +#define CD_ABORT 1 +#define CD_CONTINUE 0 + +/* simulation flags */ +#define CD_SIM_NONE 0x0000 +#define CD_SIM_LINE 0x0001 +#define CD_SIM_RECT 0x0002 +#define CD_SIM_BOX 0x0004 +#define CD_SIM_ARC 0x0008 +#define CD_SIM_SECTOR 0x0010 +#define CD_SIM_CHORD 0x0020 +#define CD_SIM_POLYLINE 0x0040 +#define CD_SIM_POLYGON 0x0080 +#define CD_SIM_TEXT 0x0100 +#define CD_SIM_ALL 0xFFFF + +#define CD_SIM_LINES (CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE) +#define CD_SIM_FILLS (CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON) + +/* some predefined colors for convenience */ +#define CD_RED 0xFF0000L /* 255, 0, 0 */ +#define CD_DARK_RED 0x800000L /* 128, 0, 0 */ +#define CD_GREEN 0x00FF00L /* 0,255, 0 */ +#define CD_DARK_GREEN 0x008000L /* 0,128, 0 */ +#define CD_BLUE 0x0000FFL /* 0, 0,255 */ +#define CD_DARK_BLUE 0x000080L /* 0, 0,128 */ + +#define CD_YELLOW 0xFFFF00L /* 255,255, 0 */ +#define CD_DARK_YELLOW 0x808000L /* 128,128, 0 */ +#define CD_MAGENTA 0xFF00FFL /* 255, 0,255 */ +#define CD_DARK_MAGENTA 0x800080L /* 128, 0,128 */ +#define CD_CYAN 0x00FFFFL /* 0,255,255 */ +#define CD_DARK_CYAN 0x008080L /* 0,128,128 */ + +#define CD_WHITE 0xFFFFFFL /* 255,255,255 */ +#define CD_BLACK 0x000000L /* 0, 0, 0 */ + +#define CD_DARK_GRAY 0x808080L /* 128,128,128 */ +#define CD_GRAY 0xC0C0C0L /* 192,192,192 */ + +/* some useful conversion factors */ +#define CD_MM2PT 2.834645669 /* millimeters to points (pt = CD_MM2PT * mm) */ +#define CD_RAD2DEG 57.295779513 /* radians to degrees (deg = CD_RAD2DEG * rad) */ +#define CD_DEG2RAD 0.01745329252 /* degrees to radians (rad = CD_DEG2RAD * deg) */ + +/* paper sizes */ +enum { + CD_A0, + CD_A1, + CD_A2, + CD_A3, + CD_A4, + CD_A5, + CD_LETTER, + CD_LEGAL +}; + + +#ifdef __cplusplus +} +#endif + + + +/****************************************************************************** +Copyright (C) 1994-2020 Tecgraf/PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +#endif /* ifndef CD_H */ + diff --git a/libs/CD/include/cd_canvas.hpp b/libs/CD/include/cd_canvas.hpp new file mode 100644 index 0000000..9620d17 --- /dev/null +++ b/libs/CD/include/cd_canvas.hpp @@ -0,0 +1,360 @@ +/** \file + * \brief Canvas Class + * + * DEPRECATED API. USE NAMESPACE BASED CLASSES. + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CANVAS_HPP +#define __CD_CANVAS_HPP + +#include "cd.h" +#include "wd.h" + +class cdCanvasC +{ + cdCanvas* canvas; + + cdCanvasC() {}; + +public: + +/* canvas init */ + cdCanvasC(cdCanvas* _canvas) + { this->canvas = _canvas; } + + ~cdCanvasC() + { cdKillCanvas(this->canvas); } + +cdContext* GetContext() + { return cdCanvasGetContext(canvas); } +int Activate() + { return cdCanvasActivate(canvas); } +void Deactivate() + { cdCanvasDeactivate(canvas); } + +/* control */ +int Simulate(int mode) + { return cdCanvasSimulate(canvas, mode); } +void Flush() + { cdCanvasFlush(canvas); } +void Clear() + { cdCanvasClear(canvas); } +cdState* SaveState() + { return cdCanvasSaveState(canvas); } +void RestoreState(cdState* state) + { cdCanvasRestoreState(canvas, state); } +void SetAttribute(const char* name, char* data) + { cdCanvasSetAttribute(canvas, name, data); } +char* GetAttribute(const char* name) + { return cdCanvasGetAttribute(canvas, name); } + +/* interpretation */ +int Play(cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data) + { return cdCanvasPlay(canvas, context, xmin, xmax, ymin, ymax, data); } + +/* coordinate transformation */ +void GetSize(int *width, int *height, double *width_mm, double *height_mm) + { cdCanvasGetSize(canvas, width, height, width_mm, height_mm); } +int UpdateYAxis(int* y) + { return cdCanvasUpdateYAxis(canvas, y); } +void MM2Pixel(double mm_dx, double mm_dy, int *dx, int *dy) + { cdCanvasMM2Pixel(canvas, mm_dx, mm_dy, dx, dy); } +void Pixel2MM(int dx, int dy, double *mm_dx, double *mm_dy) + { cdCanvasPixel2MM(canvas, dx, dy, mm_dx, mm_dy); } +void MM2Pixel(double mm_dx, double mm_dy, double *dx, double *dy) + { cdfCanvasMM2Pixel(canvas, mm_dx, mm_dy, dx, dy); } +void Pixel2MM(double dx, double dy, double *mm_dx, double *mm_dy) + { cdfCanvasPixel2MM(canvas, dx, dy, mm_dx, mm_dy); } +void Origin(int x, int y) + { cdCanvasOrigin(canvas, x, y); } +void Origin(double x, double y) + { cdfCanvasOrigin(canvas, x, y); } +void GetOrigin(int *x, int *y) + { cdCanvasGetOrigin(canvas, x, y); } +void GetOrigin(double *x, double *y) + { cdfCanvasGetOrigin(canvas, x, y); } + +/* clipping */ +int Clip(int mode) + { return cdCanvasClip(canvas, mode); } +void ClipArea(int xmin, int xmax, int ymin, int ymax) + { cdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int GetClipArea(int *xmin, int *xmax, int *ymin, int *ymax) + { return cdCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } +void ClipArea(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int GetClipArea(double *xmin, double *xmax, double *ymin, double *ymax) + { return cdfCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } + +/* clipping region */ +int IsPointInRegion(int x, int y) + { return cdCanvasIsPointInRegion(canvas, x, y); } +void OffsetRegion(int x, int y) + { cdCanvasOffsetRegion(canvas, x, y); } +void GetRegionBox(int *xmin, int *xmax, int *ymin, int *ymax) + { cdCanvasGetRegionBox(canvas, xmin, xmax, ymin, ymax); } +int RegionCombineMode(int mode) + { return cdCanvasRegionCombineMode(canvas, mode); } + +/* primitives */ +void Pixel(int x, int y, long color) + { cdCanvasPixel(canvas, x, y, color); } +void Mark(int x, int y) + { cdCanvasMark(canvas, x, y); } + +void Line(int x1, int y1, int x2, int y2) + { cdCanvasLine(canvas, x1, y1, x2, y2); } +void Begin(int mode) + { cdCanvasBegin(canvas, mode); } +void Vertex(int x, int y) + { cdCanvasVertex(canvas, x, y); } +void End() + { cdCanvasEnd(canvas); } +void Rect(int xmin, int xmax, int ymin, int ymax) + { cdCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void Box(int xmin, int xmax, int ymin, int ymax) + { cdCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void Arc(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void Sector(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void Chord(int xc, int yc, int w, int h, double angle1, double angle2) + { cdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void Text(int x, int y, const char* s) + { cdCanvasText(canvas, x, y, s); } + +void Line(double x1, double y1, double x2, double y2) + { cdfCanvasLine(canvas, x1, y1, x2, y2); } +void Vertex(double x, double y) + { cdfCanvasVertex(canvas, x, y); } +void Rect(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void Box(double xmin, double xmax, double ymin, double ymax) + { cdfCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void Arc(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void Sector(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void Chord(double xc, double yc, double w, double h, double angle1, double angle2) + { cdfCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void Text(double x, double y, const char* s) + { cdfCanvasText(canvas, x, y, s); } + +/* attributes */ +long Background(long color) + { return cdCanvasBackground(canvas, color); } +long Foreground(long color) + { return cdCanvasForeground(canvas, color); } +int BackOpacity(int opacity) + { return cdCanvasBackOpacity(canvas, opacity); } +int WriteMode(int mode) + { return cdCanvasWriteMode(canvas, mode); } +int LineStyle(int style) + { return cdCanvasLineStyle(canvas, style); } +void LineStyleDashes(const int* dashes, int count) + { cdCanvasLineStyleDashes(canvas, dashes, count); } +int LineWidth(int width) + { return cdCanvasLineWidth(canvas, width); } +int LineJoin(int join) + { return cdCanvasLineJoin(canvas, join); } +int LineCap(int cap) + { return cdCanvasLineCap(canvas, cap); } +int InteriorStyle(int style) + { return cdCanvasInteriorStyle(canvas, style); } +int Hatch(int style) + { return cdCanvasHatch(canvas, style); } +void Stipple(int w, int h, const unsigned char* stipple) + { cdCanvasStipple(canvas, w, h, stipple); } +unsigned char* GetStipple(int *n, int *m) + { return cdCanvasGetStipple(canvas, n, m); } +void Pattern(int w, int h, long const int *pattern) + { cdCanvasPattern(canvas, w, h, pattern); } +long* GetPattern(int* n, int* m) + { return cdCanvasGetPattern(canvas, n, m); } +int FillMode(int mode) + { return cdCanvasFillMode(canvas, mode); } +int Font(const char* type_face, int style, int size) + { return cdCanvasFont(canvas, type_face, style, size); } +void GetFont(char *type_face, int *style, int *size) + { cdCanvasGetFont(canvas, type_face, style, size); } +char* NativeFont(const char* font) + { return cdCanvasNativeFont(canvas, font); } +int TextAlignment(int alignment) + { return cdCanvasTextAlignment(canvas, alignment); } +double TextOrientation(double angle) + { return cdCanvasTextOrientation(canvas, angle); } +int MarkType(int type) + { return cdCanvasMarkType(canvas, type); } +int MarkSize(int size) + { return cdCanvasMarkSize(canvas, size); } + +/* vector text */ +void VectorText(int x, int y, const char* s) + { cdCanvasVectorText(canvas, x, y, s); } +void MultiLineVectorText(int x, int y, const char* s) + { cdCanvasMultiLineVectorText(canvas, x, y, s); } + +/* vector text attributes */ +char *VectorFont(const char *filename) + { return cdCanvasVectorFont(canvas, filename); } +void VectorTextDirection(int x1, int y1, int x2, int y2) + { cdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } +double* VectorTextTransform(const double* matrix) + { return cdCanvasVectorTextTransform(canvas, matrix); } +void VectorTextSize(int size_x, int size_y, const char* s) + { cdCanvasVectorTextSize(canvas, size_x, size_y, s); } +int VectorCharSize(int size) + { return cdCanvasVectorCharSize(canvas, size); } + + +/* vector text properties */ +void GetVectorTextSize(const char* s, int *x, int *y) + { cdCanvasGetVectorTextSize(canvas, s, x, y); } +void GetVectorTextBounds(const char* s, int x, int y, int *rect) + { cdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + +/* properties */ +void GetFontDim(int *max_width, int *height, int *ascent, int *descent) + { cdCanvasGetFontDim(canvas, max_width, height, ascent, descent); } +void GetTextSize(const char* s, int *width, int *height) + { cdCanvasGetTextSize(canvas, s, width, height); } +void GetTextBox(int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax) + { cdCanvasGetTextBox(canvas, x, y, s, xmin, xmax, ymin, ymax); } +void GetTextBounds(int x, int y, const char* s, int *rect) + { cdCanvasGetTextBounds(canvas, x, y, s, rect); } +int GetColorPlanes() + { return cdCanvasGetColorPlanes(canvas); } + +/* color */ +void Palette(int n, const long *palette, int mode) + { cdCanvasPalette(canvas, n, palette, mode); } + +/* client images */ +void GetImageRGB(unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h) + { cdCanvasGetImageRGB(canvas, r, g, b, x, y, w, h); } +void PutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } +void PutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectRGBA(canvas, iw, ih, r, g, b, a, x, y, w, h, xmin, xmax, ymin, ymax); } +void PutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRectMap(canvas, iw, ih, index, colors, x, y, w, h, xmin, xmax, ymin, ymax); } + +/* server images */ +cdImage* CreateImage(int w, int h) + { return cdCanvasCreateImage(canvas, w, h); } +void GetImage(cdImage* image, int x, int y) + { cdCanvasGetImage(canvas, image, x, y); } +void PutImageRect(cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax) + { cdCanvasPutImageRect(canvas, image, x, y, xmin, xmax, ymin, ymax); } +void ScrollArea(int xmin, int xmax, int ymin, int ymax, int dx, int dy) + { cdCanvasScrollArea(canvas, xmin, xmax, ymin, ymax, dx, dy); } + +void PutBitmap(cdBitmap* bitmap, int x, int y, int w, int h) + { cdCanvasPutBitmap(canvas, bitmap, x, y, w, h); } +void GetBitmap(cdBitmap* bitmap, int x, int y) + { cdCanvasGetBitmap(canvas, bitmap, x, y); } + +/* coordinate transformation */ +void wWindow(double xmin, double xmax, double ymin, double ymax) + { wdCanvasWindow(canvas, xmin, xmax, ymin, ymax); } +void wGetWindow(double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetWindow(canvas, xmin, xmax, ymin, ymax); } +void wViewport(int xmin, int xmax, int ymin, int ymax) + { wdCanvasViewport(canvas, xmin, xmax, ymin, ymax); } +void wGetViewport(int *xmin, int *xmax, int *ymin, int *ymax) + { wdCanvasGetViewport(canvas, xmin, xmax, ymin, ymax); } +void wWorld2Canvas(double xw, double yw, int *xv, int *yv) + { wdCanvasWorld2Canvas(canvas, xw, yw, xv, yv); } +void wWorld2CanvasSize(double hw, double vw, int *hv, int *vv) + { wdCanvasWorld2CanvasSize(canvas, hw, vw, hv, vv); } +void wCanvas2World(int xv, int yv, double *xw, double *yw) + { wdCanvasCanvas2World(canvas, xv, yv, xw, yw); } + +void wClipArea(double xmin, double xmax, double ymin, double ymax) + { wdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } +int wGetClipArea(double *xmin, double *xmax, double *ymin, double *ymax) + { return wdCanvasGetClipArea(canvas, xmin, xmax, ymin, ymax); } +int wIsPointInRegion(double x, double y) + { return wdCanvasIsPointInRegion(canvas, x, y); } +void wOffsetRegion(double x, double y) + { wdCanvasOffsetRegion(canvas, x, y); } +void wGetRegionBox(double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetRegionBox(canvas, xmin, xmax, ymin, ymax); } + +/* primitives */ +void wPixel(double x, double y, long color) + { wdCanvasPixel(canvas, x, y, color); } +void wMark(double x, double y) + { wdCanvasMark(canvas, x, y); } +void wLine(double x1, double y1, double x2, double y2) + { wdCanvasLine(canvas, x1, y1, x2, y2); } +void wVertex(double x, double y) + { wdCanvasVertex(canvas, x, y); } +void wRect(double xmin, double xmax, double ymin, double ymax) + { wdCanvasRect(canvas, xmin, xmax, ymin, ymax); } +void wBox(double xmin, double xmax, double ymin, double ymax) + { wdCanvasBox(canvas, xmin, xmax, ymin, ymax); } +void wArc(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } +void wSector(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } +void wChord(double xc, double yc, double w, double h, double angle1, double angle2) + { wdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } +void wText(double x, double y, const char* s) + { wdCanvasText(canvas, x, y, s); } + +void wPutImageRect(cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRect(canvas, image, x, y, xmin, xmax, ymin, ymax); } +void wPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectRGB(canvas, iw, ih, r, g, b, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectRGBA(canvas, iw, ih, r, g, b, a, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax) + { wdCanvasPutImageRectMap(canvas, iw, ih, index, colors, x, y, w, h, xmin, xmax, ymin, ymax); } +void wPutBitmap(cdBitmap* bitmap, double x, double y, double w, double h) + { wdCanvasPutBitmap(canvas, bitmap, x, y, w, h); } + +/* attributes */ +double wLineWidth(double width) + { return wdCanvasLineWidth(canvas, width); } +int wFont(const char* type_face, int style, double size) + { return wdCanvasFont(canvas, type_face, style, size); } +void wGetFont(char *type_face, int *style, double *size) + { wdCanvasGetFont(canvas, type_face, style, size); } +double wMarkSize(double size) + { return wdCanvasMarkSize(canvas, size); } +void wGetFontDim(double *max_width, double *height, double *ascent, double *descent) + { wdCanvasGetFontDim(canvas, max_width, height, ascent, descent); } +void wGetTextSize(const char* s, double *width, double *height) + { wdCanvasGetTextSize(canvas, s, width, height); } +void wGetTextBox(double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax) + { wdCanvasGetTextBox(canvas, x, y, s, xmin, xmax, ymin, ymax); } +void wGetTextBounds(double x, double y, const char* s, double *rect) + { wdCanvasGetTextBounds(canvas, x, y, s, rect); } +void wStipple(int w, int h, const unsigned char*fgbg, double w_mm, double h_mm) + { wdCanvasStipple(canvas, w, h, fgbg, w_mm, h_mm); } +void wPattern(int w, int h, const long *color, double w_mm, double h_mm) + { wdCanvasPattern(canvas, w, h, color, w_mm, h_mm); } + +/* vector text */ +void wVectorTextDirection(double x1, double y1, double x2, double y2) + { wdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } +void wVectorTextSize(double size_x, double size_y, const char* s) + { wdCanvasVectorTextSize(canvas, size_x, size_y, s); } +void wGetVectorTextSize(const char* s, double *x, double *y) + { wdCanvasGetVectorTextSize(canvas, s, x, y); } +double wVectorCharSize(double size) + { return wdCanvasVectorCharSize(canvas, size); } +void wVectorText(double x, double y, const char* s) + { wdCanvasVectorText(canvas, x, y, s); } +void wMultiLineVectorText(double x, double y, const char* s) + { wdCanvasMultiLineVectorText(canvas, x, y, s); } +void wGetVectorTextBounds(const char* s, double x, double y, double *rect) + { wdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + +}; + +#endif + diff --git a/libs/CD/include/cd_old.h b/libs/CD/include/cd_old.h new file mode 100644 index 0000000..47d805c --- /dev/null +++ b/libs/CD/include/cd_old.h @@ -0,0 +1,158 @@ +/** \file + * \brief Old User API + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_OLD_H +#define __CD_OLD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* canvas control */ +int cdActivate(cdCanvas* canvas); +cdCanvas* cdActiveCanvas(void); +int cdSimulate(int mode); +void cdFlush(void); +void cdClear(void); +cdState* cdSaveState(void); +void cdRestoreState(cdState* state); +void cdSetAttribute(const char* name, char* data); +void cdSetfAttribute(const char* name, const char* format, ...); +char* cdGetAttribute(const char* name); +cdContext* cdGetContext(cdCanvas* canvas); + +/* interpretation */ +int cdRegisterCallback(cdContext *context, int cb, cdCallback func); +int cdPlay(cdContext *context, int xmin, int xmax, int ymin, int ymax, void *data); + +/* coordinate transformation */ +void cdGetCanvasSize(int *width, int *height, double *width_mm, double *height_mm); +int cdUpdateYAxis(int *y); +void cdMM2Pixel(double mm_dx, double mm_dy, int *dx, int *dy); +void cdPixel2MM(int dx, int dy, double *mm_dx, double *mm_dy); +void cdOrigin(int x, int y); + +/* clipping */ +int cdClip(int mode); +int * cdGetClipPoly(int *n); +void cdClipArea(int xmin, int xmax, int ymin, int ymax); +int cdGetClipArea(int *xmin, int *xmax, int *ymin, int *ymax); + +/* clipping region */ +int cdPointInRegion(int x, int y); +void cdOffsetRegion(int x, int y); +void cdRegionBox(int *xmin, int *xmax, int *ymin, int *ymax); +int cdRegionCombineMode(int mode); + +/* primitives */ +void cdPixel(int x, int y, long color); +void cdMark(int x, int y); +void cdLine(int x1, int y1, int x2, int y2); +void cdBegin(int mode); +void cdVertex(int x, int y); +void cdEnd(void); +void cdRect(int xmin, int xmax, int ymin, int ymax); +void cdBox(int xmin, int xmax, int ymin, int ymax); +void cdArc(int xc, int yc, int w, int h, double angle1, double angle2); +void cdSector(int xc, int yc, int w, int h, double angle1, double angle2); +void cdChord(int xc, int yc, int w, int h, double angle1, double angle2); +void cdText(int x, int y, const char* s); + +/* attributes */ +long cdBackground(long color); +long cdForeground(long color); +int cdBackOpacity(int opacity); +int cdWriteMode(int mode); +int cdLineStyle(int style); +void cdLineStyleDashes(const int* dashes, int count); +int cdLineWidth(int width); +int cdLineJoin(int join); +int cdLineCap(int cap); +int cdInteriorStyle(int style); +int cdHatch(int style); +void cdStipple(int w, int h, const unsigned char* stipple); +unsigned char* cdGetStipple(int *n, int *m); +void cdPattern(int w, int h, const long *pattern); +long* cdGetPattern(int* n, int* m); +int cdFillMode(int mode); +void cdFont(int type_face, int style, int size); +void cdGetFont(int *type_face, int *style, int *size); +char* cdNativeFont(const char* font); +int cdTextAlignment(int alignment); +double cdTextOrientation(double angle); +int cdMarkType(int type); +int cdMarkSize(int size); + +/* vector text */ +void cdVectorText(int x, int y, const char* s); +void cdMultiLineVectorText(int x, int y, const char* s); + +/* vector text attributes */ +char *cdVectorFont(const char *filename); +void cdVectorTextDirection(int x1, int y1, int x2, int y2); +double* cdVectorTextTransform(const double* matrix); +void cdVectorTextSize(int size_x, int size_y, const char* s); +int cdVectorCharSize(int size); + +/* vector text properties */ +void cdGetVectorTextSize(const char* s, int *x, int *y); +void cdGetVectorTextBounds(const char* s, int x, int y, int *rect); + +/* properties */ +void cdFontDim(int *max_width, int *height, int *ascent, int *descent); +void cdTextSize(const char* s, int *width, int *height); +void cdTextBox(int x, int y, const char* s, int *xmin, int *xmax, int *ymin, int *ymax); +void cdTextBounds(int x, int y, const char* s, int *rect); +int cdGetColorPlanes(void); + +/* color */ +void cdPalette(int n, const long* palette, int mode); + +/* client images */ +void cdGetImageRGB(unsigned char* r, unsigned char* g, unsigned char* b, int x, int y, int w, int h); +void cdPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + +/* defined for backward compatibility */ +#define cdPutImageRGB(iw, ih, r, g, b, x, y, w, h) cdPutImageRectRGB((iw), (ih), (r), (g), (b), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImageRGBA(iw, ih, r, g, b, a, x, y, w, h) cdPutImageRectRGBA((iw), (ih), (r), (g), (b), (a), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImageMap(iw, ih, index, colors, x, y, w, h) cdPutImageRectMap((iw), (ih), (index), (colors), (x), (y), (w), (h), 0, 0, 0, 0) +#define cdPutImage(image, x, y) cdPutImageRect((image), (x), (y), 0, 0, 0, 0) + +/* server images */ +cdImage* cdCreateImage(int w, int h); +void cdGetImage(cdImage* image, int x, int y); +void cdPutImageRect(cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); +void cdScrollArea(int xmin, int xmax, int ymin, int ymax, int dx, int dy); + +/* bitmap */ +void cdPutBitmap(cdBitmap* bitmap, int x, int y, int w, int h); +void cdGetBitmap(cdBitmap* bitmap, int x, int y); + +enum { /* OLD type face -> new names */ + CD_SYSTEM, /* "System" */ + CD_COURIER, /* "Courier" */ + CD_TIMES_ROMAN, /* "Times" */ + CD_HELVETICA, /* "Helvetica" */ + CD_NATIVE +}; + +/* OLD definitions, defined for backward compatibility */ +#define CD_CLIPON CD_CLIPAREA +#define CD_CENTER_BASE CD_BASE_CENTER +#define CD_LEFT_BASE CD_BASE_LEFT +#define CD_RIGHT_BASE CD_BASE_RIGHT +#define CD_ITALIC_BOLD CD_BOLD_ITALIC +#define cdScrollImage cdScrollArea +#define cdCanvas2Raster(x, y) {(void)x; cdUpdateYAxis(y);} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cd_plus.h b/libs/CD/include/cd_plus.h new file mode 100644 index 0000000..2aa0d32 --- /dev/null +++ b/libs/CD/include/cd_plus.h @@ -0,0 +1,634 @@ +/** \file + * \brief Name space for C++ high level API + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PLUS_H +#define __CD_PLUS_H + + +#include "cd.h" +#include "wd.h" + +#include "cdiup.h" +#include "cddbuf.h" +#include "cdprint.h" +#include "cdnative.h" +#include "cdgdiplus.h" +#include "cdcgm.h" +#include "cddgn.h" +#include "cddxf.h" +#include "cdclipbd.h" +#include "cdemf.h" +#include "cdirgb.h" +#include "cdmf.h" +#include "cdps.h" +#include "cdpdf.h" +#include "cdsvg.h" +#include "cdwmf.h" +#include "cddebug.h" +#include "cdgl.h" +#include "cdpicture.h" +#include "cdim.h" + + + + +/** \brief Name space for C++ high level API + * + * \par + * Defines wrapper classes for all C structures. + * + * See \ref cd_plus.h + */ +namespace cd +{ + inline char* Version() { return cdVersion(); } + inline char* VersionDate() { return cdVersionDate(); } + inline int VersionNumber() { return cdVersionNumber(); } + + + inline long ColorEncode(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255) { + return cdEncodeColorAlpha(red, green, blue, alpha); } + inline unsigned char ColorAlpha(long color) { return cdAlpha(color); } + inline unsigned char ColorRed(long color) { return cdRed(color); } + inline unsigned char ColorGreen(long color) { return cdGreen(color); } + inline unsigned char ColorBlue(long color) { return cdBlue(color); } + + + class Context + { + cdContext* cd_context; + + friend class Canvas; + + public: + Context(cdContext* ref_context) { cd_context = ref_context; } + + unsigned long Caps() { return cdContextCaps(cd_context); } + bool IsPlus() { return cdContextIsPlus(cd_context) != 0; } + int Type() { return cdContextType(cd_context); } + + static void UsePlus(bool use) { cdUseContextPlus(use); } + static void InitPlus() { cdInitContextPlus(); } + static void FinishPlus() { cdFinishContextPlus(); } + + static void GetScreenSize(int &width, int &height, double &width_mm, double &height_mm) { cdGetScreenSize(&width, &height, &width_mm, &height_mm); } + static int GetScreenColorPlanes() { return cdGetScreenColorPlanes(); } + }; + + + class Canvas + { + /* forbidden */ + Canvas(const Canvas&) {} + + protected: + cdCanvas* canvas; + bool release; + + Canvas() { canvas = 0; release = true; } + + static inline int PlaySize_CB(cdCanvas *cd_canvas, int w, int h, double w_mm, double h_mm) { + Canvas* canvas = (Canvas*)cdCanvasGetAttribute(cd_canvas, "USERDATA"); + return canvas->PlaySizeCallback(w, h, w_mm, h_mm); + } + + public: + Canvas(cdCanvas* ref_canvas) { canvas = ref_canvas; release = false; } + + virtual ~Canvas() { + if (canvas && release) + cdKillCanvas(canvas); + } + + cdCanvas* GetHandle() const { return canvas; } + + bool Failed() const { + return canvas == 0; + } + + Context GetContext() { return cdCanvasGetContext(canvas); } + int Activate() { return cdCanvasActivate(canvas); } + void Deactivate() { cdCanvasDeactivate(canvas); } + + /* control */ + int Simulate(int mode) { return cdCanvasSimulate(canvas, mode); } + void Flush() { cdCanvasFlush(canvas); } + void Clear() { cdCanvasClear(canvas); } + + cdState* SaveState() { return cdCanvasSaveState(canvas); } + void RestoreState(cdState* state) { cdCanvasRestoreState(canvas, state); } + void ReleaseState(cdState* state) { cdReleaseState(state); } + + void SetAttribute(const char* name, char* data) { cdCanvasSetAttribute(canvas, name, data); } + char* GetAttribute(const char* name) { return cdCanvasGetAttribute(canvas, name); } + + virtual int PlaySizeCallback(int /* w */, int /* h */, double /* w_mm */, double /* h_mm */) { return CD_CONTINUE; } + /* interpretation */ + int Play(const Context& context, int xmin, int xmax, int ymin, int ymax, void *data) { + cdCanvasSetAttribute(canvas, "USERDATA", (char*)this); + cdContextRegisterCallback(context.cd_context, CD_SIZECB, (cdCallback)PlaySize_CB); + return cdCanvasPlay(canvas, context.cd_context, xmin, xmax, ymin, ymax, data); + } + int wPlay(const Context& context, double xmin, double xmax, double ymin, double ymax, void *data) { + cdCanvasSetAttribute(canvas, "USERDATA", (char*)this); + cdContextRegisterCallback(context.cd_context, CD_SIZECB, (cdCallback)PlaySize_CB); + return wdCanvasPlay(canvas, context.cd_context, xmin, xmax, ymin, ymax, data); + } + + /* coordinates utilities */ + void GetSize(int &width, int &height, double &width_mm, double &height_mm) { cdCanvasGetSize(canvas, &width, &height, &width_mm, &height_mm); } + int UpdateYAxis(int &y) { return cdCanvasUpdateYAxis(canvas, &y); } + double UpdateYAxis(double &y) { return cdfCanvasUpdateYAxis(canvas, &y); } + int InvertYAxis(int y) { return cdCanvasInvertYAxis(canvas, y); } + double InvertYAxis(double y) { return cdfCanvasInvertYAxis(canvas, y); } + void MM2Pixel(double mm_dx, double mm_dy, int &dx, int &dy) { cdCanvasMM2Pixel(canvas, mm_dx, mm_dy, &dx, &dy); } + void MM2Pixel(double mm_dx, double mm_dy, double &dx, double &dy) { cdfCanvasMM2Pixel(canvas, mm_dx, mm_dy, &dx, &dy); } + void Pixel2MM(int dx, int dy, double &mm_dx, double &mm_dy) { cdCanvasPixel2MM(canvas, dx, dy, &mm_dx, &mm_dy); } + void Pixel2MM(double dx, double dy, double &mm_dx, double &mm_dy) { cdfCanvasPixel2MM(canvas, dx, dy, &mm_dx, &mm_dy); } + void Origin(int x, int y) { cdCanvasOrigin(canvas, x, y); } + void Origin(double x, double y) { cdfCanvasOrigin(canvas, x, y); } + void GetOrigin(int &x, int &y) { cdCanvasGetOrigin(canvas, &x, &y); } + void GetOrigin(double &x, double &y) { cdfCanvasGetOrigin(canvas, &x, &y); } + + /* coordinates transformation */ + void Transform(const double* matrix) { cdCanvasTransform(canvas, matrix); } + double* GetTransform() { return cdCanvasGetTransform(canvas); } + void TransformMultiply(const double* matrix) { cdCanvasTransformMultiply(canvas, matrix); } + void TransformRotate(double angle) { cdCanvasTransformRotate(canvas, angle); } + void TransformScale(double sx, double sy) { cdCanvasTransformScale(canvas, sx, sy); } + void TransformTranslate(double dx, double dy) { cdCanvasTransformTranslate(canvas, dx, dy); } + void TransformPoint(int x, int y, int &tx, int &ty) { cdCanvasTransformPoint(canvas, x, y, &tx, &ty); } + void TransformPoint(double x, double y, double &tx, double &ty) { cdfCanvasTransformPoint(canvas, x, y, &tx, &ty); } + + /* world coordinate transformation */ + void wWindow(double xmin, double xmax, double ymin, double ymax) { wdCanvasWindow(canvas, xmin, xmax, ymin, ymax); } + void wGetWindow(double &xmin, double &xmax, double &ymin, double &ymax) { wdCanvasGetWindow(canvas, &xmin, &xmax, &ymin, &ymax); } + void wViewport(int xmin, int xmax, int ymin, int ymax) { wdCanvasViewport(canvas, xmin, xmax, ymin, ymax); } + void wGetViewport(int &xmin, int &xmax, int &ymin, int &ymax) { wdCanvasGetViewport(canvas, &xmin, &xmax, &ymin, &ymax); } + void wWorld2Canvas(double xw, double yw, int &xv, int &yv) { wdCanvasWorld2Canvas(canvas, xw, yw, &xv, &yv); } + void wWorld2CanvasSize(double hw, double vw, int &hv, int &vv) { wdCanvasWorld2CanvasSize(canvas, hw, vw, &hv, &vv); } + void wCanvas2World(int xv, int yv, double &xw, double &yw) { wdCanvasCanvas2World(canvas, xv, yv, &xw, &yw); } + void wSetTransform(double sx, double sy, double tx, double ty) { wdCanvasSetTransform(canvas, sx, sy, tx, ty); } + void wGetTransform(double &sx, double &sy, double &tx, double &ty) { wdCanvasGetTransform(canvas, &sx, &sy, &tx, &ty); } + void wTranslate(double dtx, double dty) { wdCanvasTranslate(canvas, dtx, dty); } + void wScale(double dsx, double dsy) { wdCanvasScale(canvas, dsx, dsy); } + + + /* clipping */ + int Clip(int mode) { return cdCanvasClip(canvas, mode); } + void ClipArea(int xmin, int xmax, int ymin, int ymax) { cdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } + void ClipArea(double xmin, double xmax, double ymin, double ymax) { cdfCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } + void wClipArea(double xmin, double xmax, double ymin, double ymax) { wdCanvasClipArea(canvas, xmin, xmax, ymin, ymax); } + int GetClipArea(int &xmin, int &xmax, int &ymin, int &ymax) { return cdCanvasGetClipArea(canvas, &xmin, &xmax, &ymin, &ymax); } + int GetClipArea(double &xmin, double &xmax, double &ymin, double &ymax) { return cdfCanvasGetClipArea(canvas, &xmin, &xmax, &ymin, &ymax); } + int wGetClipArea(double &xmin, double &xmax, double &ymin, double &ymax) { return wdCanvasGetClipArea(canvas, &xmin, &xmax, &ymin, &ymax); } + + /* clipping region */ + int IsPointInRegion(int x, int y) { return cdCanvasIsPointInRegion(canvas, x, y); } + int wIsPointInRegion(double x, double y) { return wdCanvasIsPointInRegion(canvas, x, y); } + void OffsetRegion(int x, int y) { cdCanvasOffsetRegion(canvas, x, y); } + void wOffsetRegion(double x, double y) { wdCanvasOffsetRegion(canvas, x, y); } + void GetRegionBox(int &xmin, int &xmax, int &ymin, int &ymax) { cdCanvasGetRegionBox(canvas, &xmin, &xmax, &ymin, &ymax); } + void wGetRegionBox(double &xmin, double &xmax, double &ymin, double &ymax) { wdCanvasGetRegionBox(canvas, &xmin, &xmax, &ymin, &ymax); } + int RegionCombineMode(int mode) { return cdCanvasRegionCombineMode(canvas, mode); } + + /* primitives */ + void Pixel(int x, int y, long color) { cdCanvasPixel(canvas, x, y, color); } + void Pixel(double x, double y, long color) { cdfCanvasPixel(canvas, x, y, color); } + void wPixel(double x, double y, long color) { wdCanvasPixel(canvas, x, y, color); } + void Mark(int x, int y) { cdCanvasMark(canvas, x, y); } + void Mark(double x, double y) { cdfCanvasMark(canvas, x, y); } + void wMark(double x, double y) { wdCanvasMark(canvas, x, y); } + + void Begin(int mode) { cdCanvasBegin(canvas, mode); } + void PathSet(int action) { cdCanvasPathSet(canvas, action); } + void End() { cdCanvasEnd(canvas); } + + void Line(int x1, int y1, int x2, int y2) { cdCanvasLine(canvas, x1, y1, x2, y2); } + void Line(double x1, double y1, double x2, double y2) { cdfCanvasLine(canvas, x1, y1, x2, y2); } + void wLine(double x1, double y1, double x2, double y2) { wdCanvasLine(canvas, x1, y1, x2, y2); } + void Vertex(int x, int y) { cdCanvasVertex(canvas, x, y); } + void wVertex(double x, double y) { wdCanvasVertex(canvas, x, y); } + void Vertex(double x, double y) { cdfCanvasVertex(canvas, x, y); } + void Rect(int xmin, int xmax, int ymin, int ymax) { cdCanvasRect(canvas, xmin, xmax, ymin, ymax); } + void Rect(double xmin, double xmax, double ymin, double ymax) { cdfCanvasRect(canvas, xmin, xmax, ymin, ymax); } + void wRect(double xmin, double xmax, double ymin, double ymax) { wdCanvasRect(canvas, xmin, xmax, ymin, ymax); } + void Box(int xmin, int xmax, int ymin, int ymax) { cdCanvasBox(canvas, xmin, xmax, ymin, ymax); } + void Box(double xmin, double xmax, double ymin, double ymax) { cdfCanvasBox(canvas, xmin, xmax, ymin, ymax); } + void wBox(double xmin, double xmax, double ymin, double ymax) { wdCanvasBox(canvas, xmin, xmax, ymin, ymax); } + void Arc(int xc, int yc, int w, int h, double angle1, double angle2) { cdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } + void Arc(double xc, double yc, double w, double h, double angle1, double angle2) { cdfCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } + void wArc(double xc, double yc, double w, double h, double angle1, double angle2) { wdCanvasArc(canvas, xc, yc, w, h, angle1, angle2); } + void Sector(int xc, int yc, int w, int h, double angle1, double angle2) { cdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } + void Sector(double xc, double yc, double w, double h, double angle1, double angle2) { cdfCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } + void wSector(double xc, double yc, double w, double h, double angle1, double angle2) { wdCanvasSector(canvas, xc, yc, w, h, angle1, angle2); } + void Chord(double xc, double yc, double w, double h, double angle1, double angle2) { cdfCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } + void Chord(int xc, int yc, int w, int h, double angle1, double angle2) { cdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } + void wChord(double xc, double yc, double w, double h, double angle1, double angle2) { wdCanvasChord(canvas, xc, yc, w, h, angle1, angle2); } + void Text(int x, int y, const char* s) { cdCanvasText(canvas, x, y, s); } + void Text(double x, double y, const char* s) { cdfCanvasText(canvas, x, y, s); } + void wText(double x, double y, const char* s) { wdCanvasText(canvas, x, y, s); } + + /* attributes */ + void SetBackground(long color) { cdCanvasSetBackground(canvas, color); } + void SeForeground(long color) { cdCanvasSetForeground(canvas, color); } + long Background(long color) { return cdCanvasBackground(canvas, color); } + long Foreground(long color) { return cdCanvasForeground(canvas, color); } + int BackOpacity(int opacity) { return cdCanvasBackOpacity(canvas, opacity); } + int WriteMode(int mode) { return cdCanvasWriteMode(canvas, mode); } + int LineStyle(int style) { return cdCanvasLineStyle(canvas, style); } + void LineStyleDashes(const int* dashes, int count) { cdCanvasLineStyleDashes(canvas, dashes, count); } + int LineWidth(int width) { return cdCanvasLineWidth(canvas, width); } + double wLineWidth(double width) { return wdCanvasLineWidth(canvas, width); } + int LineJoin(int join) { return cdCanvasLineJoin(canvas, join); } + int LineCap(int cap) { return cdCanvasLineCap(canvas, cap); } + int InteriorStyle(int style) { return cdCanvasInteriorStyle(canvas, style); } + int Hatch(int style) { return cdCanvasHatch(canvas, style); } +#ifdef __IM_PLUS_H + void Stipple(const im::Image& stipple) { cdCanvasStippleImImage(canvas, stipple.GetHandle()); } + unsigned char* GetStipple(int &n, int &m) { return cdCanvasGetStipple(canvas, &n, &m); } + void Pattern(const im::Image& pattern) { cdCanvasPatternImImage(canvas, pattern.GetHandle()); } + long* GetPattern(int& n, int& m) { return cdCanvasGetPattern(canvas, &n, &m); } +#endif + int FillMode(int mode) { return cdCanvasFillMode(canvas, mode); } + int Font(const char* type_face, int style, int size) { return cdCanvasFont(canvas, type_face, style, size); } + int wFont(const char* type_face, int style, double size) { return wdCanvasFont(canvas, type_face, style, size); } + void GetFont(char *type_face, int &style, int &size) { cdCanvasGetFont(canvas, type_face, &style, &size); } + void wGetFont(char *type_face, int &style, double &size) { wdCanvasGetFont(canvas, type_face, &style, &size); } + char* NativeFont(const char* font) { return cdCanvasNativeFont(canvas, font); } + int TextAlignment(int alignment) { return cdCanvasTextAlignment(canvas, alignment); } + double TextOrientation(double angle) { return cdCanvasTextOrientation(canvas, angle); } + int MarkType(int type) { return cdCanvasMarkType(canvas, type); } + int MarkSize(int size) { return cdCanvasMarkSize(canvas, size); } + double wMarkSize(double size) { return wdCanvasMarkSize(canvas, size); } + + /* vector text */ + void VectorText(int x, int y, const char* s) { cdCanvasVectorText(canvas, x, y, s); } + void VectorText(double x, double y, const char* s) { cdfCanvasVectorText(canvas, x, y, s); } + void wVectorText(double x, double y, const char* s) { wdCanvasVectorText(canvas, x, y, s); } + void MultiLineVectorText(int x, int y, const char* s) { cdCanvasMultiLineVectorText(canvas, x, y, s); } + void MultiLineVectorText(double x, double y, const char* s) { cdfCanvasMultiLineVectorText(canvas, x, y, s); } + void wMultiLineVectorText(double x, double y, const char* s) { wdCanvasMultiLineVectorText(canvas, x, y, s); } + + /* vector text attributes */ + char *VectorFont(const char *filename) { return cdCanvasVectorFont(canvas, filename); } + void VectorTextDirection(int x1, int y1, int x2, int y2) { cdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } + void VectorTextDirection(double x1, double y1, double x2, double y2) { cdfCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } + void wVectorTextDirection(double x1, double y1, double x2, double y2) { wdCanvasVectorTextDirection(canvas, x1, y1, x2, y2); } + double* VectorTextTransform(const double* matrix) { return cdCanvasVectorTextTransform(canvas, matrix); } + void VectorTextSize(int size_x, int size_y, const char* s) { cdCanvasVectorTextSize(canvas, size_x, size_y, s); } + void VectorTextSize(double size_x, double size_y, const char* s) { cdfCanvasVectorTextSize(canvas, size_x, size_y, s); } + void wVectorTextSize(double size_x, double size_y, const char* s) { wdCanvasVectorTextSize(canvas, size_x, size_y, s); } + int VectorCharSize(int size) { return cdCanvasVectorCharSize(canvas, size); } + double VectorCharSize(double size) { return cdfCanvasVectorCharSize(canvas, size); } + double wVectorCharSize(double size) { return wdCanvasVectorCharSize(canvas, size); } + void VectorFontSize(double size_x, double size_y) { cdCanvasVectorFontSize(canvas, size_x, size_y); } + void GetVectorFontSize(double &size_x, double &size_y) { cdCanvasGetVectorFontSize(canvas, &size_x, &size_y); } + + + /* vector text properties */ + void GetVectorTextSize(const char* s, int &x, int &y) { cdCanvasGetVectorTextSize(canvas, s, &x, &y); } + void GetVectorTextSize(const char* s, double &x, double &y) { cdfCanvasGetVectorTextSize(canvas, s, &x, &y); } + void wGetVectorTextSize(const char* s, double &x, double &y) { wdCanvasGetVectorTextSize(canvas, s, &x, &y); } + void GetVectorTextBounds(const char* s, int x, int y, int *rect) { cdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + void GetVectorTextBounds(const char* s, double x, double y, double *rect) { cdfCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + void wGetVectorTextBounds(const char* s, double x, double y, double *rect) { wdCanvasGetVectorTextBounds(canvas, s, x, y, rect); } + void GetVectorTextBox(int x, int y, const char *s, int &xmin, int &xmax, int &ymin, int &ymax) { cdCanvasGetVectorTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + void GetVectorTextBox(double x, double y, const char *s, double &xmin, double &xmax, double &ymin, double &ymax) { cdfCanvasGetVectorTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + void wGetVectorTextBox(double x, double y, const char *s, double &xmin, double &xmax, double &ymin, double &ymax) { wdCanvasGetVectorTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + + /* properties */ + void GetFontDim(int &max_width, int &height, int &ascent, int &descent) { cdCanvasGetFontDim(canvas, &max_width, &height, &ascent, &descent); } + void wGetFontDim(double &max_width, double &height, double &ascent, double &descent) { wdCanvasGetFontDim(canvas, &max_width, &height, &ascent, &descent); } + void GetTextSize(const char* s, int &width, int &height) { cdCanvasGetTextSize(canvas, s, &width, &height); } + void wGetTextSize(const char* s, double &width, double &height) { wdCanvasGetTextSize(canvas, s, &width, &height); } + void GetTextBox(int x, int y, const char* s, int &xmin, int &xmax, int &ymin, int &ymax) { cdCanvasGetTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + void GetTextBox(double x, double y, const char* s, double &xmin, double &xmax, double &ymin, double &ymax) { cdfCanvasGetTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + void wGetTextBox(double x, double y, const char* s, double &xmin, double &xmax, double &ymin, double &ymax) { wdCanvasGetTextBox(canvas, x, y, s, &xmin, &xmax, &ymin, &ymax); } + void GetTextBounds(int x, int y, const char* s, int *rect) { cdCanvasGetTextBounds(canvas, x, y, s, rect); } + void GetTextBounds(double x, double y, const char* s, double *rect) { cdfCanvasGetTextBounds(canvas, x, y, s, rect); } + void wGetTextBounds(double x, double y, const char* s, double *rect) { wdCanvasGetTextBounds(canvas, x, y, s, rect); } + int GetColorPlanes() { return cdCanvasGetColorPlanes(canvas); } + + + /* client images */ +#ifdef __IM_PLUS_H + void PutImage(const im::Image& image, int x, int y, int w, int h) { cdCanvasPutImImage(canvas, image.GetHandle(), x, y, w, h); } + void PutImage(const im::Image& image, double x, double y, double w, double h) { cdfCanvasPutImImage(canvas, image.GetHandle(), x, y, w, h); } + void wPutImage(const im::Image& image, double x, double y, double w, double h) { wdCanvasPutImImage(canvas, image.GetHandle(), x, y, w, h); } + + void GetImage(im::Image& image, int x, int y) { cdCanvasGetImImage(canvas, image.GetHandle(), x, y); } + void wGetImage(im::Image& image, double x, double y) { wdCanvasGetImImage(canvas, image.GetHandle(), x, y); } +#endif + }; + + + class CanvasImageRGB : public Canvas + { + public: + CanvasImageRGB(int width, int height, bool has_alpha = false, double res = 0) + : Canvas() { const char *alpha = ""; + if (has_alpha) + alpha = "-a"; + + if (res) + canvas = cdCreateCanvasf(CD_IMAGERGB, "%dx%d %g %s", width, height, res, alpha); + else + canvas = cdCreateCanvasf(CD_IMAGERGB, "%dx%d %s", width, height, alpha); } + }; +#ifdef __IM_PLUS_H + class CanvasImImage : public Canvas + { + public: + CanvasImImage(im::Image& image, double res = 0) + : Canvas() { canvas = cdCreateCanvas(CD_IMIMAGE, image.GetHandle()); + if (canvas && res) + cdCanvasSetfAttribute(canvas, "RESOLUTION", "%g", res); + } + }; +#endif + class CanvasMetafileEMF : public Canvas + { + public: + CanvasMetafileEMF(const char* filename, int width, int height, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_EMF, "\"%s\" %dx%d %g", filename, width, height, res); + else + canvas = cdCreateCanvasf(CD_EMF, "\"%s\" %dx%d", filename, width, height); + } + }; + class CanvasMetafileWMF : public Canvas + { + public: + CanvasMetafileWMF(const char* filename, int width, int height, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_WMF, "\"%s\" %dx%d %g", filename, width, height, res); + else + canvas = cdCreateCanvasf(CD_WMF, "\"%s\" %dx%d", filename, width, height); + } + }; + class CanvasMetafileMF : public Canvas + { + public: + CanvasMetafileMF(const char* filename, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_METAFILE, "\"%s\" %g", filename, res); + else + canvas = cdCreateCanvasf(CD_METAFILE, "\"%s\"", filename); + } + CanvasMetafileMF(const char* filename, double width_mm, double height_mm, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_METAFILE, "\"%s\" %gx%g %g", filename, width_mm, height_mm, res); + else + canvas = cdCreateCanvasf(CD_METAFILE, "\"%s\" %gx%g", filename, width_mm, height_mm); + } + }; + class CanvasMetafileSVG : public Canvas + { + public: + CanvasMetafileSVG(const char* filename, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_SVG, "\"%s\" %g", filename, res); + else + canvas = cdCreateCanvasf(CD_SVG, "\"%s\"", filename); + } + CanvasMetafileSVG(const char* filename, double width_mm, double height_mm, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_SVG, "\"%s\" %gx%g %g", filename, width_mm, height_mm, res); + else + canvas = cdCreateCanvasf(CD_SVG, "\"%s\" %gx%g", filename, width_mm, height_mm); + } + }; + class CanvasMetafileDebug : public Canvas + { + public: + CanvasMetafileDebug(const char* filename, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_DEBUG, "\"%s\" %g", filename, res); + else + canvas = cdCreateCanvasf(CD_DEBUG, "\"%s\"", filename); + } + CanvasMetafileDebug(const char* filename, double width_mm, double height_mm, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_DEBUG, "\"%s\" %gx%g %g", filename, width_mm, height_mm, res); + else + canvas = cdCreateCanvasf(CD_DEBUG, "\"%s\" %gx%g", filename, width_mm, height_mm); + } + }; + class CanvasPrinter : public Canvas + { + public: + CanvasPrinter(const char* name, bool show_dialog = false) + : Canvas() { if (show_dialog) + canvas = cdCreateCanvasf(CD_PRINTER, "%s -d", name); + else + canvas = cdCreateCanvasf(CD_PRINTER, "%s", name); + } + }; + class CanvasOpenGL : public Canvas + { + public: + CanvasOpenGL(int width, int height, double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_GL, "%dx%d %g", width, height, res); + else + canvas = cdCreateCanvasf(CD_GL, "%dx%d", width, height); + } + }; + class CanvasPicture : public Canvas + { + public: + CanvasPicture(double res = 0) + : Canvas() { if (res) + canvas = cdCreateCanvasf(CD_PICTURE, "%g", res); + else + canvas = cdCreateCanvas(CD_PICTURE, ""); + } + }; + class CanvasMetafileDGN : public Canvas + { + public: + CanvasMetafileDGN(const char* filename, double res = 0, bool polygon_filling = true, const char* seed_file = 0) + : Canvas() { char* polygon_filling_str = ""; + if (!polygon_filling) + polygon_filling_str = "-f"; + + char* seed_file_str = ""; + if (seed_file) + seed_file_str = "-s"; + else + seed_file = ""; + + if (res) + canvas = cdCreateCanvasf(CD_DGN, "\"%s\" %g %s %s%s", filename, res, polygon_filling_str, seed_file_str, seed_file); + else + canvas = cdCreateCanvasf(CD_DGN, "\"%s\" %s %s%s", filename, polygon_filling_str, seed_file_str, seed_file); + } + CanvasMetafileDGN(const char* filename, double width_mm, double height_mm, double res = 0, bool polygon_filling = true, const char* seed_file = 0) + : Canvas() { char* polygon_filling_str = ""; + if (!polygon_filling) + polygon_filling_str = "-f"; + + char* seed_file_str = ""; + if (seed_file) + seed_file_str = "-s"; + else + seed_file = ""; + + if (res) + canvas = cdCreateCanvasf(CD_DGN, "\"%s\" %gx%g %g %s %s%s", filename, width_mm, height_mm, res, polygon_filling_str, seed_file_str, seed_file); + else + canvas = cdCreateCanvasf(CD_DGN, "\"%s\" %gx%g %s %s%s", filename, width_mm, height_mm, polygon_filling_str, seed_file_str, seed_file); + } + }; + class CanvasMetafileDXF : public Canvas + { + public: + CanvasMetafileDXF(const char* filename, double res = 0, bool acad2000 = true, double xmin = 0, double ymin = 0, double xmax = 0, double ymax = 0) + : Canvas() { char* acad2000_str = ""; + if (acad2000) + acad2000_str = "-ac2000"; + + if (xmin || ymin || xmax || ymax) + { if (res) + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %g %s -limits %g %g %g %g", filename, res, acad2000_str, xmin, ymin, xmax, ymax); + else + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %s -limits %g %g %g %g", filename, acad2000_str, xmin, ymin, xmax, ymax); + } + else + { if (res) + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %g %s", filename, res, acad2000_str); + else + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %s", filename, acad2000_str); + } + } + CanvasMetafileDXF(const char* filename, double width_mm, double height_mm, double res = 0, bool acad2000 = true, double xmin = 0, double ymin = 0, double xmax = 0, double ymax = 0) + : Canvas() { char* acad2000_str = ""; + if (acad2000) + acad2000_str = "-ac2000"; + + if (xmin || ymin || xmax || ymax) + { if (res) + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %gx%g %g %s -limits %g %g %g %g", filename, width_mm, height_mm, res, acad2000_str, xmin, ymin, xmax, ymax); + else + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %gx%g %s -limits %g %g %g %g", filename, width_mm, height_mm, acad2000_str, xmin, ymin, xmax, ymax); + } + else + { if (res) + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %gx%g %g %s %s%s", filename, width_mm, height_mm, res, acad2000_str); + else + canvas = cdCreateCanvasf(CD_DXF, "\"%s\" %gx%g %s %s%s", filename, width_mm, height_mm, acad2000_str); + } + } + }; + class CanvasMetafileCGM : public Canvas + { + public: + CanvasMetafileCGM(const char* filename, double res = 0, bool text_encoding = false, const char* precision = 0, const char* description = 0) + : Canvas() { char* text_encoding_str = ""; + if (text_encoding) + text_encoding_str = "-d"; + + if (!precision) /* can be "16" (short), "32" (int), "F" (float), "D" (double) */ + precision = "16"; + + char* description_str = ""; + if (description) + description_str = "-s"; + else + description = ""; + + if (res) + canvas = cdCreateCanvasf(CD_CGM, "\"%s\" %g %s -p%s %s%s", filename, res, text_encoding_str, precision, description_str, description); + else + canvas = cdCreateCanvasf(CD_CGM, "\"%s\" %s -p%s %s%s", filename, text_encoding_str, precision, description_str, description); + } + CanvasMetafileCGM(const char* filename, double width_mm, double height_mm, double res = 0, bool text_encoding = false, const char* precision = 0, const char* description = 0) + : Canvas() { char* text_encoding_str = ""; + if (text_encoding) + text_encoding_str = "-t"; + + if (!precision) /* can be "16" (short), "32" (int), "F" (float), "D" (double) */ + precision = "16"; + + char* description_str = ""; + if (description) + description_str = "-d"; + else + description = ""; + + if (res) + canvas = cdCreateCanvasf(CD_CGM, "\"%s\" %gx%g %g %s -p%s %s%s", filename, width_mm, height_mm, res, text_encoding_str, precision, description_str, description); + else + canvas = cdCreateCanvasf(CD_CGM, "\"%s\" %gx%g %s -p%s %s%s", filename, width_mm, height_mm, text_encoding_str, precision, description_str, description); + } + }; + class CanvasMetafilePDF : public Canvas + { + public: + CanvasMetafilePDF(const char* filename, int paper, int res_dpi = 0, bool landscape = false) + : Canvas() { char* landscape_str = ""; + if (landscape) + landscape_str = "-o"; + + char* res_dpi_str = ""; + if (res_dpi) + res_dpi_str = "-s"; + + canvas = cdCreateCanvasf(CD_PDF, "\"%s\" -p%d %s%s %s", filename, paper, res_dpi_str, res_dpi, landscape_str); + } + CanvasMetafilePDF(const char* filename, double width_mm, double height_mm, int res_dpi = 0, bool landscape = false) + : Canvas() { char* landscape_str = ""; + if (landscape) + landscape_str = "-o"; + + char* res_dpi_str = ""; + if (res_dpi) + res_dpi_str = "-s"; + + canvas = cdCreateCanvasf(CD_PDF, "\"%s\" -w%g -h%g %s%s %s", filename, width_mm, height_mm, res_dpi_str, res_dpi, landscape_str); + } + }; + class CanvasMetafilePS : public Canvas + { + public: + CanvasMetafilePS(const char* filename, int paper, int res_dpi = 0, bool landscape = false) + : Canvas() { char* landscape_str = ""; + if (landscape) + landscape_str = "-o"; + + char* res_dpi_str = ""; + if (res_dpi) + res_dpi_str = "-s"; + + canvas = cdCreateCanvasf(CD_PS, "\"%s\" -p%d %s%s %s", filename, paper, res_dpi_str, res_dpi, landscape_str); + } + CanvasMetafilePS(const char* filename, double width_mm, double height_mm, int res_dpi = 0, bool landscape = false) + : Canvas() { char* landscape_str = ""; + if (landscape) + landscape_str = "-o"; + + char* res_dpi_str = ""; + if (res_dpi) + res_dpi_str = "-s"; + + canvas = cdCreateCanvasf(CD_PS, "\"%s\" -w%g -h%g %s%s %s", filename, width_mm, height_mm, res_dpi_str, res_dpi, landscape_str); + } + CanvasMetafilePS(const char* filename, int res_dpi = 0, bool landscape = false) + : Canvas() { char* landscape_str = ""; + if (landscape) + landscape_str = "-o"; + + char* res_dpi_str = ""; + if (res_dpi) + res_dpi_str = "-s"; + + canvas = cdCreateCanvasf(CD_PS, "\"%s\" -e %s%s %s", filename, res_dpi_str, res_dpi, landscape_str); + } + }; +} + +#endif diff --git a/libs/CD/include/cd_private.h b/libs/CD/include/cd_private.h new file mode 100644 index 0000000..4b8c70c --- /dev/null +++ b/libs/CD/include/cd_private.h @@ -0,0 +1,440 @@ +/** \file + * \brief Private CD declarations + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PRIVATE_H +#define __CD_PRIVATE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* All context canvas must have at least the base canvas pointer. */ +typedef struct _cdCtxCanvasBase +{ + cdCanvas* canvas; +} cdCtxCanvasBase; + +typedef struct _cdCtxCanvas cdCtxCanvas; +typedef struct _cdCtxImage cdCtxImage; + +typedef struct _cdVectorFont cdVectorFont; +typedef struct _cdSimulation cdSimulation; + +typedef struct _cdPoint +{ + int x, y; +} cdPoint; + +typedef struct _cdfPoint +{ + double x, y; +} cdfPoint; + +typedef struct _cdRect +{ + int xmin, xmax, ymin, ymax; +} cdRect; + +typedef struct _cdfRect +{ + double xmin, xmax, ymin, ymax; +} cdfRect; + +typedef struct _cdAttribute +{ + const char *name; + + /* can be NULL one of them */ + void (*set)(cdCtxCanvas* ctxcanvas, char* data); + char* (*get)(cdCtxCanvas* ctxcanvas); +} cdAttribute; + +struct _cdImage +{ + int w, h; + cdCtxImage* ctximage; + + /* can NOT be NULL */ + void (*cxGetImage)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y); + void (*cxPutImageRect)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y, int xmin, int xmax, int ymin, int ymax); + void (*cxKillImage)(cdCtxImage* ctximage); +}; + +struct _cdContext +{ + unsigned long caps; /* canvas capabilities, combination of CD_CAP_* */ + int type; /* context type WINDOW, DEVICE, IMAGE or FILE, combined with PLUS */ + + /* can NOT be NULL */ + void (*cxCreateCanvas)(cdCanvas* canvas, void *data); + void (*cxInitTable)(cdCanvas* canvas); + + /* can be NULL */ + int (*cxPlay)(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data); + int (*cxRegisterCallback)(int cb, cdCallback func); +}; + +struct _cdCanvas +{ + char signature[2]; /* must be "CD" */ + + /* can NOT be NULL */ + void (*cxPixel)(cdCtxCanvas* ctxcanvas, int x, int y, long color); + void (*cxLine)(cdCtxCanvas* ctxcanvas, int x1, int y1, int x2, int y2); + void (*cxPoly)(cdCtxCanvas* ctxcanvas, int mode, cdPoint* points, int n); + void (*cxRect)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxBox)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxArc)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxSector)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxChord)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2); + void (*cxText)(cdCtxCanvas* ctxcanvas, int x, int y, const char *s, int len); + void (*cxKillCanvas)(cdCtxCanvas* ctxcanvas); + int (*cxFont)(cdCtxCanvas* ctxcanvas, const char *type_face, int style, int size); + void (*cxPutImageRectMap)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *index, const long *colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + + /* default implementation uses the simulation driver */ + void (*cxGetFontDim)(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); + void (*cxGetTextSize)(cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height); + + /* all the following function pointers can be NULL */ + + void (*cxFlush)(cdCtxCanvas* ctxcanvas); + void (*cxClear)(cdCtxCanvas* ctxcanvas); + + void (*cxFPixel)(cdCtxCanvas* ctxcanvas, double x, double y, long color); + void (*cxFLine)(cdCtxCanvas* ctxcanvas, double x1, double y1, double x2, double y2); + void (*cxFPoly)(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* points, int n); + void (*cxFRect)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + void (*cxFBox)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + void (*cxFArc)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFSector)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFChord)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2); + void (*cxFText)(cdCtxCanvas* ctxcanvas, double x, double y, const char *s, int len); + + int (*cxClip)(cdCtxCanvas* ctxcanvas, int mode); + void (*cxClipArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); + void (*cxFClipArea)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax); + int (*cxBackOpacity)(cdCtxCanvas* ctxcanvas, int opacity); + int (*cxWriteMode)(cdCtxCanvas* ctxcanvas, int mode); + int (*cxLineStyle)(cdCtxCanvas* ctxcanvas, int style); + int (*cxLineWidth)(cdCtxCanvas* ctxcanvas, int width); + int (*cxLineJoin)(cdCtxCanvas* ctxcanvas, int join); + int (*cxLineCap)(cdCtxCanvas* ctxcanvas, int cap); + int (*cxInteriorStyle)(cdCtxCanvas* ctxcanvas, int style); + int (*cxHatch)(cdCtxCanvas* ctxcanvas, int style); + void (*cxStipple)(cdCtxCanvas* ctxcanvas, int w, int h, const unsigned char *stipple); + void (*cxPattern)(cdCtxCanvas* ctxcanvas, int w, int h, const long *pattern); + int (*cxNativeFont)(cdCtxCanvas* ctxcanvas, const char* font); + int (*cxTextAlignment)(cdCtxCanvas* ctxcanvas, int alignment); + double (*cxTextOrientation)(cdCtxCanvas* ctxcanvas, double angle); + void (*cxPalette)(cdCtxCanvas* ctxcanvas, int n, const long *palette, int mode); + long (*cxBackground)(cdCtxCanvas* ctxcanvas, long color); + long (*cxForeground)(cdCtxCanvas* ctxcanvas, long color); + void (*cxTransform)(cdCtxCanvas* ctxcanvas, const double* matrix); + + void (*cxGetImageRGB)(cdCtxCanvas* ctxcanvas, unsigned char *r, unsigned char *g, unsigned char *b, int x, int y, int w, int h); + void (*cxPutImageRectRGB)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + void (*cxPutImageRectRGBA)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); + + void (*cxFPutImageRectRGB)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + void (*cxFPutImageRectRGBA)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + void (*cxFPutImageRectMap)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + + void (*cxScrollArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); + + cdCtxImage* (*cxCreateImage)(cdCtxCanvas* ctxcanvas, int w, int h); + void (*cxKillImage)(cdCtxImage* ctximage); + void (*cxGetImage)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y); + void (*cxPutImageRect)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y, int xmin, int xmax, int ymin, int ymax); + + void (*cxNewRegion)(cdCtxCanvas* ctxcanvas); + int (*cxIsPointInRegion)(cdCtxCanvas* ctxcanvas, int x, int y); + void (*cxOffsetRegion)(cdCtxCanvas* ctxcanvas, int x, int y); + void (*cxGetRegionBox)(cdCtxCanvas* ctxcanvas, int *xmin, int *xmax, int *ymin, int *ymax); + + int (*cxActivate)(cdCtxCanvas* ctxcanvas); + void (*cxDeactivate)(cdCtxCanvas* ctxcanvas); + + /* the driver must update these, when the canvas is created and + whenever the canvas change its size or bpp. */ + int w,h; /* size in pixels */ /**** pixel = mm * res ****/ + double w_mm, h_mm; /* size in mm */ /**** mm = pixel / res ****/ + double xres, yres; /* resolution in pixels/mm */ /**** res = pixel / mm ****/ + int bpp; /* number of bits per pixel */ + int invert_yaxis; /* invert Y coordinates before calling the driver, + used only when the native Y axis orientation is top-bottom "!(cap&CD_CAP_YAXIS)". + It is turned off by the driver if native transformation matrix is used. */ + double matrix[6]; + int use_matrix; + + /* clipping attributes */ + int clip_mode; + cdRect clip_rect; + cdfRect clip_frect; + int clip_poly_n; + cdPoint* clip_poly; /* only defined if integer polygon created, if exist clip_fpoly is NULL, and ->Poly exists */ + cdfPoint* clip_fpoly; /* only defined if real polygon created, if exist clip_poly is NULL, and ->fPoly exists */ + + /* clipping region attributes */ + int new_region; + int combine_mode; + + /* color attributes */ + long foreground, background; + int back_opacity, write_mode; + + /* primitive attributes */ + int mark_type, mark_size; + + int line_style, line_width; + int line_cap, line_join; + int* line_dashes; + int line_dashes_count; + + int interior_style, hatch_style; + int fill_mode; + + char font_type_face[1024]; + int font_style, font_size; + int text_alignment; + double text_orientation; + char native_font[1024]; + + int pattern_w, pattern_h, pattern_size; + long* pattern; + int stipple_w, stipple_h, stipple_size; + unsigned char* stipple; + + /* origin */ + int use_origin; + cdPoint origin; /* both points contains the same coordinate always */ + cdfPoint forigin; + + /* last polygon */ + int poly_mode, + poly_n, /* current number of vertices */ + poly_size, fpoly_size; /* allocated number of vertices, only increases */ + cdPoint* poly; /* used during an integer polygon creation */ + cdfPoint* fpoly; /* used during an real polygon creation, only if ->cxFPoly exists */ + int use_fpoly; + + /* last path */ + int path_n, /* current number of actions */ + path_size; /* allocated number of actions, only increases */ + int* path; /* used during path creation */ + int path_arc_index; /* used for arc */ + + /* simulation flags */ + int sim_mode; + + /* WC */ + double s, sx, tx, sy, ty; /* Transform Window -> Viewport (scale+translation)*/ + cdfRect window; /* Window in WC */ + cdRect viewport; /* Viewport in pixels */ + + cdAttribute* attrib_list[50]; + int attrib_n; + + cdVectorFont* vector_font; + cdSimulation* simulation; + cdCtxCanvas* ctxcanvas; + cdContext* context; + + void* userdata; +}; + +enum{CD_BASE_WIN, CD_BASE_X, CD_BASE_GDK, CD_BASE_HAIKU}; +int cdBaseDriver(void); + +/***************/ +/* attributes */ +/***************/ +void cdRegisterAttribute(cdCanvas* canvas, cdAttribute* attrib); +void cdUpdateAttributes(cdCanvas* canvas); + +/***************/ +/* vector font */ +/***************/ +cdVectorFont* cdCreateVectorFont(cdCanvas* canvas); +void cdKillVectorFont(cdVectorFont* vector_font_data); + +/**********/ +/* WC */ +/**********/ +void wdSetDefaults(cdCanvas* canvas); + +/********************/ +/* Context Plus */ +/********************/ +void cdInitContextPlusList(cdContext* ctx_list[]); +cdContext* cdGetContextPlus(int ctx); +enum{CD_CTXPLUS_NATIVEWINDOW, CD_CTXPLUS_IMAGE, CD_CTXPLUS_DBUFFER, CD_CTXPLUS_PRINTER, CD_CTXPLUS_EMF, CD_CTXPLUS_CLIPBOARD}; +#define CD_CTXPLUS_COUNT 6 +#define CD_CTX_PLUS 0xFF00 /* to combine with context type */ + +/*************/ +/* utilities */ +/*************/ +int cdRound(double x); +int cdCheckBoxSize(int *xmin, int *xmax, int *ymin, int *ymax); +int cdfCheckBoxSize(double *xmin, double *xmax, double *ymin, double *ymax); +void cdNormalizeLimits(int w, int h, int *xmin, int *xmax, int *ymin, int *ymax); +int cdGetFileName(const char* strdata, char* filename); +int cdStrEqualNoCase(const char* str1, const char* str2); +int cdStrEqualNoCasePartial(const char* str1, const char* str2); +int cdStrLineCount(const char* str); +char* cdStrDup(const char* str); +char* cdStrDupN(const char* str, int len); +int cdStrIsAscii(const char* str); +char* cdStrConvertToUTF8(const char* str, int len, char* utf8_buffer, int *utf8_buffer_len, int utf8mode); +void cdSetPaperSize(int size, double *w_pt, double *h_pt); +int cdGetFontFileName(const char* type_face, char* filename); +int cdGetFontFileNameDefault(const char *type_face, int style, char* filename); +int cdGetFontFileNameSystem(const char *type_face, int style, char* filename); +int cdStrTmpFileName(char* filename); +int cdMakeDirectory(const char *path); +int cdIsDirectory(const char* path); +int cdRemoveDirectory(const char *path); +void cdCopyFile(const char* srcFile, const char* destFile); + +typedef struct _cdDirData +{ + const char* path; + char filename[1024]; + int isDir; + int closed; + void* handle; +} cdDirData; + +cdDirData* cdDirIterOpen(const char *path); +int cdDirIter(cdDirData * dirData); +void cdDirClose(cdDirData* dirData); + +void cdPoly(cdCanvas* canvas, int mode, cdPoint* points, int n); + +void cdGetArcBox(int xc, int yc, int w, int h, double a1, double a2, int *xmin, int *xmax, int *ymin, int *ymax); +int cdGetArcPathF(const cdPoint* poly, double *xc, double *yc, double *w, double *h, double *a1, double *a2); +int cdfGetArcPath(const cdfPoint* poly, double *xc, double *yc, double *w, double *h, double *a1, double *a2); +int cdGetArcPath(const cdPoint* poly, int *xc, int *yc, int *w, int *h, double *a1, double *a2); +void cdGetArcStartEnd(int xc, int yc, int w, int h, double a1, double a2, int *x1, int *y1, int *x2, int *y2); +void cdfGetArcStartEnd(double xc, double yc, double w, double h, double a1, double a2, double *x1, double *y1, double *x2, double *y2); + +#define _cdCheckCanvas(_canvas) (_canvas!=NULL && ((unsigned char*)_canvas)[0] == 'C' && ((unsigned char*)_canvas)[1] == 'D') +#define _cdSwapInt(_a,_b) {int _c=_a;_a=_b;_b=_c;} +#define _cdSwapDouble(_a,_b) {double _c=_a;_a=_b;_b=_c;} +#define _cdRound(_x) ((int)(_x < 0? (_x-0.5): (_x+0.5))) +#define _cdRotateHatch(_x) ((_x) = ((_x)<< 1) | ((_x)>>7)) +#define _cdInvertYAxis(_canvas, _y) (_canvas->h - (_y) - 1) + + +/******************/ +/* Transformation */ +/******************/ +void cdMatrixTransformPoint(double* matrix, int x, int y, int *rx, int *ry); +void cdfMatrixTransformPoint(double* matrix, double x, double y, double *rx, double *ry); +void cdMatrixMultiply(const double* matrix, double* mul_matrix); +void cdMatrixInverse(const double* matrix, double* inv_matrix); +void cdfRotatePoint(cdCanvas* canvas, double x, double y, double cx, double cy, double *rx, double *ry, double sin_theta, double cos_theta); +void cdRotatePoint(cdCanvas* canvas, int x, int y, int cx, int cy, int *rx, int *ry, double sin_teta, double cos_teta); +void cdRotatePointY(cdCanvas* canvas, int x, int y, int cx, int cy, int *ry, double sin_theta, double cos_theta); +void cdfRotatePointY(cdCanvas* canvas, double x, double y, double cx, double cy, double *ry, double sin_theta, double cos_theta); +void cdTextTranslatePoint(cdCanvas* canvas, int x, int y, int w, int h, int baseline, int *rx, int *ry); +void cdfTextTranslatePoint(cdCanvas* canvas, double x, double y, int w, int h, int baseline, double *rx, double *ry); +void cdMovePoint(int *x, int *y, double dx, double dy, double sin_theta, double cos_theta); +void cdfMovePoint(double *x, double *y, double dx, double dy, double sin_theta, double cos_theta); + +/*************/ +/* Fonts */ +/*************/ +int cdParsePangoFont(const char *nativefont, char *type_face, int *style, int *size); +int cdParseIupWinFont(const char *nativefont, char *type_face, int *style, int *size); +int cdParseXWinFont(const char *nativefont, char *type_face, int *style, int *size); +int cdGetFontSizePixels(cdCanvas* canvas, int size); +int cdGetFontSizePoints(cdCanvas* canvas, int size); + +/* Replacements for Font using estimation */ +/* cdfontex.c */ +void cdgetfontdimEX(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); +void cdgettextsizeEX(cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height); + +/****************/ +/* For Images */ +/****************/ +unsigned char cdZeroOrderInterpolation(int width, int height, const unsigned char *map, double xl, double yl); +unsigned char cdBilinearInterpolation(int width, int height, const unsigned char *map, double xl, double yl); +void cdImageRGBInitInverseTransform(int w, int h, int xmin, int xmax, int ymin, int ymax, double *xfactor, double *yfactor, const double* matrix, double* inv_matrix); +void cdImageRGBInverseTransform(int t_x, int t_y, double *i_x, double *i_y, double xfactor, double yfactor, int xmin, int ymin, int x, int y, double *inv_matrix); +void cdImageRGBCalcDstLimits(cdCanvas* canvas, int x, int y, int w, int h, int *xmin, int *xmax, int *ymin, int *ymax, int* rect); +void cdRGB2Gray(int width, int height, const unsigned char* red, const unsigned char* green, const unsigned char* blue, unsigned char* index, long *color); + +#define CD_ALPHA_BLEND(_src,_dst,_alpha) (unsigned char)(((_src) * (_alpha) + (_dst) * (255 - (_alpha))) / 255) + +int* cdGetZoomTable(int w, int rw, int xmin); +int cdCalcZoom(int canvas_size, int cnv_rect_pos, int cnv_rect_size, + int *new_cnv_rect_pos, int *new_cnv_rect_size, + int img_rect_pos, int img_rect_size, + int *new_img_rect_pos, int *new_img_rect_size, int is_horizontal); + +/**************/ +/* simulation */ +/**************/ + +/* sim.c */ +/* simulation base driver. */ +cdSimulation* cdCreateSimulation(cdCanvas* canvas); +void cdKillSimulation(cdSimulation* simulation); +void cdSimulationInitText(cdSimulation* simulation); + +/* sim_text.c */ +/* Replacements for Text and Font using FreeType library */ +void cdSimulationText(cdCtxCanvas* ctxcanvas, int x, int y, const char *s, int len); +int cdSimulationFont(cdCtxCanvas* ctxcanvas, const char *type_face, int style, int size); +void cdSimulationGetFontDim(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent); +void cdSimulationGetTextSize(cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height); + +/* sim_linepolyfill.c */ +void cdfSimulationPoly(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* fpoly, int n); +void cdSimulationPoly(cdCtxCanvas* ctxcanvas, int mode, cdPoint* poly, int n); + +/* sim_primitives.c */ +/* Simulation functions that are >> independent << of the simulation base driver. */ + +void cdSimMark(cdCanvas* canvas, int x, int y); +void cdfSimMark(cdCanvas* canvas, double x, double y); +void cdSimPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdSimPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax); +void cdfSimPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void cdfSimPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + +/* All these use cdPoly. */ +void cdSimLine(cdCtxCanvas* ctxcanvas, int x1, int y1, int x2, int y2); +void cdSimRect(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); +void cdSimBox(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax); +void cdSimArc(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdSimSector(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdSimChord(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, double angle1, double angle2); +void cdSimPolyBezier(cdCanvas* canvas, const cdPoint* points, int n); +void cdSimPolyPath(cdCanvas* canvas, const cdPoint* points, int n); + +/* All these use the polygon method ->cxFPoly only. */ +/* can be used only by drivers that implement cxFPoly */ +void cdfSimLine(cdCtxCanvas* ctxcanvas, double x1, double y1, double x2, double y2); +void cdfSimRect(cdCtxCanvas *ctxcanvas, double xmin, double xmax, double ymin, double ymax); +void cdfSimBox(cdCtxCanvas *ctxcanvas, double xmin, double xmax, double ymin, double ymax); +void cdfSimArc(cdCtxCanvas *ctxcanvas, double xc, double yc, double width, double height, double angle1, double angle2); +void cdfSimSector(cdCtxCanvas *ctxcanvas, double xc, double yc, double width, double height, double angle1, double angle2); +void cdfSimChord(cdCtxCanvas *ctxcanvas, double xc, double yc, double width, double height, double angle1, double angle2); +void cdfSimPolyBezier(cdCanvas* canvas, const cdfPoint* points, int n); +void cdfSimPolyPath(cdCanvas* canvas, const cdfPoint* points, int n); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdcairo.h b/libs/CD/include/cdcairo.h new file mode 100644 index 0000000..81d54dc --- /dev/null +++ b/libs/CD/include/cdcairo.h @@ -0,0 +1,45 @@ +/** \file + * \brief Cairo extra drivers. + * Rendering PDF, PS, SVG and IMAGERGB. + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CAIRO_H +#define __CD_CAIRO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Some of these context can be used directly or by cdInitContextPlus, + as CD_NATIVEWINDOW, CD_IMAGE, CD_EMF, CD_PRINTER and CD_DBUFFER. + The others only directly. +*/ + +cdContext* cdContextCairoNativeWindow(void); +cdContext* cdContextCairoImage(void); +cdContext* cdContextCairoDBuffer(void); +cdContext* cdContextCairoPrinter(void); +cdContext* cdContextCairoPS(void); +cdContext* cdContextCairoPDF(void); +cdContext* cdContextCairoSVG(void); +cdContext* cdContextCairoImageRGB(void); +cdContext* cdContextCairoEMF(void); + +#define CD_CAIRO_NATIVEWINDOW cdContextCairoNativeWindow() +#define CD_CAIRO_IMAGE cdContextCairoImage() +#define CD_CAIRO_DBUFFER cdContextCairoDBuffer() +#define CD_CAIRO_PRINTER cdContextCairoPrinter() +#define CD_CAIRO_PS cdContextCairoPS() +#define CD_CAIRO_PDF cdContextCairoPDF() +#define CD_CAIRO_SVG cdContextCairoSVG() +#define CD_CAIRO_IMAGERGB cdContextCairoImageRGB() +#define CD_CAIRO_EMF cdContextCairoEMF() + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_CAIRO_ */ diff --git a/libs/CD/include/cdcgm.h b/libs/CD/include/cdcgm.h new file mode 100644 index 0000000..2e686a7 --- /dev/null +++ b/libs/CD/include/cdcgm.h @@ -0,0 +1,34 @@ +/** \file + * \brief CGM driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CGM_H +#define __CD_CGM_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextCGM(void); +#define CD_CGM cdContextCGM() + +#define CD_CGMCOUNTERCB 1 +#define CD_CGMSCLMDECB 2 +#define CD_CGMVDCEXTCB 3 +#define CD_CGMBEGPICTCB 4 +#define CD_CGMBEGPICTBCB 5 +#define CD_CGMBEGMTFCB 6 + +/* OLD definitions, defined for backward compatibility */ +#define CDPLAY_ABORT CD_ABORT +#define CDPLAY_GO CD_CONTINUE + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_CGM_ */ + + diff --git a/libs/CD/include/cdclipbd.h b/libs/CD/include/cdclipbd.h new file mode 100644 index 0000000..b1594bc --- /dev/null +++ b/libs/CD/include/cdclipbd.h @@ -0,0 +1,22 @@ +/** \file + * \brief Clipboard driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_CLIPBOARD_H +#define __CD_CLIPBOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextClipboard(void); + +#define CD_CLIPBOARD cdContextClipboard() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cddbuf.h b/libs/CD/include/cddbuf.h new file mode 100644 index 0000000..4eae9a9 --- /dev/null +++ b/libs/CD/include/cddbuf.h @@ -0,0 +1,23 @@ +/** \file + * \brief Double Buffer driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DBUF_H +#define __CD_DBUF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDBuffer(void); + +#define CD_DBUFFER cdContextDBuffer() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DBUF_ */ + diff --git a/libs/CD/include/cddebug.h b/libs/CD/include/cddebug.h new file mode 100644 index 0000000..0d3c5c6 --- /dev/null +++ b/libs/CD/include/cddebug.h @@ -0,0 +1,24 @@ +/** \file + * \brief CD Debug driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DEBUG_H +#define __CD_DEBUG_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDebug(void); + +#define CD_DEBUG cdContextDebug() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DEBUG_H */ + + diff --git a/libs/CD/include/cddgn.h b/libs/CD/include/cddgn.h new file mode 100644 index 0000000..ed90f40 --- /dev/null +++ b/libs/CD/include/cddgn.h @@ -0,0 +1,23 @@ +/** \file + * \brief DGN driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DGN_H +#define __CD_DGN_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDGN(void); + +#define CD_DGN cdContextDGN() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DGN_ */ + diff --git a/libs/CD/include/cddirect2d.h b/libs/CD/include/cddirect2d.h new file mode 100644 index 0000000..f058947 --- /dev/null +++ b/libs/CD/include/cddirect2d.h @@ -0,0 +1,35 @@ +/** \file + * \brief Direct2D extra drivers. + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DIRECT2D_H +#define __CD_DIRECT2D_H + +#ifdef __cplusplus +extern "C" { +#endif + + +cdContext* cdContextDirect2DNativeWindow(void); /* already double buffered */ +cdContext* cdContextDirect2DImage(void); /* to draw on an image */ +cdContext* cdContextDirect2DImageRGB(void); /* to draw on an RGBA image */ +cdContext* cdContextDirect2DDBuffer(void); /* Not necessary, used to test image drawing */ +cdContext* cdContextDirect2DPrinter(void); /* NOT working */ + +#define CD_DIRECT2D_NATIVEWINDOW cdContextDirect2DNativeWindow() +#define CD_DIRECT2D_IMAGE cdContextDirect2DImage() +#define CD_DIRECT2D_IMAGERGB cdContextDirect2DImageRGB() +#define CD_DIRECT2D_DBUFFER cdContextDirect2DDBuffer() +#define CD_DIRECT2D_PRINTER cdContextDirect2DPrinter() + +void cdInitDirect2D(void); +void cdFinishDirect2D(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DIRECT2D_H */ diff --git a/libs/CD/include/cddxf.h b/libs/CD/include/cddxf.h new file mode 100644 index 0000000..402504e --- /dev/null +++ b/libs/CD/include/cddxf.h @@ -0,0 +1,22 @@ +/** \file + * \brief DXF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_DXF_H +#define __CD_DXF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextDXF(void); + +#define CD_DXF cdContextDXF() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_DXF_ */ diff --git a/libs/CD/include/cdemf.h b/libs/CD/include/cdemf.h new file mode 100644 index 0000000..20e15fe --- /dev/null +++ b/libs/CD/include/cdemf.h @@ -0,0 +1,22 @@ +/** \file + * \brief EMF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_EMF_H +#define __CD_EMF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextEMF(void); + +#define CD_EMF cdContextEMF() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdgdiplus.h b/libs/CD/include/cdgdiplus.h new file mode 100644 index 0000000..75e24f3 --- /dev/null +++ b/libs/CD/include/cdgdiplus.h @@ -0,0 +1,29 @@ +/** \file + * \brief GDI+ Control + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_GDIPLUS_H +#define __CD_GDIPLUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WIN32 +void cdInitGdiPlus(void); /* old function, replaced by cdInitContextPlus */ +#else +#define cdInitGdiPlus() (0) +#endif + +/* Windows GDI+ Adicional Polygons */ +#define CD_SPLINE (CD_POLYCUSTOM+0) +#define CD_FILLSPLINE (CD_POLYCUSTOM+1) +#define CD_FILLGRADIENT (CD_POLYCUSTOM+2) + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _CD_GDIPLUS_ */ diff --git a/libs/CD/include/cdgl.h b/libs/CD/include/cdgl.h new file mode 100644 index 0000000..946268a --- /dev/null +++ b/libs/CD/include/cdgl.h @@ -0,0 +1,23 @@ +/** \file +* \brief OpenGL driver +* +* See Copyright Notice in cd.h +*/ + +#ifndef __CD_GL_H +#define __CD_GL_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextGL(void); + +#define CD_GL cdContextGL() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_GL_ */ + diff --git a/libs/CD/include/cdim.h b/libs/CD/include/cdim.h new file mode 100644 index 0000000..163552d --- /dev/null +++ b/libs/CD/include/cdim.h @@ -0,0 +1,33 @@ +/** \file + * \brief imImage driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IM_H +#define __CD_IM_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextImImage(void); + +#define CD_IMIMAGE cdContextImImage() + + +#ifdef __IM_IMAGE_H +void cdCanvasPatternImImage(cdCanvas* canvas, const imImage* image); +void cdCanvasStippleImImage(cdCanvas* canvas, const imImage* image); +void cdCanvasPutImImage(cdCanvas* canvas, const imImage* image, int x, int y, int w, int h); +void cdCanvasGetImImage(cdCanvas* canvas, imImage* image, int x, int y); +void cdfCanvasPutImImage(cdCanvas* canvas, const imImage* image, double x, double y, double w, double h); +void wdCanvasPutImImage(cdCanvas* canvas, const imImage* image, double x, double y, double w, double h); +void wdCanvasGetImImage(cdCanvas* canvas, imImage* image, double x, double y); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_IM_ */ diff --git a/libs/CD/include/cdimage.h b/libs/CD/include/cdimage.h new file mode 100644 index 0000000..3573ef2 --- /dev/null +++ b/libs/CD/include/cdimage.h @@ -0,0 +1,23 @@ +/** \file + * \brief Server Image driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IMAGE_H +#define __CD_IMAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextImage(void); + +#define CD_IMAGE cdContextImage() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_IMAGE_ */ + diff --git a/libs/CD/include/cdirgb.h b/libs/CD/include/cdirgb.h new file mode 100644 index 0000000..187f2e6 --- /dev/null +++ b/libs/CD/include/cdirgb.h @@ -0,0 +1,32 @@ +/** \file + * \brief IMAGERGB driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IRGB_H +#define __CD_IRGB_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextImageRGB(void); +cdContext* cdContextDBufferRGB(void); + +#define CD_IMAGERGB cdContextImageRGB() +#define CD_DBUFFERRGB cdContextDBufferRGB() + +/* DEPRECATED functions, use REDIMAGE, GREENIMAGE, + BLUEIMAGE, and ALPHAIMAGE attributes. */ +unsigned char* cdRedImage(cdCanvas* cnv); +unsigned char* cdGreenImage(cdCanvas* cnv); +unsigned char* cdBlueImage(cdCanvas* cnv); +unsigned char* cdAlphaImage(cdCanvas* cnv); + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_IRGB_ */ diff --git a/libs/CD/include/cdiup.h b/libs/CD/include/cdiup.h new file mode 100644 index 0000000..abea13b --- /dev/null +++ b/libs/CD/include/cdiup.h @@ -0,0 +1,29 @@ +/** \file + * \brief IUP driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_IUP_H +#define __CD_IUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* NOTICE: implemented in IUP at the IUPCD library. + Only this file is at the CD includes. */ + +cdContext* cdContextIup(void); +cdContext* cdContextIupDBuffer(void); +cdContext* cdContextIupDBufferRGB(void); + +#define CD_IUP cdContextIup() +#define CD_IUPDBUFFER cdContextIupDBuffer() +#define CD_IUPDBUFFERRGB cdContextIupDBufferRGB() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdlua.h b/libs/CD/include/cdlua.h new file mode 100644 index 0000000..a353dd8 --- /dev/null +++ b/libs/CD/include/cdlua.h @@ -0,0 +1,40 @@ +/** \file + * \brief Lua Binding Control + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUA_H +#define __CD_LUA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdlua_open(void); +void cdlua_close(void); + +/* utilities */ +cdCanvas* cdlua_getcanvas(void); /* pos=1, deprecated use cdlua_checkcanvas */ +cdCanvas* cdlua_checkcanvas(int pos); +void cdlua_pushcanvas(cdCanvas* canvas); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdlua_open(lua_State *L); +int cdlua_close(lua_State *L); + +/* utilities */ +cdCanvas* cdlua_getcanvas(lua_State * L); /* pos=1, deprecated use cdlua_checkcanvas */ +cdCanvas* cdlua_checkcanvas(lua_State * L, int pos); +void cdlua_pushcanvas(lua_State * L, cdCanvas* canvas); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libs/CD/include/cdlua3_private.h b/libs/CD/include/cdlua3_private.h new file mode 100644 index 0000000..3c84c72 --- /dev/null +++ b/libs/CD/include/cdlua3_private.h @@ -0,0 +1,120 @@ +/** \file + * \brief Private Lua 3 Binding Functions + * + * See Copyright Notice in cd.h + */ + +#ifndef __CDLUA3_PRIVATE_H +#define __CDLUA3_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define COLOR_TAG "CDLUA_COLOR_TAG" +#define CANVAS_TAG "CDLUA_CANVAS_TAG" +#define STATE_TAG "CDLUA_STATE_TAG" +#define BITMAP_TAG "CDLUA_BITMAP_TAG" +#define IMAGE_TAG "CDLUA_IMAGE_TAG" +#define IMAGERGB_TAG "CDLUA_IMAGERGB_TAG" +#define IMAGERGBA_TAG "CDLUA_IMAGERGBA_TAG" +#define STIPPLE_TAG "CDLUA_STIPPLE_TAG" +#define PATTERN_TAG "CDLUA_PATTERN_TAG" +#define PALETTE_TAG "CDLUA_PALETTE_TAG" +#define IMAGEMAP_TAG "CDLUA_IMAGEMAP_TAG" +#define CHANNEL_TAG "CDLUA_CHANNEL_TAG" + +/* context management */ + +typedef struct _cdCallbackLUA { + int lock; + char *name; + cdCallback func; +} cdCallbackLUA; + +typedef struct _cdContextLUA { + int id; + char *name; + cdContext* (*ctx)(void); + void* (*checkdata)(int param); + cdCallbackLUA* cb_list; + int cb_n; +} cdContextLUA; + +void cdlua_addcontext(cdContextLUA* luactx); +void cdlua_register(char* name, lua_CFunction func); +void cdlua_pushnumber(double num, char* name); + +/* tag management */ + +typedef struct _canvas_t { + cdCanvas *cd_canvas; +} canvas_t; + +typedef struct _state_t { + cdState *state; +} state_t; + +typedef struct _stipple_t { + unsigned char *value; + int width; + int height; + long int size; +} stipple_t; + +typedef struct _pattern_t { + long int *color; + int width; + int height; + long int size; +} pattern_t; + +typedef struct _palette_t { + long int *color; + long int size; +} palette_t; + +typedef struct _image_t { + void *cd_image; +} image_t; + +typedef struct _imagergb_t { + unsigned char *red; + unsigned char *green; + unsigned char *blue; + int width; + int height; + long int size; +} imagergb_t; + +typedef struct _imagergba_t { + unsigned char *red; + unsigned char *green; + unsigned char *blue; + unsigned char *alpha; + int width; + int height; + long int size; +} imagergba_t; + +typedef struct _imagemap_t { + unsigned char *index; + int width; + int height; + long int size; +} imagemap_t; + +typedef struct _channel_t { + unsigned char *value; + long int size; +} channel_t; + +typedef struct _bitmap_t { + cdBitmap *image; +} bitmap_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdlua5_private.h b/libs/CD/include/cdlua5_private.h new file mode 100644 index 0000000..fd62a29 --- /dev/null +++ b/libs/CD/include/cdlua5_private.h @@ -0,0 +1,145 @@ +/** \file +* \brief Private Lua 5 Binding Functions +* +* See Copyright Notice in cd.h +*/ + +#ifndef __CDLUA5_PRIVATE_H +#define __CDLUA5_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* context management */ + +typedef struct _cdluaCallback { + int lock; + const char* name; + cdCallback func; +} cdluaCallback; + +typedef struct _cdluaContext { + int id; + const char* name; + cdContext* (*ctx)(void); + void* (*checkdata)(lua_State* L,int param); + cdluaCallback* cb_list; + int cb_n; +} cdluaContext; + +typedef struct _cdluaLuaState { + cdCanvas* void_canvas; /* the VOID canvas to avoid a NULL active canvas */ + cdluaContext* drivers[50]; /* store the registered drivers, map integer values to cdContext */ + int numdrivers; +} cdluaLuaState; + +/* metatables */ + +typedef struct _cdluaStipple { + unsigned char* stipple; + int width; + int height; + long int size; +} cdluaStipple; + +typedef struct _cdluaPattern { + long* pattern; + int width; + int height; + long int size; +} cdluaPattern; + +/* this is the same declaration used in the IM toolkit for imPalette in Lua */ +typedef struct _cdluaPalette { + long* color; + int count; +} cdluaPalette; + +typedef struct _cdluaImageRGB { + unsigned char* red; + unsigned char* green; + unsigned char* blue; + int width; + int height; + long int size; + int free; +} cdluaImageRGB; + +typedef struct _cdluaImageRGBA { + unsigned char* red; + unsigned char* green; + unsigned char* blue; + unsigned char* alpha; + int width; + int height; + long int size; + int free; +} cdluaImageRGBA; + +typedef struct _cdluaImageMap { + unsigned char* index; + int width; + int height; + long int size; +} cdluaImageMap; + +typedef struct _cdluaImageChannel { + unsigned char* channel; + long int size; +} cdluaImageChannel; + + +cdluaLuaState* cdlua_getstate(lua_State* L); +cdluaContext* cdlua_getcontext(lua_State* L, int param); + +lua_State* cdlua_getplaystate(void); +void cdlua_setplaystate(lua_State* L); + +void cdlua_register_lib(lua_State *L, const luaL_Reg* funcs); +void cdlua_register_funcs(lua_State *L, const luaL_Reg* funcs); + +void cdlua_kill_active(lua_State* L, cdCanvas* canvas); +void cdlua_open_active(lua_State* L, cdluaLuaState* cdL); +void cdlua_close_active(cdluaLuaState* cdL); + +void cdlua_open_canvas(lua_State* L); + +void cdlua_addcontext(lua_State* L, cdluaLuaState* cdL, cdluaContext* luactx); +void cdlua_initdrivers(lua_State* L, cdluaLuaState* cdL); + +cdluaPalette* cdlua_checkpalette(lua_State* L, int param); +cdluaStipple* cdlua_checkstipple(lua_State* L, int param); +cdluaPattern* cdlua_checkpattern(lua_State* L, int param); +cdluaImageRGB* cdlua_checkimagergb(lua_State* L, int param); +cdluaImageRGBA* cdlua_checkimagergba(lua_State* L, int param); +cdluaImageMap* cdlua_checkimagemap(lua_State* L, int param); +cdluaImageChannel* cdlua_checkchannel(lua_State* L, int param); + +long cdlua_checkcolor(lua_State* L, int param); +cdImage* cdlua_checkimage(lua_State* L, int param); +cdState* cdlua_checkstate(lua_State* L, int param); +cdBitmap* cdlua_checkbitmap(lua_State* L, int param); + +void cdlua_pushcolor(lua_State* L, long color); +void cdlua_pushpalette(lua_State* L, long* palette, int size); +void cdlua_pushstipple(lua_State* L, unsigned char* stipple, int width, int height); +void cdlua_pushpattern(lua_State* L, long int* pattern, int width, int height); +void cdlua_pushimagergb(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height); +void cdlua_pushimagergba(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height); +void cdlua_pushimagemap(lua_State* L, unsigned char* index, int width, int height); +void cdlua_pushchannel(lua_State* L, unsigned char* channel, int size); + +void cdlua_pushimage(lua_State* L, cdImage* image); +void cdlua_pushstate(lua_State* L, cdState* state); +void cdlua_pushbitmap(lua_State* L, cdBitmap* bitmap); + +void cdlua_pushimagergb_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height); +void cdlua_pushimagergba_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdluagl.h b/libs/CD/include/cdluagl.h new file mode 100644 index 0000000..412d745 --- /dev/null +++ b/libs/CD/include/cdluagl.h @@ -0,0 +1,27 @@ +/** \file + * \brief OpenGL Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAGL_H +#define __CD_LUAGL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluagl_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluagl_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libs/CD/include/cdluaim.h b/libs/CD/include/cdluaim.h new file mode 100644 index 0000000..a421431 --- /dev/null +++ b/libs/CD/include/cdluaim.h @@ -0,0 +1,22 @@ +/** \file + * \brief CD+IM Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAIM_H +#define __CD_LUAIM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluaim_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdluaiup.h b/libs/CD/include/cdluaiup.h new file mode 100644 index 0000000..570d7f1 --- /dev/null +++ b/libs/CD/include/cdluaiup.h @@ -0,0 +1,27 @@ +/** \file + * \brief IUP Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAIUP_H +#define __CD_LUAIUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluaiup_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluaiup_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libs/CD/include/cdluapdf.h b/libs/CD/include/cdluapdf.h new file mode 100644 index 0000000..45b4d98 --- /dev/null +++ b/libs/CD/include/cdluapdf.h @@ -0,0 +1,27 @@ +/** \file + * \brief PDF Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAPDF_H +#define __CD_LUAPDF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluapdf_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluapdf_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libs/CD/include/cdmf.h b/libs/CD/include/cdmf.h new file mode 100644 index 0000000..7cc2a93 --- /dev/null +++ b/libs/CD/include/cdmf.h @@ -0,0 +1,24 @@ +/** \file + * \brief CD Metafile driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_MF_H +#define __CD_MF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextMetafile(void); + +#define CD_METAFILE cdContextMetafile() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_MF_ */ + + diff --git a/libs/CD/include/cdmf_private.h b/libs/CD/include/cdmf_private.h new file mode 100644 index 0000000..7da5b90 --- /dev/null +++ b/libs/CD/include/cdmf_private.h @@ -0,0 +1,32 @@ +/** \file + * \brief CD Metafile driver private declarations + * + * See Copyright Notice in cd.h + */ + +#ifndef __CDMF_PRIVATE_H +#define __CDMF_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* public part of the internal cdCtxCanvas */ +typedef struct cdCanvasMF +{ + cdCanvas* canvas; + char* filename; + void* data; +} cdCanvasMF; + +void cdcreatecanvasMF(cdCanvas *canvas, void *data); +void cdinittableMF(cdCanvas* canvas); +void cdkillcanvasMF(cdCanvasMF *mfcanvas); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/libs/CD/include/cdnative.h b/libs/CD/include/cdnative.h new file mode 100644 index 0000000..66c9c75 --- /dev/null +++ b/libs/CD/include/cdnative.h @@ -0,0 +1,26 @@ +/** \file + * \brief NativeWindow driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_NATIVE_H +#define __CD_NATIVE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextNativeWindow(void); + +#define CD_NATIVEWINDOW cdContextNativeWindow() + +void cdGetScreenSize(int *width, int *height, double *width_mm, double *height_mm); +int cdGetScreenColorPlanes(void); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_NATIVE_ */ + diff --git a/libs/CD/include/cdpdf.h b/libs/CD/include/cdpdf.h new file mode 100644 index 0000000..89486fc --- /dev/null +++ b/libs/CD/include/cdpdf.h @@ -0,0 +1,23 @@ +/** \file + * \brief PDF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PDF_H +#define __CD_PDF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPDF(void); + +#define CD_PDF cdContextPDF() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _CD_PDF_ */ + diff --git a/libs/CD/include/cdpicture.h b/libs/CD/include/cdpicture.h new file mode 100644 index 0000000..860ff97 --- /dev/null +++ b/libs/CD/include/cdpicture.h @@ -0,0 +1,22 @@ +/** \file + * \brief CD Picture driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PICTURE_H +#define __CD_PICTURE_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPicture(void); + +#define CD_PICTURE cdContextPicture() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/cdpptx.h b/libs/CD/include/cdpptx.h new file mode 100644 index 0000000..0808117 --- /dev/null +++ b/libs/CD/include/cdpptx.h @@ -0,0 +1,21 @@ +/** \file + * \brief PPTX driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PPTX_H +#define __CD_PPTX_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPPTX(void); +#define CD_PPTX cdContextPPTX() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_PPTX_ */ diff --git a/libs/CD/include/cdprint.h b/libs/CD/include/cdprint.h new file mode 100644 index 0000000..fff824b --- /dev/null +++ b/libs/CD/include/cdprint.h @@ -0,0 +1,23 @@ +/** \file + * \brief Printer driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PRINTER_H +#define __CD_PRINTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPrinter(void); + +#define CD_PRINTER cdContextPrinter() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_PRINTER_ */ + diff --git a/libs/CD/include/cdps.h b/libs/CD/include/cdps.h new file mode 100644 index 0000000..0f4bdd8 --- /dev/null +++ b/libs/CD/include/cdps.h @@ -0,0 +1,23 @@ +/** \file + * \brief PS driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_PS_H +#define __CD_PS_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextPS(void); + +#define CD_PS cdContextPS() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_PS_ */ + diff --git a/libs/CD/include/cdsvg.h b/libs/CD/include/cdsvg.h new file mode 100644 index 0000000..53861ae --- /dev/null +++ b/libs/CD/include/cdsvg.h @@ -0,0 +1,22 @@ +/** \file + * \brief SVG driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_SVG_H +#define __CD_SVG_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextSVG(void); + +#define CD_SVG cdContextSVG() + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __CD_SVG_ */ diff --git a/libs/CD/include/cdwmf.h b/libs/CD/include/cdwmf.h new file mode 100644 index 0000000..607af6c --- /dev/null +++ b/libs/CD/include/cdwmf.h @@ -0,0 +1,22 @@ +/** \file + * \brief WMF driver + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_WMF_H +#define __CD_WMF_H + +#ifdef __cplusplus +extern "C" { +#endif + +cdContext* cdContextWMF(void); + +#define CD_WMF cdContextWMF() + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/include/wd.h b/libs/CD/include/wd.h new file mode 100644 index 0000000..f9586b3 --- /dev/null +++ b/libs/CD/include/wd.h @@ -0,0 +1,88 @@ +/** \file + * \brief World Coordinate Functions + * + * See Copyright Notice in cd.h + */ + +#ifndef __WD_H +#define __WD_H + +#ifdef __cplusplus +extern "C" { +#endif + +int wdCanvasPlay(cdCanvas* canvas, cdContext *context, double xmin, double xmax, double ymin, double ymax, void *data); + +/* coordinate transformation */ +void wdCanvasWindow(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasGetWindow(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); +void wdCanvasViewport(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); +void wdCanvasGetViewport(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); +void wdCanvasWorld2Canvas(cdCanvas* canvas, double xw, double yw, int *xv, int *yv); +void wdCanvasWorld2CanvasSize(cdCanvas* canvas, double hw, double vw, int *hv, int *vv); +void wdCanvasCanvas2World(cdCanvas* canvas, int xv, int yv, double *xw, double *yw); +void wdCanvasSetTransform(cdCanvas* canvas, double sx, double sy, double tx, double ty); +void wdCanvasGetTransform(cdCanvas* canvas, double *sx, double *sy, double *tx, double *ty); +void wdCanvasTranslate(cdCanvas* canvas, double dtx, double dty); +void wdCanvasScale(cdCanvas* canvas, double dsx, double dsy); + +void wdCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); +int wdCanvasIsPointInRegion(cdCanvas* canvas, double x, double y); +void wdCanvasOffsetRegion(cdCanvas* canvas, double x, double y); +void wdCanvasGetRegionBox(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); + +void wdCanvasHardcopy(cdCanvas* canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)); + +/* primitives */ +void wdCanvasPixel(cdCanvas* canvas, double x, double y, long color); +void wdCanvasMark(cdCanvas* canvas, double x, double y); +void wdCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void wdCanvasVertex(cdCanvas* canvas, double x, double y); +void wdCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); +void wdCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); +void wdCanvasText(cdCanvas* canvas, double x, double y, const char* s); + +void wdCanvasGetImageRGB(cdCanvas* canvas, unsigned char* r, unsigned char* g, unsigned char* b, double x, double y, int iw, int ih); +void wdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); + +void wdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); + +void wdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* bitmap, double x, double y, double w, double h); + +/* attributes */ +double wdCanvasLineWidth(cdCanvas* canvas, double width); +int wdCanvasFont(cdCanvas* canvas, const char* type_face, int style, double size); +void wdCanvasGetFont(cdCanvas* canvas, char *type_face, int *style, double *size); +double wdCanvasMarkSize(cdCanvas* canvas, double size); +void wdCanvasGetFontDim(cdCanvas* canvas, double *max_width, double *height, double *ascent, double *descent); +void wdCanvasGetTextSize(cdCanvas* canvas, const char* s, double *width, double *height); +void wdCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax); +void wdCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* s, double *rect); +void wdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char*fgbg, double w_mm, double h_mm); +void wdCanvasPattern(cdCanvas* canvas, int w, int h, const long *color, double w_mm, double h_mm); + +/* vector text */ +void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); +void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* s); +void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, double *x, double *y); +double wdCanvasVectorCharSize(cdCanvas* canvas, double size); +void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* s); +void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* s); +void wdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, double x, double y, double *rect); +void wdCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char *s, double *xmin, double *xmax, double *ymin, double *ymax); + +#ifdef __cplusplus +} +#endif + +#ifndef CD_NO_OLD_INTERFACE +#include "wd_old.h" +#endif + +#endif diff --git a/libs/CD/include/wd_old.h b/libs/CD/include/wd_old.h new file mode 100644 index 0000000..683c589 --- /dev/null +++ b/libs/CD/include/wd_old.h @@ -0,0 +1,85 @@ +/** \file + * \brief Old WC API + * + * See Copyright Notice in cd.h + */ + +#ifndef WD_OLD_H +#define WD_OLD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* coordinate transformation */ +void wdWindow(double xmin, double xmax, double ymin, double ymax); +void wdGetWindow(double *xmin, double *xmax, double *ymin, double *ymax); +void wdViewport(int xmin, int xmax, int ymin, int ymax); +void wdGetViewport(int *xmin, int *xmax, int *ymin, int *ymax); +void wdWorld2Canvas(double xw, double yw, int *xv, int *yv); +void wdWorld2CanvasSize(double hw, double vw, int *hv, int *vv); +void wdCanvas2World(int xv, int yv, double *xw, double *yw); + +void wdClipArea(double xmin, double xmax, double ymin, double ymax); +int wdGetClipArea(double *xmin, double *xmax, double *ymin, double *ymax); +double* wdGetClipPoly(int *n); +int wdPointInRegion(double x, double y); +void wdOffsetRegion(double x, double y); +void wdRegionBox(double *xmin, double *xmax, double *ymin, double *ymax); + +void wdHardcopy(cdContext* ctx, void *data, cdCanvas *cnv, void(*draw_func)(void)); + +/* primitives */ +void wdPixel(double x, double y, long color); +void wdMark(double x, double y); +void wdLine(double x1, double y1, double x2, double y2); +void wdVertex(double x, double y); +void wdRect(double xmin, double xmax, double ymin, double ymax); +void wdBox(double xmin, double xmax, double ymin, double ymax); +void wdArc(double xc, double yc, double w, double h, double angle1, double angle2); +void wdSector(double xc, double yc, double w, double h, double angle1, double angle2); +void wdChord(double xc, double yc, double w, double h, double angle1, double angle2); +void wdText(double x, double y, const char* s); + +void wdPutImageRect(cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectRGB(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectRGBA(int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutImageRectMap(int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax); +void wdPutBitmap(cdBitmap* bitmap, double x, double y, double w, double h); + +/* attributes */ +double wdLineWidth(double width); +void wdFont(int type_face, int style, double size); +void wdGetFont(int *type_face, int *style, double *size); +double wdMarkSize(double size); +void wdFontDim(double *max_width, double *height, double *ascent, double *descent); +void wdTextSize(const char* s, double *width, double *height); +void wdTextBox(double x, double y, const char* s, double *xmin, double *xmax, double *ymin, double *ymax); +void wdTextBounds(double x, double y, const char* s, double *rect); +void wdStipple(int w, int h, const unsigned char* stipple, double w_mm, double h_mm); +void wdPattern(int w, int h, const long* pattern, double w_mm, double h_mm); + +/* vector text */ +void wdVectorTextDirection(double x1, double y1, double x2, double y2); +void wdVectorTextSize(double size_x, double size_y, const char* s); +void wdGetVectorTextSize(const char* s, double *x, double *y); +double wdVectorCharSize(double size); +void wdVectorText(double x, double y, const char* s); +void wdMultiLineVectorText(double x, double y, const char* s); +void wdGetVectorTextBounds(const char* s, double x, double y, double *rect); + +/* OLD definitions, defined for backward compatibility */ +#define wdVectorFont cdVectorFont +#define wdVectorTextTransform cdVectorTextTransform +#define wdActivate cdActivate +#define wdClip(mode) cdClip(mode) +#define wdBegin(mode) cdBegin(mode) +#define wdEnd() cdEnd(); +#define wdMM2Pixel(mm_dx, mm_dy, dx, dy) cdMM2Pixel(mm_dx, mm_dy, dx, dy) +#define wdPixel2MM(dx, dy, mm_dx, mm_dy) cdPixel2MM(dx, dy, mm_dx, mm_dy) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CD/libcd.a b/libs/CD/libcd.a new file mode 100644 index 0000000..18e4226 Binary files /dev/null and b/libs/CD/libcd.a differ diff --git a/libs/CD/libcdcairo.a b/libs/CD/libcdcairo.a new file mode 100644 index 0000000..d587b2b Binary files /dev/null and b/libs/CD/libcdcairo.a differ diff --git a/libs/CD/libcdcontextplus.a b/libs/CD/libcdcontextplus.a new file mode 100644 index 0000000..ff18917 Binary files /dev/null and b/libs/CD/libcdcontextplus.a differ diff --git a/libs/CD/libcddirect2d.a b/libs/CD/libcddirect2d.a new file mode 100644 index 0000000..3421755 Binary files /dev/null and b/libs/CD/libcddirect2d.a differ diff --git a/libs/CD/libcdgl.a b/libs/CD/libcdgl.a new file mode 100644 index 0000000..44a3303 Binary files /dev/null and b/libs/CD/libcdgl.a differ diff --git a/libs/CD/libcdim.a b/libs/CD/libcdim.a new file mode 100644 index 0000000..db880ed Binary files /dev/null and b/libs/CD/libcdim.a differ diff --git a/libs/CD/libcdpdf.a b/libs/CD/libcdpdf.a new file mode 100644 index 0000000..0eca1b8 Binary files /dev/null and b/libs/CD/libcdpdf.a differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/libfreetype6.a b/libs/CD/libfreetype6.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libfreetype6.a rename to libs/CD/libfreetype6.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libftgl.a b/libs/CD/libftgl.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libftgl.a rename to libs/CD/libftgl.a diff --git a/libs/CD/libpdflib.a b/libs/CD/libpdflib.a new file mode 100644 index 0000000..5fec9f4 Binary files /dev/null and b/libs/CD/libpdflib.a differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/libzlib1.a b/libs/CD/libzlib1.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libzlib1.a rename to libs/CD/libzlib1.a diff --git a/libs/CD/pdflib.dll b/libs/CD/pdflib.dll new file mode 100644 index 0000000..ed30949 Binary files /dev/null and b/libs/CD/pdflib.dll differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/zlib1.dll b/libs/CD/zlib1.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/zlib1.dll rename to libs/CD/zlib1.dll diff --git a/libs/IUP/freetype6.dll b/libs/IUP/freetype6.dll new file mode 100644 index 0000000..e8c3c21 Binary files /dev/null and b/libs/IUP/freetype6.dll differ diff --git a/libs/IUP/ftgl.dll b/libs/IUP/ftgl.dll new file mode 100644 index 0000000..97fc44d Binary files /dev/null and b/libs/IUP/ftgl.dll differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup.h b/libs/IUP/include/iup.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup.h rename to libs/IUP/include/iup.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_class_cbs.hpp b/libs/IUP/include/iup_class_cbs.hpp similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_class_cbs.hpp rename to libs/IUP/include/iup_class_cbs.hpp diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_config.h b/libs/IUP/include/iup_config.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_config.h rename to libs/IUP/include/iup_config.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_export.h b/libs/IUP/include/iup_export.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_export.h rename to libs/IUP/include/iup_export.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_mglplot.h b/libs/IUP/include/iup_mglplot.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_mglplot.h rename to libs/IUP/include/iup_mglplot.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_plot.h b/libs/IUP/include/iup_plot.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_plot.h rename to libs/IUP/include/iup_plot.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_plus.h b/libs/IUP/include/iup_plus.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_plus.h rename to libs/IUP/include/iup_plus.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_scintilla.h b/libs/IUP/include/iup_scintilla.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_scintilla.h rename to libs/IUP/include/iup_scintilla.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iup_varg.h b/libs/IUP/include/iup_varg.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iup_varg.h rename to libs/IUP/include/iup_varg.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupcbs.h b/libs/IUP/include/iupcbs.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupcbs.h rename to libs/IUP/include/iupcbs.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupcontrols.h b/libs/IUP/include/iupcontrols.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupcontrols.h rename to libs/IUP/include/iupcontrols.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupdef.h b/libs/IUP/include/iupdef.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupdef.h rename to libs/IUP/include/iupdef.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupdraw.h b/libs/IUP/include/iupdraw.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupdraw.h rename to libs/IUP/include/iupdraw.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupdraw_cd.h b/libs/IUP/include/iupdraw_cd.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupdraw_cd.h rename to libs/IUP/include/iupdraw_cd.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupfiledlg.h b/libs/IUP/include/iupfiledlg.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupfiledlg.h rename to libs/IUP/include/iupfiledlg.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupgl.h b/libs/IUP/include/iupgl.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupgl.h rename to libs/IUP/include/iupgl.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupglcontrols.h b/libs/IUP/include/iupglcontrols.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupglcontrols.h rename to libs/IUP/include/iupglcontrols.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupim.h b/libs/IUP/include/iupim.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupim.h rename to libs/IUP/include/iupim.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupkey.h b/libs/IUP/include/iupkey.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupkey.h rename to libs/IUP/include/iupkey.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iuplua.h b/libs/IUP/include/iuplua.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iuplua.h rename to libs/IUP/include/iuplua.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iuplua_mglplot.h b/libs/IUP/include/iuplua_mglplot.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iuplua_mglplot.h rename to libs/IUP/include/iuplua_mglplot.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iuplua_plot.h b/libs/IUP/include/iuplua_plot.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iuplua_plot.h rename to libs/IUP/include/iuplua_plot.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iuplua_scintilla.h b/libs/IUP/include/iuplua_scintilla.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iuplua_scintilla.h rename to libs/IUP/include/iuplua_scintilla.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluacontrols.h b/libs/IUP/include/iupluacontrols.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluacontrols.h rename to libs/IUP/include/iupluacontrols.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluafiledlg.h b/libs/IUP/include/iupluafiledlg.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluafiledlg.h rename to libs/IUP/include/iupluafiledlg.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluagl.h b/libs/IUP/include/iupluagl.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluagl.h rename to libs/IUP/include/iupluagl.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluaglcontrols.h b/libs/IUP/include/iupluaglcontrols.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluaglcontrols.h rename to libs/IUP/include/iupluaglcontrols.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluaim.h b/libs/IUP/include/iupluaim.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluaim.h rename to libs/IUP/include/iupluaim.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluaole.h b/libs/IUP/include/iupluaole.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluaole.h rename to libs/IUP/include/iupluaole.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluascripterdlg.h b/libs/IUP/include/iupluascripterdlg.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluascripterdlg.h rename to libs/IUP/include/iupluascripterdlg.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluatuio.h b/libs/IUP/include/iupluatuio.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluatuio.h rename to libs/IUP/include/iupluatuio.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupluaweb.h b/libs/IUP/include/iupluaweb.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupluaweb.h rename to libs/IUP/include/iupluaweb.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupole.h b/libs/IUP/include/iupole.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupole.h rename to libs/IUP/include/iupole.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iuptuio.h b/libs/IUP/include/iuptuio.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iuptuio.h rename to libs/IUP/include/iuptuio.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/include/iupweb.h b/libs/IUP/include/iupweb.h similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/include/iupweb.h rename to libs/IUP/include/iupweb.h diff --git a/libs/iup-3.31_Win64_dllw6_lib/iup.dll b/libs/IUP/iup.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iup.dll rename to libs/IUP/iup.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iup_mglplot.dll b/libs/IUP/iup_mglplot.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iup_mglplot.dll rename to libs/IUP/iup_mglplot.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iup_plot.dll b/libs/IUP/iup_plot.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iup_plot.dll rename to libs/IUP/iup_plot.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iup_scintilla.dll b/libs/IUP/iup_scintilla.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iup_scintilla.dll rename to libs/IUP/iup_scintilla.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupcd.dll b/libs/IUP/iupcd.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupcd.dll rename to libs/IUP/iupcd.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupcontrols.dll b/libs/IUP/iupcontrols.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupcontrols.dll rename to libs/IUP/iupcontrols.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupgl.dll b/libs/IUP/iupgl.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupgl.dll rename to libs/IUP/iupgl.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupglcontrols.dll b/libs/IUP/iupglcontrols.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupglcontrols.dll rename to libs/IUP/iupglcontrols.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupim.dll b/libs/IUP/iupim.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupim.dll rename to libs/IUP/iupim.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupimglib.dll b/libs/IUP/iupimglib.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupimglib.dll rename to libs/IUP/iupimglib.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iupole.dll b/libs/IUP/iupole.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iupole.dll rename to libs/IUP/iupole.dll diff --git a/libs/iup-3.31_Win64_dllw6_lib/iuptuio.dll b/libs/IUP/iuptuio.dll similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/iuptuio.dll rename to libs/IUP/iuptuio.dll diff --git a/libs/IUP/libfreetype6.a b/libs/IUP/libfreetype6.a new file mode 100644 index 0000000..1d193ad Binary files /dev/null and b/libs/IUP/libfreetype6.a differ diff --git a/libs/IUP/libftgl.a b/libs/IUP/libftgl.a new file mode 100644 index 0000000..85302b5 Binary files /dev/null and b/libs/IUP/libftgl.a differ diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiup.a b/libs/IUP/libiup.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiup.a rename to libs/IUP/libiup.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiup_mglplot.a b/libs/IUP/libiup_mglplot.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiup_mglplot.a rename to libs/IUP/libiup_mglplot.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiup_plot.a b/libs/IUP/libiup_plot.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiup_plot.a rename to libs/IUP/libiup_plot.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiup_scintilla.a b/libs/IUP/libiup_scintilla.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiup_scintilla.a rename to libs/IUP/libiup_scintilla.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupcd.a b/libs/IUP/libiupcd.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupcd.a rename to libs/IUP/libiupcd.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupcontrols.a b/libs/IUP/libiupcontrols.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupcontrols.a rename to libs/IUP/libiupcontrols.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupgl.a b/libs/IUP/libiupgl.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupgl.a rename to libs/IUP/libiupgl.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupglcontrols.a b/libs/IUP/libiupglcontrols.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupglcontrols.a rename to libs/IUP/libiupglcontrols.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupim.a b/libs/IUP/libiupim.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupim.a rename to libs/IUP/libiupim.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupimglib.a b/libs/IUP/libiupimglib.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupimglib.a rename to libs/IUP/libiupimglib.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiupole.a b/libs/IUP/libiupole.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiupole.a rename to libs/IUP/libiupole.a diff --git a/libs/iup-3.31_Win64_dllw6_lib/libiuptuio.a b/libs/IUP/libiuptuio.a similarity index 100% rename from libs/iup-3.31_Win64_dllw6_lib/libiuptuio.a rename to libs/IUP/libiuptuio.a diff --git a/libs/IUP/libzlib1.a b/libs/IUP/libzlib1.a new file mode 100644 index 0000000..72265f6 Binary files /dev/null and b/libs/IUP/libzlib1.a differ diff --git a/libs/IUP/zlib1.dll b/libs/IUP/zlib1.dll new file mode 100644 index 0000000..4f435eb Binary files /dev/null and b/libs/IUP/zlib1.dll differ diff --git a/src/cb_edit.c b/src/cb_edit.c index f90ac17..39d43e9 100644 --- a/src/cb_edit.c +++ b/src/cb_edit.c @@ -17,10 +17,10 @@ int btn_new_cb(Ihandle *self) record_history(); Ihandle *current_list = get_current_list(); - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); count++; - IupSetAttributeId(current_list, "", count, buffer); - IupSetInt(current_list, "COUNT", count); + IupSetInt(current_list, "NUMLIN", count); + IupSetAttributeId2(current_list, "", count, 1, buffer); // 更新选中状态 set_single_selection(current_list, count); @@ -47,7 +47,7 @@ int btn_edit_cb(Ihandle *self) if (selected == 0) return IUP_DEFAULT; - char *current_val = IupGetAttributeId(current_list, "", selected); + char *current_val = IupGetAttributeId2(current_list, "", selected, 1); char buffer[4096]; // 假设单个路径不超过4096 if (current_val) { @@ -67,7 +67,7 @@ int btn_edit_cb(Ihandle *self) record_history(); // 更新 UI - IupSetAttributeId(current_list, "", selected, buffer); + IupSetAttributeId2(current_list, "", selected, 1, buffer); // 更新 raw_data int pos = IupGetInt(tabs_main, "VALUEPOS"); @@ -89,32 +89,111 @@ int btn_edit_cb(Ihandle *self) return IUP_DEFAULT; } -// 双击回调 -int list_dblclick_cb(Ihandle *self, int item, char *text) +// 单击/双击回调 (用于 IupMatrix 的 CLICK_CB) +int list_dblclick_cb(Ihandle *self, int lin, int col, char *status) { - // 这里的 self 就是触发双击的列表控件 - if (item > 0) + if (lin > 0) { - // 选中该行 (单选) - set_single_selection(self, item); - // 调用编辑逻辑 - btn_edit_cb(NULL); + // 如果是双击 + if (strchr(status, 'D') || strchr(status, 'd')) + { + // 选中该行 (单选) + set_single_selection(self, lin); + + // 如果双击的不是第一列(路径),则调用弹窗编辑 + if (col != 1) { + btn_edit_cb(NULL); + } + // 如果是第一列,默认进入内联编辑,无需干预 + } + // 如果是右键点击 (status包含 '3') + else if (strchr(status, '3')) + { + // 选中该行 + set_single_selection(self, lin); + + // 创建右键菜单 + Ihandle *item_new = IupItem("新建", NULL); + IupSetAttribute(item_new, "IMAGE", "IUP_FileNew"); + IupSetCallback(item_new, "ACTION", (Icallback)btn_new_cb); + + Ihandle *item_edit = IupItem("编辑", NULL); + IupSetAttribute(item_edit, "IMAGE", "IUP_EditCopy"); + IupSetCallback(item_edit, "ACTION", (Icallback)btn_edit_cb); + + Ihandle *item_del = IupItem("删除", NULL); + IupSetAttribute(item_del, "IMAGE", "IUP_EditErase"); + IupSetCallback(item_del, "ACTION", (Icallback)btn_del_cb); + + Ihandle *item_up = IupItem("上移", NULL); + IupSetAttribute(item_up, "IMAGE", "IUP_ArrowUp"); + IupSetCallback(item_up, "ACTION", (Icallback)btn_up_cb); + + Ihandle *item_down = IupItem("下移", NULL); + IupSetAttribute(item_down, "IMAGE", "IUP_ArrowDown"); + IupSetCallback(item_down, "ACTION", (Icallback)btn_down_cb); + + Ihandle *menu = IupMenu( + item_new, + item_edit, + item_del, + IupSeparator(), + item_up, + item_down, + NULL + ); + + IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS); + IupDestroy(menu); + } } return IUP_DEFAULT; } +// 内联编辑回调 +int matrix_edition_cb(Ihandle *self, int lin, int col, int mode, int update) +{ + if (mode == 1) + { + // 进入编辑模式前,记录历史 + record_history(); + } + else if (mode == 0 && update == 1) + { + // 结束编辑并更新了值 + // 同步到 raw_data + int pos = IupGetInt(tabs_main, "VALUEPOS"); + StringList *raw_data = (pos == 0) ? &raw_sys_paths : &raw_user_paths; + + char *filter = IupGetAttribute(txt_search, "VALUE"); + if (!filter || strlen(filter) == 0) { + if (raw_data && lin > 0 && lin <= raw_data->count) { + char *new_val = IupGetAttributeId2(self, "", lin, 1); + if (new_val) { + free(raw_data->items[lin-1]); + raw_data->items[lin-1] = _strdup(new_val); + } + } + } + + refresh_single_list_style(self); + } + return IUP_DEFAULT; +} + + // 按钮回调:删除 (支持多选) int btn_del_cb(Ihandle *self) { Ihandle *current_list = get_current_list(); - char *value = IupGetAttribute(current_list, "VALUE"); + char *value = IupGetAttribute(current_list, "MARKED"); if (!value) return IUP_DEFAULT; int len = strlen(value); int has_selection = 0; for (int i = 0; i < len; i++) { - if (value[i] == '+') { + if (value[i] == '1') { has_selection = 1; break; } @@ -136,10 +215,10 @@ int btn_del_cb(Ihandle *self) // 从后往前遍历删除,避免索引错位 for (int i = len - 1; i >= 0; i--) { - if (value[i] == '+') + if (value[i] == '1') { int item_index = i + 1; // IUP 索引从 1 开始 - char *val = IupGetAttributeId(current_list, "", item_index); + char *val = IupGetAttributeId2(current_list, "", item_index, 1); // 从缓存删除 if (val && raw_data) @@ -150,7 +229,7 @@ int btn_del_cb(Ihandle *self) } // 从界面删除 - IupSetInt(current_list, "REMOVEITEM", item_index); + IupSetInt(current_list, "DELLIN", item_index); } } @@ -167,7 +246,7 @@ int btn_del_cb(Ihandle *self) int btn_up_cb(Ihandle *self) { Ihandle *current_list = get_current_list(); - char *value = IupGetAttribute(current_list, "VALUE"); + char *value = IupGetAttribute(current_list, "MARKED"); if (!value) return IUP_DEFAULT; @@ -177,7 +256,7 @@ int btn_up_cb(Ihandle *self) // 预检查是否有移动 for (int i = 1; i < len; i++) { - if (new_value[i] == '+' && new_value[i - 1] == '-') { + if (new_value[i] == '1' && new_value[i - 1] == '0') { moved = 1; break; } @@ -194,18 +273,18 @@ int btn_up_cb(Ihandle *self) // 从前往后遍历,如果当前项被选中且前一项未选中,则交换 for (int i = 1; i < len; i++) { - if (new_value[i] == '+' && new_value[i - 1] == '-') + if (new_value[i] == '1' && new_value[i - 1] == '0') { // 交换列表项内容 - char *curr_text = IupGetAttributeId(current_list, "", i + 1); - char *prev_text = IupGetAttributeId(current_list, "", i); + char *curr_text = IupGetAttributeId2(current_list, "", i + 1, 1); + char *prev_text = IupGetAttributeId2(current_list, "", i, 1); // 需要复制,防止指针失效 char *curr_copy = curr_text ? _strdup(curr_text) : NULL; char *prev_copy = prev_text ? _strdup(prev_text) : NULL; - IupSetAttributeId(current_list, "", i, curr_copy); - IupSetAttributeId(current_list, "", i + 1, prev_copy); + IupSetAttributeId2(current_list, "", i, 1, curr_copy); + IupSetAttributeId2(current_list, "", i + 1, 1, prev_copy); if (curr_copy) free(curr_copy); if (prev_copy) free(prev_copy); @@ -218,13 +297,13 @@ int btn_up_cb(Ihandle *self) } // 交换选中状态 - new_value[i] = '-'; - new_value[i - 1] = '+'; + new_value[i] = '0'; + new_value[i - 1] = '1'; } } // 更新选中状态 - IupSetAttribute(current_list, "VALUE", new_value); + IupSetAttribute(current_list, "MARKED", new_value); refresh_single_list_style(current_list); } free(new_value); @@ -235,7 +314,7 @@ int btn_up_cb(Ihandle *self) int btn_down_cb(Ihandle *self) { Ihandle *current_list = get_current_list(); - char *value = IupGetAttribute(current_list, "VALUE"); + char *value = IupGetAttribute(current_list, "MARKED"); if (!value) return IUP_DEFAULT; @@ -245,7 +324,7 @@ int btn_down_cb(Ihandle *self) // 预检查 for (int i = len - 2; i >= 0; i--) { - if (new_value[i] == '+' && new_value[i + 1] == '-') { + if (new_value[i] == '1' && new_value[i + 1] == '0') { moved = 1; break; } @@ -262,18 +341,18 @@ int btn_down_cb(Ihandle *self) // 从后往前遍历,如果当前项被选中且后一项未选中,则交换 for (int i = len - 2; i >= 0; i--) { - if (new_value[i] == '+' && new_value[i + 1] == '-') + if (new_value[i] == '1' && new_value[i + 1] == '0') { // 交换列表项内容 - char *curr_text = IupGetAttributeId(current_list, "", i + 1); - char *next_text = IupGetAttributeId(current_list, "", i + 2); + char *curr_text = IupGetAttributeId2(current_list, "", i + 1, 1); + char *next_text = IupGetAttributeId2(current_list, "", i + 2, 1); // 需要复制 char *curr_copy = curr_text ? _strdup(curr_text) : NULL; char *next_copy = next_text ? _strdup(next_text) : NULL; - IupSetAttributeId(current_list, "", i + 2, curr_copy); - IupSetAttributeId(current_list, "", i + 1, next_copy); + IupSetAttributeId2(current_list, "", i + 2, 1, curr_copy); + IupSetAttributeId2(current_list, "", i + 1, 1, next_copy); if (curr_copy) free(curr_copy); if (next_copy) free(next_copy); @@ -286,13 +365,13 @@ int btn_down_cb(Ihandle *self) } // 交换选中状态 - new_value[i] = '-'; - new_value[i + 1] = '+'; + new_value[i] = '0'; + new_value[i + 1] = '1'; } } // 更新选中状态 - IupSetAttribute(current_list, "VALUE", new_value); + IupSetAttribute(current_list, "MARKED", new_value); refresh_single_list_style(current_list); } free(new_value); @@ -303,7 +382,7 @@ int btn_down_cb(Ihandle *self) int btn_clean_cb(Ihandle *self) { Ihandle *current_list = get_current_list(); - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); if (count == 0) return IUP_DEFAULT; @@ -323,7 +402,7 @@ int btn_clean_cb(Ihandle *self) // 从后往前遍历删除,避免索引错位 for (int i = count; i >= 1; i--) { - char *item = IupGetAttributeId(current_list, "", i); + char *item = IupGetAttributeId2(current_list, "", i, 1); if (!item) continue; @@ -340,7 +419,7 @@ int btn_clean_cb(Ihandle *self) // 注意:这里需要再次遍历,性能稍低但最稳妥 for (int j = 1; j < i; j++) { - char *prev_item = IupGetAttributeId(current_list, "", j); + char *prev_item = IupGetAttributeId2(current_list, "", j, 1); if (prev_item && _stricmp(item, prev_item) == 0) { should_remove = 1; @@ -358,7 +437,7 @@ int btn_clean_cb(Ihandle *self) free(val_copy); } - IupSetAttributeId(current_list, "REMOVEITEM", i, NULL); + IupSetInt(current_list, "DELLIN", i); } } diff --git a/src/cb_file.c b/src/cb_file.c index edc741c..7c39cce 100644 --- a/src/cb_file.c +++ b/src/cb_file.c @@ -25,10 +25,10 @@ int btn_browse_cb(Ihandle *self) record_history(); Ihandle *current_list = get_current_list(); - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); count++; - IupSetAttributeId(current_list, "", count, value); - IupSetInt(current_list, "COUNT", count); + IupSetInt(current_list, "NUMLIN", count); + IupSetAttributeId2(current_list, "", count, 1, value); // 更新选中状态 set_single_selection(current_list, count); @@ -101,7 +101,7 @@ int btn_redo_cb(Ihandle *self) int btn_export_cb(Ihandle *self) { Ihandle *current_list = get_current_list(); - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); if (count == 0) { IupMessage("提示", "当前列表为空,无法导出"); return IUP_DEFAULT; @@ -133,7 +133,7 @@ int btn_export_cb(Ihandle *self) FILE *fp = fopen(final_path, "w"); if (fp) { for (int i = 1; i <= count; i++) { - char *item = IupGetAttributeId(current_list, "", i); + char *item = IupGetAttributeId2(current_list, "", i, 1); if (item) fprintf(fp, "%s\n", item); } fclose(fp); @@ -181,10 +181,10 @@ int btn_import_cb(Ihandle *self) } if (len > 0) { // Add to UI - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); count++; - IupSetAttributeId(current_list, "", count, line); - IupSetInt(current_list, "COUNT", count); + IupSetInt(current_list, "NUMLIN", count); + IupSetAttributeId2(current_list, "", count, 1, line); // Add to raw_data if (raw_data) add_string_list(raw_data, line); @@ -234,10 +234,10 @@ int list_dropfiles_cb(Ihandle *self, const char *filename, int num, int x, int y IupSetAttribute(txt_search, "VALUE", ""); // 添加到列表末尾 - int count = IupGetInt(current_list, "COUNT"); + int count = IupGetInt(current_list, "NUMLIN"); count++; - IupSetAttributeId(current_list, "", count, filename); - IupSetInt(current_list, "COUNT", count); + IupSetInt(current_list, "NUMLIN", count); + IupSetAttributeId2(current_list, "", count, 1, filename); // 更新选中状态 set_single_selection(current_list, count); diff --git a/src/cb_main.c b/src/cb_main.c index 69d778e..f79fb95 100644 --- a/src/cb_main.c +++ b/src/cb_main.c @@ -22,7 +22,7 @@ int txt_search_cb(Ihandle *self) StringList *raw_data = (pos == 0) ? &raw_sys_paths : &raw_user_paths; // 清空列表 - IupSetAttribute(current_list, "REMOVEITEM", "ALL"); + IupSetInt(current_list, "NUMLIN", 0); // 重新填充 int count = 0; @@ -32,11 +32,11 @@ int txt_search_cb(Ihandle *self) if (strlen(filter) == 0 || stristr(raw_data->items[i], filter) != NULL) { count++; - IupSetAttributeId(current_list, "", count, raw_data->items[i]); + IupSetInt(current_list, "NUMLIN", count); + IupSetAttributeId2(current_list, "", count, 1, raw_data->items[i]); } } - IupSetInt(current_list, "COUNT", count); refresh_single_list_style(current_list); return IUP_DEFAULT; @@ -54,13 +54,12 @@ int list_k_any_cb(Ihandle *self, int c) return IUP_DEFAULT; } -// 鼠标移动回调 -int list_motion_cb(Ihandle *self, int x, int y, char *status) +// 鼠标移动回调 (用于 IupMatrix 的 MOUSEMOVE_CB) +int list_motion_cb(Ihandle *self, int lin, int col) { - int pos = IupConvertXYToPos(self, x, y); - if (pos > 0) + if (lin > 0) { - char *item = IupGetAttributeId(self, "", pos); + char *item = IupGetAttributeId2(self, "", lin, 1); if (item) { char *expanded = expand_env_vars(item); @@ -162,24 +161,25 @@ int tabs_tabchange_cb(Ihandle *self, int new_pos, int old_pos) if (new_pos == 2) { // 合并预览模式 - IupSetAttribute(list_merged, "REMOVEITEM", "ALL"); + IupSetInt(list_merged, "NUMLIN", 0); int count = 0; // 添加系统变量 for (int i = 0; i < raw_sys_paths.count; i++) { count++; - IupSetAttributeId(list_merged, "", count, raw_sys_paths.items[i]); + IupSetInt(list_merged, "NUMLIN", count); + IupSetAttributeId2(list_merged, "", count, 1, raw_sys_paths.items[i]); } // 添加用户变量 for (int i = 0; i < raw_user_paths.count; i++) { count++; - IupSetAttributeId(list_merged, "", count, raw_user_paths.items[i]); + IupSetInt(list_merged, "NUMLIN", count); + IupSetAttributeId2(list_merged, "", count, 1, raw_user_paths.items[i]); } - IupSetInt(list_merged, "COUNT", count); refresh_single_list_style(list_merged); // 禁用编辑按钮 diff --git a/src/main.c b/src/main.c index bbb2535..6c7b57f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "globals.h" @@ -25,6 +26,10 @@ int main(int argc, char **argv) return 1; } + // 初始化扩展库 + IupImageLibOpen(); + IupControlsOpen(); + // 开启 UTF-8 支持 IupSetGlobal("UTF8MODE", "YES"); diff --git a/src/ui.c b/src/ui.c index c00b885..34dea14 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,4 +1,5 @@ #include "ui.h" +#include #include "config.h" #include "globals.h" #include "ui_utils.h" @@ -10,18 +11,26 @@ // 创建列表控件 Ihandle *create_path_list() { - Ihandle *list = IupFlatList(); + Ihandle *list = IupMatrix(NULL); + IupSetAttribute(list, "NUMCOL", "2"); + IupSetAttribute(list, "NUMLIN", "0"); + IupSetAttribute(list, "MARKMODE", "LIN"); + IupSetAttribute(list, "MARKMULTIPLE", "YES"); + IupSetAttribute(list, "READONLY", "NO"); + IupSetAttribute(list, "0:1", "路径"); + IupSetAttribute(list, "0:2", "状态"); + IupSetAttribute(list, "ALIGNMENT1", "ALEFT"); + IupSetAttribute(list, "ALIGNMENT2", "ACENTER"); IupSetAttribute(list, "EXPAND", "YES"); - IupSetAttribute(list, "MULTIPLE", "YES"); IupSetAttribute(list, "ITEMPADDING", UI_LIST_ITEM_PADDING); IupSetAttribute(list, "BACKCOLOR", UI_LIST_BGCOLOR); IupSetAttribute(list, "BORDER", "YES"); IupSetAttribute(list, "CANFOCUS", "YES"); - IupSetAttribute(list, "HLINE", "NO"); - IupSetCallback(list, "DBLCLICK_CB", (Icallback)list_dblclick_cb); + IupSetCallback(list, "CLICK_CB", (Icallback)list_dblclick_cb); + IupSetCallback(list, "EDITION_CB", (Icallback)matrix_edition_cb); IupSetCallback(list, "DROPFILES_CB", (Icallback)list_dropfiles_cb); IupSetCallback(list, "K_ANY", (Icallback)list_k_any_cb); - IupSetCallback(list, "MOTION_CB", (Icallback)list_motion_cb); + IupSetCallback(list, "MOUSEMOVE_CB", (Icallback)list_motion_cb); return list; } @@ -30,14 +39,32 @@ Ihandle *create_main_buttons() { // 创建右侧按钮 btn_new = IupButton("新建(N)", NULL); + IupSetAttribute(btn_new, "IMAGE", "IUP_FileNew"); + IupSetAttribute(btn_new, "TITLE", "新建(N)"); btn_edit = IupButton("编辑(E)", NULL); + IupSetAttribute(btn_edit, "IMAGE", "IUP_EditCopy"); + IupSetAttribute(btn_edit, "TITLE", "编辑(E)"); btn_browse = IupButton("浏览(B)...", NULL); + IupSetAttribute(btn_browse, "IMAGE", "IUP_FileOpen"); + IupSetAttribute(btn_browse, "TITLE", "浏览(B)..."); btn_del = IupButton("删除(D)", NULL); + IupSetAttribute(btn_del, "IMAGE", "IUP_EditErase"); + IupSetAttribute(btn_del, "TITLE", "删除(D)"); btn_undo = IupButton("撤销(Z)", NULL); + IupSetAttribute(btn_undo, "IMAGE", "IUP_EditUndo"); + IupSetAttribute(btn_undo, "TITLE", "撤销(Z)"); btn_redo = IupButton("重做(Y)", NULL); + IupSetAttribute(btn_redo, "IMAGE", "IUP_EditRedo"); + IupSetAttribute(btn_redo, "TITLE", "重做(Y)"); btn_up = IupButton("上移(U)", NULL); + IupSetAttribute(btn_up, "IMAGE", "IUP_ArrowUp"); + IupSetAttribute(btn_up, "TITLE", "上移(U)"); btn_down = IupButton("下移(O)", NULL); + IupSetAttribute(btn_down, "IMAGE", "IUP_ArrowDown"); + IupSetAttribute(btn_down, "TITLE", "下移(O)"); btn_clean = IupButton("一键清理", NULL); + IupSetAttribute(btn_clean, "IMAGE", "IUP_ToolsSettings"); + IupSetAttribute(btn_clean, "TITLE", "一键清理"); // 设置按钮回调 IupSetCallback(btn_new, "ACTION", (Icallback)btn_new_cb); @@ -81,10 +108,14 @@ Ihandle *create_bottom_buttons() { // 创建底部按钮 btn_help = IupButton("帮助(H)", NULL); + IupSetAttribute(btn_help, "IMAGE", "IUP_MessageInfo"); + IupSetAttribute(btn_help, "TITLE", "帮助(H)"); // Force title IupSetCallback(btn_help, "ACTION", (Icallback)btn_help_cb); IupSetAttribute(btn_help, "RASTERSIZE", UI_BUTTON_SMALL_SIZE); btn_theme = IupButton("深色模式", NULL); + IupSetAttribute(btn_theme, "IMAGE", "IUP_WebFormat"); // Fixed icon + IupSetAttribute(btn_theme, "TITLE", "深色模式"); // Force title IupSetCallback(btn_theme, "ACTION", (Icallback)btn_theme_cb); IupSetAttribute(btn_theme, "RASTERSIZE", UI_BUTTON_SMALL_SIZE); @@ -92,18 +123,26 @@ Ihandle *create_bottom_buttons() IupSetAttribute(lbl_status, "EXPAND", "HORIZONTAL"); btn_import = IupButton("导入配置", NULL); + IupSetAttribute(btn_import, "IMAGE", "IUP_FileOpen"); + IupSetAttribute(btn_import, "TITLE", "导入配置"); // Force title IupSetCallback(btn_import, "ACTION", (Icallback)btn_import_cb); IupSetAttribute(btn_import, "RASTERSIZE", UI_BUTTON_SIZE); btn_export = IupButton("导出配置", NULL); + IupSetAttribute(btn_export, "IMAGE", "IUP_FileSave"); // Fixed icon + IupSetAttribute(btn_export, "TITLE", "导出配置"); // Force title IupSetCallback(btn_export, "ACTION", (Icallback)btn_export_cb); IupSetAttribute(btn_export, "RASTERSIZE", UI_BUTTON_SIZE); btn_ok = IupButton("确定(O)", NULL); + IupSetAttribute(btn_ok, "IMAGE", "IUP_FileSave"); + IupSetAttribute(btn_ok, "TITLE", "确定(O)"); // Force title IupSetCallback(btn_ok, "ACTION", (Icallback)btn_ok_cb); IupSetAttribute(btn_ok, "RASTERSIZE", UI_BUTTON_SIZE); btn_cancel = IupButton("取消(C)", NULL); + IupSetAttribute(btn_cancel, "IMAGE", "IUP_MessageError"); + IupSetAttribute(btn_cancel, "TITLE", "取消(C)"); // Force title IupSetCallback(btn_cancel, "ACTION", (Icallback)btn_cancel_cb); IupSetAttribute(btn_cancel, "RASTERSIZE", UI_BUTTON_SIZE); @@ -133,7 +172,7 @@ Ihandle *create_main_dialog() list_merged = create_path_list(); IupSetAttribute(list_merged, "READONLY", "YES"); - IupSetAttribute(list_merged, "MULTIPLE", "NO"); + IupSetAttribute(list_merged, "MARKMULTIPLE", "NO"); IupSetAttribute(list_merged, "BGCOLOR", UI_LIST_MERGED_BGCOLOR); // 灰色背景 // 创建标签页 diff --git a/src/ui_utils.c b/src/ui_utils.c index c76425c..9320f12 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -8,13 +8,13 @@ // 获取第一个选中的索引(1-based),如果没有选中则返回 0 int get_first_selected_index(Ihandle *list) { - char *value = IupGetAttribute(list, "VALUE"); + char *value = IupGetAttribute(list, "MARKED"); if (!value) return 0; int len = strlen(value); for (int i = 0; i < len; i++) { - if (value[i] == '+') + if (value[i] == '1') return i + 1; } return 0; @@ -23,7 +23,7 @@ int get_first_selected_index(Ihandle *list) // 设置单选(1-based) void set_single_selection(Ihandle *list, int index) { - int count = IupGetInt(list, "COUNT"); + int count = IupGetInt(list, "NUMLIN"); if (count <= 0) return; @@ -33,28 +33,29 @@ void set_single_selection(Ihandle *list, int index) for (int i = 0; i < count; i++) { - new_val[i] = '-'; + new_val[i] = '0'; } new_val[count] = '\0'; if (index >= 1 && index <= count) { - new_val[index - 1] = '+'; + new_val[index - 1] = '1'; } - IupSetAttribute(list, "VALUE", new_val); + IupSetAttribute(list, "MARKED", new_val); free(new_val); } // 从原始数据刷新UI void refresh_ui_from_raw(Ihandle *list, StringList *raw) { - IupSetAttribute(list, "REMOVEITEM", "ALL"); + IupSetInt(list, "NUMLIN", 0); + IupSetInt(list, "NUMLIN", raw->count); for (int i = 0; i < raw->count; i++) { - IupSetAttributeId(list, "", i + 1, raw->items[i]); + IupSetAttributeId2(list, "", i + 1, 1, raw->items[i]); } - IupSetInt(list, "COUNT", raw->count); + IupSetAttribute(list, "REDRAW", "ALL"); // Force matrix redraw refresh_single_list_style(list); } diff --git a/src/utils.c b/src/utils.c index ffd78f0..efad2b1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -43,27 +43,30 @@ int check_admin() } // 展开环境变量 -char* expand_env_vars(const char* path) +char *expand_env_vars(const char *path) { - if (!path) return NULL; - + if (!path) + return NULL; + // 先转换为宽字符,因为ExpandEnvironmentStringsW不支持UTF-8 wchar_t *wpath = utf8_to_wide(path); - if (!wpath) return NULL; - + if (!wpath) + return NULL; + DWORD size = ExpandEnvironmentStringsW(wpath, NULL, 0); - if (size == 0) { + if (size == 0) + { free(wpath); return NULL; } - + wchar_t *wexpanded = (wchar_t *)malloc(size * sizeof(wchar_t)); ExpandEnvironmentStringsW(wpath, wexpanded, size); free(wpath); - + char *expanded = wide_to_utf8(wexpanded); free(wexpanded); - + return expanded; } @@ -76,7 +79,7 @@ static int path_exists(const char *path) wchar_t *wpath = utf8_to_wide(expanded_path); free(expanded_path); - + if (!wpath) return 0; @@ -99,61 +102,75 @@ void refresh_single_list_style(Ihandle *list) { if (!list) return; - int count = IupGetInt(list, "COUNT"); - - // 用于查重的简单数组(实际项目可以用哈希表) - // 为了简单,我们只用双重循环检查重复,性能在几百个条目下没问题 + int count = IupGetInt(list, "NUMLIN"); for (int i = 1; i <= count; i++) { - char *item = IupGetAttributeId(list, "", i); + char *item = IupGetAttributeId2(list, "", i, 1); if (!item) continue; - // 默认颜色:黑字 - char fg_color[32]; - if (is_dark_mode) - strcpy(fg_color, "255 255 255"); - else - strcpy(fg_color, "0 0 0"); + const char *status_str = "正常"; + char bg_color[32] = ""; // 1. 检查有效性 if (!path_exists(item)) { - // 无效路径:红色 - sprintf(fg_color, "255 0 0"); - } - - // 2. 检查重复 (只检查当前项之前的项,如果之前出现过,当前项标橙) - for (int j = 1; j < i; j++) - { - char *prev_item = IupGetAttributeId(list, "", j); - if (prev_item && _stricmp(item, prev_item) == 0) // Windows 路径不区分大小写 - { - // 重复路径:橙色 - sprintf(fg_color, "255 128 0"); - break; - } - } - - IupSetAttributeId(list, "ITEMFGCOLOR", i, fg_color); - - // 斑马纹背景 - if (is_dark_mode) - { - if (i % 2 == 0) - IupSetAttributeId(list, "ITEMBGCOLOR", i, "60 60 60"); - else - IupSetAttributeId(list, "ITEMBGCOLOR", i, "50 50 50"); + // 无效路径:红色背景 + strcpy(bg_color, "255 100 100"); // 柔和的红色 + status_str = "无效"; } else { - if (i % 2 == 0) - IupSetAttributeId(list, "ITEMBGCOLOR", i, "245 245 245"); - else - IupSetAttributeId(list, "ITEMBGCOLOR", i, "255 255 255"); + // 2. 检查重复 (只检查当前项之前的项,如果之前出现过,当前项标橙) + for (int j = 1; j < i; j++) + { + char *prev_item = IupGetAttributeId2(list, "", j, 1); + if (prev_item && _stricmp(item, prev_item) == 0) // Windows 路径不区分大小写 + { + // 重复路径:橙色背景 + strcpy(bg_color, "255 165 0"); + status_str = "重复"; + break; + } + } } + + IupSetAttributeId2(list, "", i, 2, status_str); + + // 如果没有特殊状态,使用斑马纹背景 + if (strlen(bg_color) == 0) + { + if (is_dark_mode) + { + if (i % 2 == 0) + strcpy(bg_color, "60 60 60"); + else + strcpy(bg_color, "50 50 50"); + } + else + { + if (i % 2 == 0) + strcpy(bg_color, "245 245 245"); + else + strcpy(bg_color, "255 255 255"); + } + } + + char attr_bg[32]; + sprintf(attr_bg, "BGCOLOR%d:*", i); + IupSetAttribute(list, attr_bg, bg_color); + + // 恢复前景色 + char attr_fg[32]; + sprintf(attr_fg, "FGCOLOR%d:*", i); + if (is_dark_mode) + IupSetAttribute(list, attr_fg, "255 255 255"); + else + IupSetAttribute(list, attr_fg, "0 0 0"); } + + IupSetAttribute(list, "REDRAW", "ALL"); // Ensure Matrix repaints colors } // 刷新所有列表样式