mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
h
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@26 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
17
src/button.c
Normal file
17
src/button.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* $Id$ */
|
||||
#include <Milsko/Milsko.h>
|
||||
|
||||
static void create(MilskoWidget handle) {
|
||||
}
|
||||
|
||||
static void draw(MilskoWidget handle) {
|
||||
}
|
||||
|
||||
MilskoClassRec MilskoButtonClassRec = {
|
||||
NULL, /* opaque */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL /* click */
|
||||
};
|
||||
MilskoClass MilskoButtonClass = &MilskoButtonClassRec;
|
||||
41
src/core.c
41
src/core.c
@@ -162,44 +162,3 @@ void MilskoApply(MilskoWidget handle, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static int hex(const char* txt, int len) {
|
||||
int i;
|
||||
int r = 0;
|
||||
for(i = 0; i < len; i++) {
|
||||
char c = txt[i];
|
||||
int n = 0;
|
||||
if('a' <= c && c <= 'f') {
|
||||
n = c - 'a' + 10;
|
||||
} else if('A' <= c && c <= 'F') {
|
||||
n = c - 'A' + 10;
|
||||
} else if('0' <= c && c <= '9') {
|
||||
n = c - '0';
|
||||
}
|
||||
r = r << 4;
|
||||
r |= n;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) {
|
||||
int r = 0;
|
||||
int g = 0;
|
||||
int b = 0;
|
||||
|
||||
if(text[0] == '#' && strlen(text) == 4) {
|
||||
r = hex(text + 1, 1);
|
||||
g = hex(text + 2, 1);
|
||||
b = hex(text + 3, 1);
|
||||
|
||||
r |= r << 4;
|
||||
g |= g << 4;
|
||||
b |= b << 4;
|
||||
} else if(text[0] == '#' && strlen(text) == 7) {
|
||||
r = hex(text + 1, 2);
|
||||
g = hex(text + 3, 2);
|
||||
b = hex(text + 5, 2);
|
||||
}
|
||||
|
||||
return MilskoLLAllocColor(handle->lowlevel, r, g, b);
|
||||
}
|
||||
|
||||
61
src/draw.c
Normal file
61
src/draw.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $Id$ */
|
||||
#include <Milsko/Milsko.h>
|
||||
|
||||
static int hex(const char* txt, int len) {
|
||||
int i;
|
||||
int r = 0;
|
||||
for(i = 0; i < len; i++) {
|
||||
char c = txt[i];
|
||||
int n = 0;
|
||||
if('a' <= c && c <= 'f') {
|
||||
n = c - 'a' + 10;
|
||||
} else if('A' <= c && c <= 'F') {
|
||||
n = c - 'A' + 10;
|
||||
} else if('0' <= c && c <= '9') {
|
||||
n = c - '0';
|
||||
}
|
||||
r = r << 4;
|
||||
r |= n;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) {
|
||||
int r = 0;
|
||||
int g = 0;
|
||||
int b = 0;
|
||||
|
||||
if(text[0] == '#' && strlen(text) == 4) {
|
||||
r = hex(text + 1, 1);
|
||||
g = hex(text + 2, 1);
|
||||
b = hex(text + 3, 1);
|
||||
|
||||
r |= r << 4;
|
||||
g |= g << 4;
|
||||
b |= b << 4;
|
||||
} else if(text[0] == '#' && strlen(text) == 7) {
|
||||
r = hex(text + 1, 2);
|
||||
g = hex(text + 3, 2);
|
||||
b = hex(text + 5, 2);
|
||||
}
|
||||
|
||||
return MilskoLLAllocColor(handle->lowlevel, r, g, b);
|
||||
}
|
||||
|
||||
void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color) {
|
||||
MilskoPoint p[4];
|
||||
|
||||
p[0].x = rect->x;
|
||||
p[0].y = rect->y;
|
||||
|
||||
p[1].x = rect->x + rect->width;
|
||||
p[1].y = rect->y;
|
||||
|
||||
p[2].x = rect->x + rect->width;
|
||||
p[2].y = rect->y + rect->height;
|
||||
|
||||
p[3].x = rect->x;
|
||||
p[3].y = rect->y + rect->height;
|
||||
|
||||
MilskoLLPolygon(handle->lowlevel, p, 4, color);
|
||||
}
|
||||
19
src/window.c
19
src/window.c
@@ -7,21 +7,14 @@ static void create(MilskoWidget handle) {
|
||||
|
||||
static void draw(MilskoWidget handle) {
|
||||
MilskoLLColor c = MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground));
|
||||
MilskoPoint p[4];
|
||||
MilskoRect r;
|
||||
|
||||
p[0].x = 0;
|
||||
p[0].y = 0;
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.width = MilskoGetInteger(handle, MilskoNwidth);
|
||||
r.height = MilskoGetInteger(handle, MilskoNheight);
|
||||
|
||||
p[1].x = MilskoGetInteger(handle, MilskoNwidth);
|
||||
p[1].y = 0;
|
||||
|
||||
p[2].x = MilskoGetInteger(handle, MilskoNwidth);
|
||||
p[2].y = MilskoGetInteger(handle, MilskoNheight);
|
||||
|
||||
p[3].x = 0;
|
||||
p[3].y = MilskoGetInteger(handle, MilskoNheight);
|
||||
|
||||
MilskoLLPolygon(handle->lowlevel, p, 4, c);
|
||||
MilskoDrawRect(handle, &r, c);
|
||||
|
||||
MilskoLLFreeColor(c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user