forked from pyrite-dev/milsko
Compare commits
13 commits
49a0f08f61
...
270c87bca2
| Author | SHA1 | Date | |
|---|---|---|---|
|
270c87bca2 |
|||
|
dabe62d475 |
|||
|
1e74356db7 |
|||
|
bc998806ee |
|||
|
cf4fdc531a |
|||
|
f9c0ec987e |
|||
|
0c8715ec9f |
|||
|
363897df74 |
|||
|
e57f3fd910 |
|||
|
82f9330bef |
|||
|
bbc27d680a |
|||
|
0c787264c6 |
|||
| 9a4c74ad93 |
25 changed files with 4881 additions and 904 deletions
1
.clangd
1
.clangd
|
|
@ -1 +0,0 @@
|
||||||
header-insertion: never
|
|
||||||
|
|
@ -171,10 +171,10 @@ print(OUT "\n");
|
||||||
print(OUT "all: lib examples\n");
|
print(OUT "all: lib examples\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "install: lib\n");
|
print(OUT "install: lib\n");
|
||||||
print(OUT " mkdir -p \$(PREFIX)/lib \$(PREFIX)/include\n");
|
print(OUT " mkdir -p \$(DESTDIR)\$(PREFIX)/lib \$(DESTDIR)\$(PREFIX)/include\n");
|
||||||
print(OUT " -cp src/${library_prefix}Mw${library_suffix} \$(PREFIX)/lib/\n");
|
print(OUT " -cp src/${library_prefix}Mw${library_suffix} \$(DESTDIR)\$(PREFIX)/lib/\n");
|
||||||
print(OUT " -cp src/libMw.a \$(PREFIX)/lib/\n");
|
print(OUT " -cp src/libMw.a \$(DESTDIR)\$(PREFIX)/lib/\n");
|
||||||
print(OUT " cp -rf include \$(PREFIX)/\n");
|
print(OUT " cp -rf include \$(DESTDIR)\$(PREFIX)/\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "format:\n");
|
print(OUT "format:\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
|
|
|
||||||
|
|
@ -142,10 +142,10 @@ int main() {
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
bgcolor = MwParseColor(window, MwGetText(window, MwNbackground));
|
bgcolor = MwParseColor(window, MwGetText(window, MwNbackground));
|
||||||
MwGetColor(bgcolor, &br, &bg, &bb);
|
MwColorGet(bgcolor, &br, &bg, &bb);
|
||||||
|
|
||||||
fgcolor = MwParseColor(window, MwGetText(window, MwNforeground));
|
fgcolor = MwParseColor(window, MwGetText(window, MwNforeground));
|
||||||
MwGetColor(fgcolor, &fr, &fg, &fb);
|
MwColorGet(fgcolor, &fr, &fg, &fb);
|
||||||
|
|
||||||
opengl = MwCreateWidget(MwOpenGLClass, "clock", window, 0, 0, 100, 100);
|
opengl = MwCreateWidget(MwOpenGLClass, "clock", window, 0, 0, 100, 100);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ typedef uint16_t MwU16;
|
||||||
typedef int8_t MwI8;
|
typedef int8_t MwI8;
|
||||||
typedef uint8_t MwU8;
|
typedef uint8_t MwU8;
|
||||||
|
|
||||||
#define OTHER_TYPES_DEFINED
|
#define MW_OTHER_TYPES_DEFINED
|
||||||
#elif __GNUC__ > 2
|
#elif __GNUC__ > 2
|
||||||
typedef long long MwI64;
|
typedef long long MwI64;
|
||||||
typedef unsigned long long MwU64;
|
typedef unsigned long long MwU64;
|
||||||
|
|
@ -48,18 +48,18 @@ typedef unsigned __int16 MwU16;
|
||||||
typedef __int8 MwI8;
|
typedef __int8 MwI8;
|
||||||
typedef unsigned __int8 MwU8;
|
typedef unsigned __int8 MwU8;
|
||||||
|
|
||||||
#define OTHER_TYPES_DEFINED
|
#define MW_OTHER_TYPES_DEFINED
|
||||||
#else
|
#else
|
||||||
/* out of hope */
|
/* out of hope */
|
||||||
typedef long MwI64;
|
typedef long MwI64;
|
||||||
typedef unsigned long MwU64;
|
typedef unsigned long MwU64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OTHER_TYPES_DEFINED
|
#ifdef MW_OTHER_TYPES_DEFINED
|
||||||
#undef OTHER_TYPES_DEFINED
|
#undef MW_OTHER_TYPES_DEFINED
|
||||||
#else
|
#else
|
||||||
typedef int MwI32;
|
typedef int MwI32;
|
||||||
typedef unsigned int MwU32;
|
typedef unsigned int MwU32;
|
||||||
|
|
||||||
typedef short MwI16;
|
typedef short MwI16;
|
||||||
typedef unsigned short MwU16;
|
typedef unsigned short MwU16;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,13 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Parses a color text
|
||||||
|
* @param text Color text
|
||||||
|
* @param rgb RGB
|
||||||
|
*/
|
||||||
|
MWDECL void MwParseColorNoAllocate(const char* text, MwRGB* rgb);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Lighten a color
|
* @brief Lighten a color
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
|
|
@ -105,7 +112,7 @@ MWDECL MwLLPixmap MwLoadImage(MwWidget handle, const char* path);
|
||||||
* @param green Pointer to green color
|
* @param green Pointer to green color
|
||||||
* @param blue Pointer to blue color
|
* @param blue Pointer to blue color
|
||||||
*/
|
*/
|
||||||
MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue);
|
MWDECL void MwColorGet(MwLLColor color, int* red, int* green, int* blue);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Creates a pixmap from raw data
|
* @brief Creates a pixmap from raw data
|
||||||
|
|
@ -118,14 +125,25 @@ MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue);
|
||||||
MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
|
MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Creates a pixmap from raw data
|
* @brief Updates a pixmap using raw data
|
||||||
* @param handle Widget
|
* @param pixmap Pixmap to update
|
||||||
* @param rgb RGBA data
|
* @param rgb RGBA data
|
||||||
* @param width Width
|
|
||||||
* @param height Height
|
|
||||||
* @return Pixmap
|
|
||||||
*/
|
*/
|
||||||
MWDECL void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwLLPixmap pixmap);
|
MWDECL void MwPixmapReloadRaw(MwLLPixmap pixmap, unsigned char* rgb);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets the raw data of pixmap
|
||||||
|
* @param pixmap Pixmap
|
||||||
|
* @return RFBA data
|
||||||
|
*/
|
||||||
|
MWDECL unsigned char* MwPixmapGetRaw(MwLLPixmap pixmap);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets the size of pixmap
|
||||||
|
* @param pixmap Pixmap
|
||||||
|
* @param rect Size
|
||||||
|
*/
|
||||||
|
MWDECL void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Creates a pixmap from XPM data
|
* @brief Creates a pixmap from XPM data
|
||||||
|
|
@ -191,6 +209,13 @@ MWDECL int MwTextHeight(MwWidget handle, const char* text);
|
||||||
*/
|
*/
|
||||||
MWDECL MwLLColor MwParseColorName(MwWidget handle, const char* color);
|
MWDECL MwLLColor MwParseColorName(MwWidget handle, const char* color);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Parses a color name
|
||||||
|
* @param color Color name
|
||||||
|
* @param rgb RGB
|
||||||
|
*/
|
||||||
|
MWDECL void MwParseColorNameNoAllocate(const char* color, MwRGB* rgb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ struct _MwLLCommonPixmap {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
unsigned char* raw;
|
unsigned char* raw;
|
||||||
|
void* user;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
/*!
|
/*!
|
||||||
* @file Mw/LowLevel/Wayland.h
|
* @file Mw/LowLevel/Wayland.h
|
||||||
* @brief Wayland Backend
|
* @brief Work in progress Wayland Backend
|
||||||
* @warning This is used internally
|
* @warning This is used internally.
|
||||||
|
* @warning This is disabled by default.
|
||||||
*/
|
*/
|
||||||
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
||||||
#define __MW_LOWLEVEL_WAYLAND_H__
|
#define __MW_LOWLEVEL_WAYLAND_H__
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#define MwNshowArrows "IshowArrows"
|
#define MwNshowArrows "IshowArrows"
|
||||||
#define MwNpadding "Ipadding"
|
#define MwNpadding "Ipadding"
|
||||||
#define MwNborderWidth "IborderWidth"
|
#define MwNborderWidth "IborderWidth"
|
||||||
|
#define MwNfillArea "IfillArea"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|
@ -44,6 +45,7 @@
|
||||||
#define MwNsizeHints "VsizeHints"
|
#define MwNsizeHints "VsizeHints"
|
||||||
#define MwNfont "Vfont"
|
#define MwNfont "Vfont"
|
||||||
#define MwNboldFont "VboldFont"
|
#define MwNboldFont "VboldFont"
|
||||||
|
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
||||||
|
|
||||||
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
||||||
#define MwNresizeHandler "Cresize" /* NULL */
|
#define MwNresizeHandler "Cresize" /* NULL */
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
- MwNwidth
|
- MwNwidth
|
||||||
- MwNheight
|
- MwNheight
|
||||||
- MwNborderWidth
|
- MwNborderWidth
|
||||||
|
- MwNbackgroundPixmap
|
||||||
|
|
||||||
Integer properties must be prefixed with I.
|
Integer properties must be prefixed with I.
|
||||||
String properties must be prefixed with S.
|
String properties must be prefixed with S.
|
||||||
|
|
@ -488,6 +489,7 @@
|
||||||
<property name="text" />
|
<property name="text" />
|
||||||
<property name="flat" />
|
<property name="flat" />
|
||||||
<property name="padding" />
|
<property name="padding" />
|
||||||
|
<property name="fillArea" />
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="CheckBox">
|
<widget name="CheckBox">
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ static void sync_move(MwLL handle, int x, int y) {
|
||||||
XSync(handle->x11.display, False);
|
XSync(handle->x11.display, False);
|
||||||
if(!XPending(handle->x11.display)) continue;
|
if(!XPending(handle->x11.display)) continue;
|
||||||
XNextEvent(handle->x11.display, &ev);
|
XNextEvent(handle->x11.display, &ev);
|
||||||
if(ev.type == ReparentNotify && ev.xreparent.window == handle->x11.window && ev.xreparent.window != RootWindow(handle->x11.display, DefaultScreen(handle->x11.display))) {
|
if(ev.type == ReparentNotify && ev.xreparent.window == handle->x11.window) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
arrput(queue, ev);
|
arrput(queue, ev);
|
||||||
|
|
@ -580,9 +580,7 @@ static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
||||||
MwLLPixmap r = malloc(sizeof(*r));
|
MwLLPixmap r = malloc(sizeof(*r));
|
||||||
char* di = malloc(4 * width * height);
|
|
||||||
char* dm = malloc(4 * width * height);
|
|
||||||
int evbase, erbase;
|
int evbase, erbase;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
|
||||||
|
|
@ -603,8 +601,11 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
|
||||||
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
|
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, di, width, height, 32, width * 4);
|
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, NULL, width, height, 32, 0);
|
||||||
r->x11.mask = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), 1, ZPixmap, 0, dm, width, height, 32, width * 4);
|
r->x11.mask = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), 1, ZPixmap, 0, NULL, width, height, 32, 0);
|
||||||
|
|
||||||
|
r->x11.image->data = malloc(r->x11.image->bytes_per_line * height);
|
||||||
|
r->x11.mask->data = malloc(r->x11.mask->bytes_per_line * height);
|
||||||
|
|
||||||
MwLLPixmapUpdate(r);
|
MwLLPixmapUpdate(r);
|
||||||
return r;
|
return r;
|
||||||
|
|
@ -1020,7 +1021,7 @@ static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
||||||
|
|
||||||
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
||||||
XWindowAttributes xwa;
|
XWindowAttributes xwa;
|
||||||
XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa);
|
XGetWindowAttributes(handle->x11.display, DefaultRootWindow(handle->x11.display), &xwa);
|
||||||
|
|
||||||
rect->x = rect->y = 0;
|
rect->x = rect->y = 0;
|
||||||
rect->width = xwa.width;
|
rect->width = xwa.width;
|
||||||
|
|
|
||||||
5484
src/color.c
5484
src/color.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,6 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#include "../external/stb_ds.h"
|
#include "../external/stb_ds.h"
|
||||||
#include "Mw/LowLevel.h"
|
|
||||||
|
|
||||||
static void lldrawhandler(MwLL handle, void* data) {
|
static void lldrawhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
|
|
||||||
|
|
@ -146,11 +146,11 @@ static void color_picker_image_update(color_picker_t* picker) {
|
||||||
picker->color_picker_pixmap = MwLoadRaw(
|
picker->color_picker_pixmap = MwLoadRaw(
|
||||||
picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE);
|
picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE);
|
||||||
} else {
|
} else {
|
||||||
MwReloadRaw(
|
MwPixmapReloadRaw(
|
||||||
picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE, picker->color_picker_pixmap);
|
picker->color_picker_pixmap, picker->color_picker_image_data);
|
||||||
}
|
}
|
||||||
MwVaApply(picker->color_picker_img, MwNpixmap, picker->color_picker_pixmap, NULL);
|
MwVaApply(picker->color_picker_img, MwNpixmap, picker->color_picker_pixmap, NULL);
|
||||||
// printf("%d\n", n);
|
/* printf("%d\n", n); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void color_picker_click(MwWidget handle, void* user, void* call) {
|
static void color_picker_click(MwWidget handle, void* user, void* call) {
|
||||||
|
|
@ -165,7 +165,7 @@ static void color_picker_click(MwWidget handle, void* user, void* call) {
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)call;
|
(void)call;
|
||||||
|
|
||||||
// color_picker_image_update(picker);
|
/* color_picker_image_update(picker); */
|
||||||
|
|
||||||
i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4;
|
i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4;
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ static void color_picker_on_change_value(MwWidget handle, void* user,
|
||||||
picker->value = ((double)value / 1024.);
|
picker->value = ((double)value / 1024.);
|
||||||
|
|
||||||
picker->doUpdate = 1;
|
picker->doUpdate = 1;
|
||||||
// color_picker_image_update(picker);
|
/* color_picker_image_update(picker); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void color_picker_tick(MwWidget handle, void* user,
|
static void color_picker_tick(MwWidget handle, void* user,
|
||||||
|
|
@ -282,12 +282,12 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) {
|
||||||
MwVaCreateWidget(MwImageClass, "image", picker->parent, IMG_POS_X(w), IMG_POS_Y(h),
|
MwVaCreateWidget(MwImageClass, "image", picker->parent, IMG_POS_X(w), IMG_POS_Y(h),
|
||||||
PICKER_SIZE, PICKER_SIZE, NULL);
|
PICKER_SIZE, PICKER_SIZE, NULL);
|
||||||
|
|
||||||
// picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4);
|
/* picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4); */
|
||||||
|
|
||||||
picker->color_picker_pixmap = NULL;
|
picker->color_picker_pixmap = NULL;
|
||||||
picker->value = 0;
|
picker->value = 0;
|
||||||
|
|
||||||
// color_picker_image_update(picker);
|
/* color_picker_image_update(picker); */
|
||||||
picker->doUpdate = 1;
|
picker->doUpdate = 1;
|
||||||
|
|
||||||
MwAddUserHandler(picker->color_picker_img, MwNmouseDownHandler,
|
MwAddUserHandler(picker->color_picker_img, MwNmouseDownHandler,
|
||||||
|
|
@ -299,7 +299,7 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) {
|
||||||
|
|
||||||
MwSetText(picker->color_display_text, MwNbackground, "#FFFFFF");
|
MwSetText(picker->color_display_text, MwNbackground, "#FFFFFF");
|
||||||
MwSetText(picker->color_display_text, MwNtext, "#FFFFFF");
|
MwSetText(picker->color_display_text, MwNtext, "#FFFFFF");
|
||||||
// MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER);
|
/* MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER); */
|
||||||
|
|
||||||
MwAddUserHandler(picker->color_display_text, MwNactivateHandler,
|
MwAddUserHandler(picker->color_display_text, MwNactivateHandler,
|
||||||
color_display_text_change, picker);
|
color_display_text_change, picker);
|
||||||
|
|
|
||||||
90
src/draw.c
90
src/draw.c
|
|
@ -37,28 +37,35 @@ static int hex(const char* txt, int len) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLColor MwParseColor(MwWidget handle, const char* text) {
|
void MwParseColorNoAllocate(const char* text, MwRGB* rgb) {
|
||||||
int r;
|
|
||||||
int g;
|
|
||||||
int b;
|
|
||||||
|
|
||||||
if(text[0] == '#' && strlen(text) == 4) {
|
if(text[0] == '#' && strlen(text) == 4) {
|
||||||
r = hex(text + 1, 1);
|
rgb->red = hex(text + 1, 1);
|
||||||
g = hex(text + 2, 1);
|
rgb->green = hex(text + 2, 1);
|
||||||
b = hex(text + 3, 1);
|
rgb->blue = hex(text + 3, 1);
|
||||||
|
|
||||||
r |= r << 4;
|
rgb->red |= rgb->red << 4;
|
||||||
g |= g << 4;
|
rgb->green |= rgb->green << 4;
|
||||||
b |= b << 4;
|
rgb->blue |= rgb->blue << 4;
|
||||||
} else if(text[0] == '#' && strlen(text) == 7) {
|
} else if(text[0] == '#' && strlen(text) == 7) {
|
||||||
r = hex(text + 1, 2);
|
rgb->red = hex(text + 1, 2);
|
||||||
g = hex(text + 3, 2);
|
rgb->green = hex(text + 3, 2);
|
||||||
b = hex(text + 5, 2);
|
rgb->blue = hex(text + 5, 2);
|
||||||
} else {
|
} else {
|
||||||
return MwParseColorName(handle, text);
|
MwParseColorNameNoAllocate(text, rgb);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return MwLLAllocColor(handle->lowlevel, r, g, b);
|
MwLLColor MwParseColor(MwWidget handle, const char* text) {
|
||||||
|
MwRGB rgb;
|
||||||
|
|
||||||
|
rgb.red = 0;
|
||||||
|
rgb.green = 0;
|
||||||
|
rgb.blue = 0;
|
||||||
|
|
||||||
|
MwParseColorNoAllocate(text, &rgb);
|
||||||
|
|
||||||
|
return MwLLAllocColor(handle->lowlevel, rgb.red, rgb.green, rgb.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b) {
|
MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b) {
|
||||||
|
|
@ -649,45 +656,21 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) {
|
MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) {
|
||||||
MwLLPixmap px;
|
MwLLPixmap px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||||
unsigned char* out = malloc(width * height * 4);
|
|
||||||
int i;
|
|
||||||
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
|
|
||||||
|
|
||||||
memset(out, 0, width * height * 4);
|
px->common.user = handle;
|
||||||
for(i = 0; i < width * height; i++) {
|
MwPixmapReloadRaw(px, rgb);
|
||||||
unsigned char* pin = &rgb[i * 4];
|
|
||||||
unsigned char* pout = &out[i * 4];
|
|
||||||
double a = pin[3];
|
|
||||||
|
|
||||||
a /= 255;
|
|
||||||
if(a != 0) {
|
|
||||||
pout[0] = pin[0] * a;
|
|
||||||
pout[1] = pin[1] * a;
|
|
||||||
pout[2] = pin[2] * a;
|
|
||||||
|
|
||||||
pout[0] += base->common.red * (1 - a);
|
|
||||||
pout[1] += base->common.green * (1 - a);
|
|
||||||
pout[2] += base->common.blue * (1 - a);
|
|
||||||
pout[3] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(handle->bgcolor == NULL) MwLLFreeColor(base);
|
|
||||||
|
|
||||||
px = MwLLCreatePixmap(handle->lowlevel, out, width, height);
|
|
||||||
|
|
||||||
free(out);
|
|
||||||
|
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwLLPixmap px) {
|
void MwPixmapReloadRaw(MwLLPixmap px, unsigned char* rgb) {
|
||||||
int i;
|
int i;
|
||||||
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
|
MwWidget handle = px->common.user;
|
||||||
|
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
|
||||||
|
|
||||||
memset(px->common.raw, 0, width * height * 4);
|
memset(px->common.raw, 0, px->common.width * px->common.height * 4);
|
||||||
for(i = 0; i < width * height; i++) {
|
for(i = 0; i < px->common.width * px->common.height; i++) {
|
||||||
unsigned char* pin = &rgb[i * 4];
|
unsigned char* pin = &rgb[i * 4];
|
||||||
unsigned char* pout = &px->common.raw[i * 4];
|
unsigned char* pout = &px->common.raw[i * 4];
|
||||||
double a = pin[3];
|
double a = pin[3];
|
||||||
|
|
@ -710,7 +693,16 @@ void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwL
|
||||||
MwLLPixmapUpdate(px);
|
MwLLPixmapUpdate(px);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwGetColor(MwLLColor color, int* red, int* green, int* blue) {
|
unsigned char* MwPixmapGetRaw(MwLLPixmap pixmap) {
|
||||||
|
return pixmap->common.raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect) {
|
||||||
|
rect->width = pixmap->common.width;
|
||||||
|
rect->height = pixmap->common.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwColorGet(MwLLColor color, int* red, int* green, int* blue) {
|
||||||
*red = color->common.red;
|
*red = color->common.red;
|
||||||
*green = color->common.green;
|
*green = color->common.green;
|
||||||
*blue = color->common.blue;
|
*blue = color->common.blue;
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ static int ttf_MwTextHeight(MwWidget handle, int count) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||||
|
if(strlen(text) == 0) return;
|
||||||
#ifdef TTF
|
#ifdef TTF
|
||||||
if(ttf_MwDrawText(handle, point, text, bold, align, color))
|
if(ttf_MwDrawText(handle, point, text, bold, align, color))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ static int create(MwWidget handle) {
|
||||||
|
|
||||||
MwSetInteger(handle, MwNflat, 0);
|
MwSetInteger(handle, MwNflat, 0);
|
||||||
MwSetInteger(handle, MwNpadding, 0);
|
MwSetInteger(handle, MwNpadding, 0);
|
||||||
|
MwSetInteger(handle, MwNfillArea, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +17,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
|
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
|
@ -33,6 +35,7 @@ static void draw(MwWidget handle) {
|
||||||
} else {
|
} else {
|
||||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
||||||
}
|
}
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
|
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
|
||||||
r.x += MwDefaultBorderWidth(handle);
|
r.x += MwDefaultBorderWidth(handle);
|
||||||
r.y += MwDefaultBorderWidth(handle);
|
r.y += MwDefaultBorderWidth(handle);
|
||||||
|
|
@ -44,18 +47,23 @@ static void draw(MwWidget handle) {
|
||||||
int ow = r.width;
|
int ow = r.width;
|
||||||
int oh = r.height;
|
int oh = r.height;
|
||||||
|
|
||||||
double sw = (double)ow / px->common.width;
|
if(MwGetInteger(handle, MwNfillArea)) {
|
||||||
double sh = (double)oh / px->common.height;
|
double sw = (double)ow / px->common.width;
|
||||||
|
double sh = (double)oh / px->common.height;
|
||||||
|
|
||||||
if(sw < sh) {
|
if(sw < sh) {
|
||||||
r.width = px->common.width * sw;
|
r.width = px->common.width * sw;
|
||||||
r.height = px->common.height * sw;
|
r.height = px->common.height * sw;
|
||||||
|
} else {
|
||||||
|
r.width = px->common.width * sh;
|
||||||
|
r.height = px->common.height * sh;
|
||||||
|
}
|
||||||
|
r.width -= MwGetInteger(handle, MwNpadding) * 2;
|
||||||
|
r.height -= MwGetInteger(handle, MwNpadding) * 2;
|
||||||
} else {
|
} else {
|
||||||
r.width = px->common.width * sh;
|
r.width = px->common.width;
|
||||||
r.height = px->common.height * sh;
|
r.height = px->common.height;
|
||||||
}
|
}
|
||||||
r.width -= MwGetInteger(handle, MwNpadding) * 2;
|
|
||||||
r.height -= MwGetInteger(handle, MwNpadding) * 2;
|
|
||||||
|
|
||||||
r.x += (double)(ow - r.width) / 2;
|
r.x += (double)(ow - r.width) / 2;
|
||||||
r.y += (double)(oh - r.height) / 2;
|
r.y += (double)(oh - r.height) / 2;
|
||||||
|
|
@ -77,7 +85,7 @@ static void click(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prop_change(MwWidget handle, const char* key) {
|
static void prop_change(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0) MwForceRender(handle);
|
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0 || strcmp(key, MwNfillArea) == 0) MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwButtonClassRec = {
|
MwClassRec MwButtonClassRec = {
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,9 @@ static int create(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect r;
|
MwRect r;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
@ -18,6 +19,7 @@ static void draw(MwWidget handle) {
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwTRUE);
|
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwTRUE);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(handle->pressed || MwGetInteger(handle, MwNchecked)) {
|
if(handle->pressed || MwGetInteger(handle, MwNchecked)) {
|
||||||
/* TODO: write check mark */
|
/* TODO: write check mark */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
|
|
@ -33,6 +34,7 @@ static void draw(MwWidget handle) {
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(str != NULL) {
|
if(str != NULL) {
|
||||||
int w = MwTextWidth(handle, "M");
|
int w = MwTextWidth(handle, "M");
|
||||||
int h = MwTextHeight(handle, "M");
|
int h = MwTextHeight(handle, "M");
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ static int create(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect fr;
|
MwRect fr;
|
||||||
MwRect rr;
|
MwRect rr;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
int inverted;
|
int inverted;
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNhasBorder)) {
|
if(MwGetInteger(handle, MwNhasBorder)) {
|
||||||
inverted = MwGetInteger(handle, MwNinverted);
|
inverted = MwGetInteger(handle, MwNinverted);
|
||||||
|
|
@ -36,6 +37,7 @@ static void draw(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawRect(handle, &rr, base);
|
MwDrawRect(handle, &rr, base);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &rr, bgpx);
|
||||||
|
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
int align;
|
int align;
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
|
@ -24,6 +25,7 @@ static void draw(MwWidget handle) {
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
align = MwGetInteger(handle, MwNalignment);
|
align = MwGetInteger(handle, MwNalignment);
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,11 @@ static int create(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect r;
|
MwRect r;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor fill = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor fill = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
double w;
|
double w;
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
@ -26,6 +27,7 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
|
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
|
||||||
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));
|
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
r.x += MwDefaultBorderWidth(handle);
|
r.x += MwDefaultBorderWidth(handle);
|
||||||
r.y += MwDefaultBorderWidth(handle);
|
r.y += MwDefaultBorderWidth(handle);
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,9 @@ static int create(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect r;
|
MwRect r;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
@ -20,6 +21,7 @@ static void draw(MwWidget handle) {
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
MwDrawDiamond(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
|
MwDrawDiamond(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
|
||||||
|
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
int or ;
|
int or ;
|
||||||
int uy, dy, ux, dx;
|
int uy, dy, ux, dx;
|
||||||
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
|
|
@ -79,6 +80,7 @@ static void draw(MwWidget handle) {
|
||||||
dx = r.width - r.height;
|
dx = r.width - r.height;
|
||||||
|
|
||||||
MwDrawWidgetBack(handle, &r, dark, 1, MwTRUE);
|
MwDrawWidgetBack(handle, &r, dark, 1, MwTRUE);
|
||||||
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
rt = r;
|
rt = r;
|
||||||
|
|
||||||
|
|
@ -142,7 +144,7 @@ static void draw(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_move(MwWidget handle) {
|
static void mouse_move(MwWidget handle) {
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
|
|
||||||
if(!handle->pressed) return;
|
if(!handle->pressed) return;
|
||||||
|
|
@ -170,9 +172,9 @@ static void mouse_move(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_down(MwWidget handle, void* ptr) {
|
static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
int ww = MwGetInteger(handle, MwNwidth);
|
int ww = MwGetInteger(handle, MwNwidth);
|
||||||
int wh = MwGetInteger(handle, MwNheight);
|
int wh = MwGetInteger(handle, MwNheight);
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
MwLLMouse* m = ptr;
|
MwLLMouse* m = ptr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
if(tree->selected) {
|
if(tree->selected) {
|
||||||
r.x = p->x;
|
r.x = p->x;
|
||||||
r.y = p->y - MwTextHeight(handle, "M") / 2;
|
r.y = p->y - MwTextHeight(handle, "M") / 2;
|
||||||
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift; // MwTextWidth(handle, tree->label);
|
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift;
|
||||||
r.height = MwTextHeight(handle, "M");
|
r.height = MwTextHeight(handle, "M");
|
||||||
MwDrawRect(handle, &r, text2);
|
MwDrawRect(handle, &r, text2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,29 @@ open(OUT, ">", "src/color.c");
|
||||||
print(OUT "#include <Mw/Milsko.h>\n");
|
print(OUT "#include <Mw/Milsko.h>\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "MwLLColor MwParseColorName(MwWidget handle, const char* color){\n");
|
print(OUT "MwLLColor MwParseColorName(MwWidget handle, const char* color){\n");
|
||||||
|
print(OUT " MwRGB rgb;\n");
|
||||||
|
print(OUT " MwParseColorNameNoAllocate(color, &rgb);\n");
|
||||||
|
print(OUT
|
||||||
|
" return MwLLAllocColor(handle->lowlevel, rgb.red, rgb.green, rgb.blue);\n"
|
||||||
|
);
|
||||||
|
print(OUT "}\n");
|
||||||
|
print(OUT "\n");
|
||||||
|
print(OUT "void MwParseColorNameNoAllocate(const char* color, MwRGB* rgb){\n");
|
||||||
|
|
||||||
while (my $l = <IN>) {
|
while (my $l = <IN>) {
|
||||||
$l =~ s/\r?\n$//;
|
$l =~ s/\r?\n$//;
|
||||||
if ($l =~ /^[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)$/) {
|
if ($l =~ /^[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)$/) {
|
||||||
print(OUT
|
print(OUT " if(strcmp(color, \"$4\") == 0){\n");
|
||||||
" if(strcmp(color, \"$4\") == 0) return MwLLAllocColor(handle->lowlevel, $1, $2, $3);\n"
|
print(OUT " rgb->red = $1;\n");
|
||||||
);
|
print(OUT " rgb->green = $2;\n");
|
||||||
|
print(OUT " rgb->green = $3;\n");
|
||||||
|
print(OUT " return;\n");
|
||||||
|
print(OUT " }\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(OUT " return MwLLAllocColor(handle->lowlevel, 0, 0, 0);\n");
|
print(OUT " rgb->red = 0;\n");
|
||||||
|
print(OUT " rgb->green = 0;\n");
|
||||||
|
print(OUT " rgb->blue = 0;\n");
|
||||||
print(OUT "}\n");
|
print(OUT "}\n");
|
||||||
|
|
||||||
close(OUT);
|
close(OUT);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue