2025-09-30 13:04:40 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @file Mw/Draw.h
|
|
|
|
|
* @brief Common drawing API
|
2025-09-30 13:04:40 +00:00
|
|
|
*/
|
2025-09-29 00:06:16 +00:00
|
|
|
#ifndef __MW_DRAW_H__
|
|
|
|
|
#define __MW_DRAW_H__
|
|
|
|
|
|
|
|
|
|
#include <Mw/MachDep.h>
|
|
|
|
|
#include <Mw/TypeDefs.h>
|
|
|
|
|
#include <Mw/LowLevel.h>
|
|
|
|
|
|
2025-09-29 00:19:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-09-30 13:04:40 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Parses a color text
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param text Color text
|
|
|
|
|
* @return Color
|
2025-09-30 13:04:40 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLColor MWAPI MwParseColor(MwWidget handle, const char* text);
|
2025-09-29 00:06:16 +00:00
|
|
|
|
2025-12-15 06:48:40 +09:00
|
|
|
/*!
|
|
|
|
|
* @brief Parses a color text
|
|
|
|
|
* @param text Color text
|
|
|
|
|
* @param rgb RGB
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwParseColorNoAllocate(const char* text, MwRGB* rgb);
|
2025-12-15 06:48:40 +09:00
|
|
|
|
2025-10-04 16:34:24 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Lighten a color
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param r Red
|
|
|
|
|
* @param g Green
|
|
|
|
|
* @param b Blue
|
|
|
|
|
* @return Color
|
2025-10-04 16:34:24 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLColor MWAPI MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b);
|
2025-10-04 16:34:24 +00:00
|
|
|
|
2025-09-30 13:04:40 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Draws a filled rectangle
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
2025-09-30 13:04:40 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
2025-09-30 13:04:40 +00:00
|
|
|
|
2025-10-23 00:26:36 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Draws a filled rectangle that fades to a darker color
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
2025-10-23 00:26:36 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color);
|
2025-10-23 00:26:36 +00:00
|
|
|
|
2025-09-30 13:04:40 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Draws a frame
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param invert Invert the 3D border color or not
|
|
|
|
|
* @warning `rect` gets changed to the area of rectangle inside
|
2025-09-30 13:04:40 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
2025-09-30 13:04:40 +00:00
|
|
|
|
2025-10-23 00:26:36 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Does the DrawFrame/DrawRect combo used for drawing widget.
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param invert Invert the 3D border color or not
|
|
|
|
|
* @warning `rect` gets changed to the area of rectangle inside
|
2025-10-23 00:26:36 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
|
2025-10-23 00:26:36 +00:00
|
|
|
|
2025-10-04 16:34:24 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Draws a triangle
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param invert Invert the 3D border color or not
|
2025-10-04 16:34:24 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction);
|
2025-10-04 16:34:24 +00:00
|
|
|
|
2025-09-30 13:04:40 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Draws a frame with specified border width
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param invert Invert the 3D border color or not
|
|
|
|
|
* @param border Border width
|
2025-11-16 08:59:09 +00:00
|
|
|
* @param diff Difference (set this to 0 if you don't know what this does)
|
|
|
|
|
* @param same Same as dark color
|
2025-10-28 20:40:26 +00:00
|
|
|
* @warning `rect` gets changed to the area of rectangle inside
|
2025-09-30 13:04:40 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
|
2025-09-30 13:04:40 +00:00
|
|
|
|
2025-09-30 17:47:03 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Creates a pixmap from image
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param path Path
|
|
|
|
|
* @return Pixmap
|
2025-09-30 17:47:03 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLPixmap MWAPI MwLoadImage(MwWidget handle, const char* path);
|
2025-09-30 17:47:03 +00:00
|
|
|
|
2025-10-09 15:20:49 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @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
|
2025-10-09 15:20:49 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwColorGet(MwLLColor color, int* red, int* green, int* blue);
|
2025-10-09 15:20:49 +00:00
|
|
|
|
2025-10-10 16:46:53 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Creates a pixmap from raw data
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rgb RGBA data
|
|
|
|
|
* @param width Width
|
|
|
|
|
* @param height Height
|
|
|
|
|
* @return Pixmap
|
2025-10-10 16:46:53 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLPixmap MWAPI MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
|
2025-10-10 16:46:53 +00:00
|
|
|
|
2025-11-02 19:15:38 +00:00
|
|
|
/*!
|
2025-12-15 07:05:42 +09:00
|
|
|
* @brief Updates a pixmap using raw data
|
2025-12-15 06:48:40 +09:00
|
|
|
* @param pixmap Pixmap to update
|
2025-11-02 19:15:38 +00:00
|
|
|
* @param rgb RGBA data
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwPixmapReloadRaw(MwLLPixmap pixmap, unsigned char* rgb);
|
2025-12-15 07:05:42 +09:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Gets the raw data of pixmap
|
|
|
|
|
* @param pixmap Pixmap
|
2026-05-02 13:44:16 +09:00
|
|
|
* @return RGBA data
|
2025-12-15 07:05:42 +09:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL unsigned char* MWAPI MwPixmapGetRaw(MwLLPixmap pixmap);
|
2025-12-15 07:05:42 +09:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Gets the size of pixmap
|
|
|
|
|
* @param pixmap Pixmap
|
|
|
|
|
* @param rect Size
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect);
|
2025-11-02 19:15:38 +00:00
|
|
|
|
2025-10-10 16:46:53 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Creates a pixmap from XPM data
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param data Data
|
|
|
|
|
* @return Pixmap
|
2025-10-10 16:46:53 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLPixmap MWAPI MwLoadXPM(MwWidget handle, char** data);
|
2025-10-10 16:46:53 +00:00
|
|
|
|
2025-10-24 16:27:10 +00:00
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Creates a pixmap from icon data
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param data Data
|
|
|
|
|
* @return Pixmap
|
2025-10-24 16:27:10 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLPixmap MWAPI MwLoadIcon(MwWidget handle, MwU32* data);
|
2025-10-24 16:27:10 +00:00
|
|
|
|
2025-10-31 15:02:40 +00:00
|
|
|
/*!
|
|
|
|
|
* @brief Draws a diamond
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param rect Rectangle area
|
|
|
|
|
* @param color Color
|
|
|
|
|
* @param invert Invert the 3D border color or not
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
2025-10-31 15:02:40 +00:00
|
|
|
|
2025-11-05 04:21:39 +00:00
|
|
|
/* text.c */
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Draws a text
|
|
|
|
|
* @param handle Widget
|
2026-04-06 17:29:09 +09:00
|
|
|
* @param ttf TTF, NULLable
|
2025-11-05 04:21:39 +00:00
|
|
|
* @param point Center point of the text
|
|
|
|
|
* @param text Text
|
|
|
|
|
* @param align Align
|
|
|
|
|
* @param color Color
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
|
2025-11-05 04:21:39 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Calculates a text width
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param text Text
|
2026-04-06 17:29:09 +09:00
|
|
|
* @param font Font, NULLable
|
2025-11-05 04:21:39 +00:00
|
|
|
* @return Text width
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL int MWAPI MwTextWidth(MwWidget handle, MwFLFont font, const char* text);
|
2025-11-05 04:21:39 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Calculates a text height
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param text Text
|
2026-04-06 17:29:09 +09:00
|
|
|
* @param font Font, NULLable
|
2025-11-05 04:21:39 +00:00
|
|
|
* @return Text height
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL int MWAPI MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
|
2025-11-05 04:21:39 +00:00
|
|
|
|
2025-10-11 06:21:43 +00:00
|
|
|
/* color.c */
|
|
|
|
|
|
|
|
|
|
/*!
|
2025-10-28 20:40:26 +00:00
|
|
|
* @brief Parses a color name
|
|
|
|
|
* @param handle Widget
|
|
|
|
|
* @param color Color name
|
|
|
|
|
* @return Color
|
2025-10-11 06:21:43 +00:00
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL MwLLColor MWAPI MwParseColorName(MwWidget handle, const char* color);
|
2025-10-11 06:21:43 +00:00
|
|
|
|
2025-12-15 06:48:40 +09:00
|
|
|
/*!
|
|
|
|
|
* @brief Parses a color name
|
|
|
|
|
* @param color Color name
|
|
|
|
|
* @param rgb RGB
|
|
|
|
|
*/
|
2026-04-22 12:05:49 +09:00
|
|
|
MWDECL void MWAPI MwParseColorNameNoAllocate(const char* color, MwRGB* rgb);
|
2025-12-15 06:48:40 +09:00
|
|
|
|
2025-09-29 00:19:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-09-29 00:06:16 +00:00
|
|
|
#endif
|