migrate MwLLColor and MwLLPixmap
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-09-27 05:49:10 +09:00
commit 6e6233edc8
55 changed files with 754 additions and 669 deletions

View file

@ -5,12 +5,12 @@
#ifndef __MW_BASETYPES_H__
#define __MW_BASETYPES_H__
typedef struct _MwPoint MwPoint;
typedef struct _MwRect MwRect;
typedef struct _MwSizeHints MwSizeHints;
typedef struct _MwFont MwFont;
typedef struct _MwCursor MwCursor;
typedef struct _MwRGB MwRGB;
typedef struct _MwPoint MwPoint;
typedef struct _MwRect MwRect;
typedef struct _MwSizeHints MwSizeHints;
typedef struct _MwFontResource MwFontResource;
typedef struct _MwCursor MwCursor;
typedef struct _MwRGB MwRGB;
typedef unsigned char MwBool;
#define MwTRUE ((MwBool)1)
@ -98,7 +98,7 @@ struct _MwCursor {
unsigned int data[MwCursorDataHeight];
};
struct _MwFont {
struct _MwFontResource {
int left;
int top;
unsigned char data[16];

View file

@ -26,7 +26,7 @@ MWDECL int MWAPI MwGetColorDifference(MwWidget handle);
* @param text Color text
* @return Color
*/
MWDECL MwLLColor MWAPI MwParseColor(MwWidget handle, const char* text);
MWDECL MwColor MWAPI MwParseColor(MwWidget handle, const char* text);
/*!
* @brief Parses a color text
@ -50,7 +50,7 @@ MWDECL void MWAPI MwColorTableInit(void);
* @param b Blue
* @return Color
*/
MWDECL MwLLColor MWAPI MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b);
MWDECL MwColor MWAPI MwLightenColor(MwWidget handle, MwColor color, int r, int g, int b);
/*!
* @brief Fix a rectangle
@ -65,7 +65,7 @@ MWDECL void MWAPI MwFixRect(MwRect* rect);
* @param rect Rectangle area
* @param color Color
*/
MWDECL void MWAPI MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
MWDECL void MWAPI MwDrawRect(MwWidget handle, MwRect* rect, MwColor color);
/*!
* @brief Draws a rectangle
@ -73,7 +73,7 @@ MWDECL void MWAPI MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
* @param rect Rectangle area
* @param color Color
*/
MWDECL void MWAPI MwDrawRectLine(MwWidget handle, MwRect* rect, MwLLColor color);
MWDECL void MWAPI MwDrawRectLine(MwWidget handle, MwRect* rect, MwColor color);
/*!
* @brief Draws a filled rectangle that fades to a darker color
@ -81,7 +81,7 @@ MWDECL void MWAPI MwDrawRectLine(MwWidget handle, MwRect* rect, MwLLColor color)
* @param rect Rectangle area
* @param color Color
*/
MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color);
MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwColor color);
/*!
* @brief Draws a frame
@ -91,7 +91,7 @@ MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor colo
* @param invert Invert the 3D border color or not
* @warning `rect` gets changed to the area of rectangle inside
*/
MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwColor color, int invert);
/*!
* @brief Draws a frame
@ -102,7 +102,7 @@ MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, in
* @param border Border
* @warning `rect` gets changed to the area of rectangle inside
*/
MWDECL void MWAPI MwDrawFrameWithBorder(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
MWDECL void MWAPI MwDrawFrameWithBorder(MwWidget handle, MwRect* rect, MwColor color, int invert, int border);
/*!
* @brief Does the DrawFrame/DrawRect combo used for drawing widget.
@ -112,7 +112,7 @@ MWDECL void MWAPI MwDrawFrameWithBorder(MwWidget handle, MwRect* rect, MwLLColor
* @param invert Invert the 3D border color or not
* @warning `rect` gets changed to the area of rectangle inside
*/
MWDECL void MWAPI MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
MWDECL void MWAPI MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwColor color, int invert, int border);
/*!
* @brief Draws a triangle
@ -121,7 +121,7 @@ MWDECL void MWAPI MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor colo
* @param color Color
* @param invert Invert the 3D border color or not
*/
MWDECL void MWAPI MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction);
MWDECL void MWAPI MwDrawTriangle(MwWidget handle, MwRect* rect, MwColor color, int invert, int direction);
/*!
* @brief Draws a frame with specified border width
@ -134,7 +134,7 @@ MWDECL void MWAPI MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color,
* @param same Same as dark color
* @warning `rect` gets changed to the area of rectangle inside
*/
MWDECL void MWAPI MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
MWDECL void MWAPI MwDrawFrameEx(MwWidget handle, MwRect* rect, MwColor color, int invert, int border, int diff, int same);
/*!
* @brief Creates a pixmap from image
@ -142,16 +142,7 @@ MWDECL void MWAPI MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color,
* @param path Path
* @return Pixmap
*/
MWDECL MwLLPixmap MWAPI MwLoadImage(MwWidget handle, const char* path);
/*!
* @brief Get color components
* @param color Color
* @param red Pointer to red color
* @param green Pointer to green color
* @param blue Pointer to blue color
*/
MWDECL void MWAPI MwColorGet(MwLLColor color, int* red, int* green, int* blue);
MWDECL MwPixmap MWAPI MwLoadImage(MwWidget handle, const char* path);
/*!
* @brief Creates a pixmap from raw data
@ -161,34 +152,82 @@ MWDECL void MWAPI MwColorGet(MwLLColor color, int* red, int* green, int* blue);
* @param height Height
* @return Pixmap
*/
MWDECL MwLLPixmap MWAPI MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
MWDECL MwPixmap MWAPI MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
/*!
* @brief Updates a pixmap using raw data
* @param pixmap Pixmap to update
* @param rgb RGBA data
*/
MWDECL void MWAPI MwPixmapReloadRaw(MwLLPixmap pixmap, unsigned char* rgb);
MWDECL void MWAPI MwPixmapReloadRaw(MwPixmap pixmap, unsigned char* rgb);
/*!
* @brief Gets the raw data of pixmap
* @param pixmap Pixmap
* @return RGBA data
*/
MWDECL unsigned char* MWAPI MwPixmapGetRaw(MwLLPixmap pixmap);
MWDECL unsigned char* MWAPI MwPixmapGetRaw(MwPixmap pixmap);
/*!
* @brief Gets the size of pixmap
* @param pixmap Pixmap
* @param rect Size
*/
MWDECL void MWAPI MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect);
MWDECL void MWAPI MwPixmapGetSize(MwPixmap pixmap, MwRect* rect);
/*!
* @brief Updates the pixmap
* @param pixmap Pixmap
*/
MWDECL void MWAPI MwPixmapUpdate(MwPixmap pixmap);
/*!
* @brief Destroys the pixmap
* @param pixmap Pixmap
*/
MWDECL void MWAPI MwDestroyPixmap(MwLLPixmap pixmap);
MWDECL void MWAPI MwDestroyPixmap(MwPixmap pixmap);
/*!
* @brief Draws the pixmap
* @param handle Handle
* @param rect Size
* @param pixmap Pixmap
*/
MWDECL void MWAPI MwDrawPixmap(MwWidget handle, MwRect* rect, MwPixmap pixmap);
/*!
* @brief Allocates a color
* @param handle Widget
* @param red Red
* @param green Green
* @param bilue Blue
* @return Color
*/
MWDECL MwColor MWAPI MwAllocColor(MwWidget handle, unsigned int red, unsigned int green, unsigned int blue);
/*!
* @brief Get color components
* @param color Color
* @param red Pointer to red color
* @param green Pointer to green color
* @param blue Pointer to blue color
*/
MWDECL void MWAPI MwColorGet(MwColor color, int* red, int* green, int* blue);
/*!
* @brief Update color
* @param color Color
* @param red Pointer to red color
* @param green Pointer to green color
* @param blue Pointer to blue color
*/
MWDECL void MWAPI MwColorUpdate(MwColor c, int r, int g, int b);
/*!
* @brief Allocates a color
* @param color Color
*/
MWDECL void MWAPI MwFreeColor(MwColor color);
/*!
* @brief Creates a pixmap from XPM data
@ -196,7 +235,7 @@ MWDECL void MWAPI MwDestroyPixmap(MwLLPixmap pixmap);
* @param data Data
* @return Pixmap
*/
MWDECL MwLLPixmap MWAPI MwLoadXPM(MwWidget handle, char** data);
MWDECL MwPixmap MWAPI MwLoadXPM(MwWidget handle, char** data);
/*!
* @brief Creates a pixmap from icon data
@ -204,7 +243,7 @@ MWDECL MwLLPixmap MWAPI MwLoadXPM(MwWidget handle, char** data);
* @param data Data
* @return Pixmap
*/
MWDECL MwLLPixmap MWAPI MwLoadIcon(MwWidget handle, MwU32* data);
MWDECL MwPixmap MWAPI MwLoadIcon(MwWidget handle, MwU32* data);
/*!
* @brief Draws a diamond
@ -213,7 +252,7 @@ MWDECL MwLLPixmap MWAPI MwLoadIcon(MwWidget handle, MwU32* data);
* @param color Color
* @param invert Invert the 3D border color or not
*/
MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwColor color, int invert);
/*!
* @brief Draws a circle
@ -224,7 +263,7 @@ MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color,
* @param filled Fill the circle or not
* @param outward
*/
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwLLColor color, MwLLColor background, int filled);
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwColor color, MwColor background, int filled);
/*!
* @brief Calculate intersect of 2 rectangles
@ -244,7 +283,7 @@ MWDECL void MwIntersectRect(MwRect* a, const MwRect* b);
* @param align Align
* @param color Color
*/
MWDECL void MWAPI MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
MWDECL void MWAPI MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwColor color);
/*!
* @brief Calculates a text width
@ -272,7 +311,7 @@ MWDECL int MWAPI MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
* @param color Color name
* @return Color
*/
MWDECL MwLLColor MWAPI MwParseColorName(MwWidget handle, const char* color);
MWDECL MwColor MWAPI MwParseColorName(MwWidget handle, const char* color);
/*!
* @brief Parses a color name

View file

@ -58,8 +58,6 @@ struct _MwLLCommonPixmap {
int width;
int height;
unsigned char* raw;
unsigned char* before_blend;
void* internal;
};
#ifdef USE_DBUS
@ -255,7 +253,7 @@ MWDECL void (*MwLLBeginDraw)(MwLL handle);
MWDECL void (*MwLLEndDraw)(MwLL handle);
MWDECL MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
MWDECL void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
MWDECL void (*MwLLColorUpdate)(MwLLColor c, int r, int g, int b);
MWDECL void (*MwLLFreeColor)(MwLLColor color);
MWDECL void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
@ -362,7 +360,7 @@ MWDECL int MwFL_STBTTSetup(void);
MWDECL int MwFL_GDISetup(void);
#endif
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color);
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwColor color);
MWDECL int (*MwFLTextWidth)(MwFLFont ttf, const char* text);
MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
MWDECL int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text);

View file

@ -34,6 +34,7 @@ struct _MwLLGDI {
struct _MwLLGDIColor {
struct _MwLLCommonColor common;
MwLL handle;
HBRUSH brush;
};

View file

@ -88,6 +88,7 @@ struct _MwLLX11 {
struct _MwLLX11Color {
struct _MwLLCommonColor common;
MwLL handle;
unsigned long pixel;
};

View file

@ -120,4 +120,11 @@
#define MwInline static __inline
#ifdef __GNUC__
/* when was this added to gcc? */
#define MW_DEPRECATE(reason) __attribute__((deprecated((reason))))
#else
#define MW_DEPRECATE(reason)
#endif
#endif

View file

@ -15,12 +15,12 @@ extern "C" {
/*!
* @brief Default font data
*/
MWDECL MwFont MwFontData[];
MWDECL MwFontResource MwFontData[];
/*!
* @brief Default bold font data
*/
MWDECL MwFont MwBoldFontData[];
MWDECL MwFontResource MwBoldFontData[];
/*!
* @brief Default TTF font data

View file

@ -38,8 +38,14 @@ typedef struct _MwDocument* MwDocument;
typedef struct _MwMouse MwMouse;
typedef struct _MwTTFInfo* MwTTFInfo;
#ifdef _MILSKO
typedef struct _MwPixmap* MwPixmap;
typedef struct _MwColor* MwColor;
typedef struct _MwFont* MwFont;
typedef struct _MwWidget* MwWidget;
#else
typedef void* MwPixmap;
typedef void* MwColor;
typedef void* MwFont;
typedef void* MwWidget;
#endif
typedef void (*MwHandler)(MwWidget handle);
@ -84,9 +90,26 @@ struct _MwVoidKeyValue {
#include <Mw/LowLevel.h>
#ifdef _MILSKO
struct _MwPixmap {
MwLLPixmap lowlevel;
MwLLCommonPixmap common;
MwWidget handle;
unsigned char* raw;
};
struct _MwColor {
MwLLColor lowlevel;
MwLLCommonColor common;
};
struct _MwFont {
MwFLFont lowlevel;
};
struct _MwWidget {
char* name;
MwLLColor bgcolor;
char* name;
MwColor bgcolor;
MwLL lowlevel;
MwWidget parent;
@ -106,7 +129,7 @@ struct _MwWidget {
MwHandler destroy_inject;
MwHandlerProp prop_inject_pixmap; /* this is for pixmap; do not use */
MwLLPixmap* pixmaps;
MwPixmap* pixmaps;
MwIntegerKeyValue* integer;
MwTextKeyValue* text;
@ -163,8 +186,8 @@ struct _MwViewport {
};
struct _MwListBoxEntry {
char** name;
MwLLPixmap pixmap;
char** name;
MwPixmap pixmap;
};
struct _MwListBox {
@ -186,7 +209,7 @@ struct _MwComboBox {
struct _MwTreeViewEntry {
char* label;
MwLLPixmap pixmap;
MwPixmap pixmap;
MwTreeViewEntry** tree;
int opened;
int selected;

View file

@ -40,7 +40,7 @@ MwInline int MwListBoxSet(MwWidget handle, int row, int col, const char* text) {
* @param index Index
* @param icon Icon
*/
MwInline void MwListBoxSetIcon(MwWidget handle, int index, MwLLPixmap icon) {
MwInline void MwListBoxSetIcon(MwWidget handle, int index, MwPixmap icon) {
MwVaWidgetExecute(handle, "mwListBoxSetIcon", NULL, index, icon);
}

View file

@ -25,7 +25,7 @@ MWDECL MwClass MwTreeViewClass;
* @parma pixmap Pixmap
* @param item Item
*/
MwInline void* MwTreeViewAdd(MwWidget handle, void* parent, MwLLPixmap pixmap, const char* item) {
MwInline void* MwTreeViewAdd(MwWidget handle, void* parent, MwPixmap pixmap, const char* item) {
void* out;
MwVaWidgetExecute(handle, "mwTreeViewAdd", &out, parent, pixmap, item);
return out;
@ -76,7 +76,7 @@ MwInline void MwTreeViewSetLabel(MwWidget handle, void* item, const char* label)
* @param item Item
* @param pixmap Pixmap
*/
MwInline void MwTreeViewSetPixmap(MwWidget handle, void* item, MwLLPixmap pixmap) {
MwInline void MwTreeViewSetPixmap(MwWidget handle, void* item, MwPixmap pixmap) {
MwVaWidgetExecute(handle, "mwTreeViewSetPixmap", NULL, item, pixmap);
}