mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-09 19:03:29 +00:00
default color
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@23 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Milsko/MachDep.h>
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Milsko/TypeDefs.h>
|
||||||
|
#include <Milsko/LowLevel.h>
|
||||||
|
|
||||||
MILSKODECL MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height);
|
MILSKODECL MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height);
|
||||||
MILSKODECL void MilskoDestroyWidget(MilskoWidget handle);
|
MILSKODECL void MilskoDestroyWidget(MilskoWidget handle);
|
||||||
@@ -12,6 +13,8 @@ MILSKODECL void MilskoLoop(MilskoWidget handle);
|
|||||||
MILSKODECL void MilskoStep(MilskoWidget handle);
|
MILSKODECL void MilskoStep(MilskoWidget handle);
|
||||||
MILSKODECL int MilskoPending(MilskoWidget handle);
|
MILSKODECL int MilskoPending(MilskoWidget handle);
|
||||||
|
|
||||||
|
MILSKODECL MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text);
|
||||||
|
|
||||||
MILSKODECL void MilskoSetInteger(MilskoWidget handle, const char* key, int n);
|
MILSKODECL void MilskoSetInteger(MilskoWidget handle, const char* key, int n);
|
||||||
MILSKODECL void MilskoSetText(MilskoWidget handle, const char* key, const char* value);
|
MILSKODECL void MilskoSetText(MilskoWidget handle, const char* key, const char* value);
|
||||||
MILSKODECL int MilskoGetInteger(MilskoWidget handle, const char* key);
|
MILSKODECL int MilskoGetInteger(MilskoWidget handle, const char* key);
|
||||||
|
|||||||
7
include/Milsko/Default.h
Normal file
7
include/Milsko/Default.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
#ifndef __MILSKO_DEFAULT_H__
|
||||||
|
#define __MILSKO_DEFAULT_H__
|
||||||
|
|
||||||
|
#define MILSKO_BACKGROUND "#ddd"
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <Milsko/StringDefs.h>
|
#include <Milsko/StringDefs.h>
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Milsko/TypeDefs.h>
|
||||||
#include <Milsko/Core.h>
|
#include <Milsko/Core.h>
|
||||||
|
#include <Milsko/Default.h>
|
||||||
|
|
||||||
#include <Milsko/Window.h>
|
#include <Milsko/Window.h>
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,6 @@
|
|||||||
#define MilskoNheight "Iheight"
|
#define MilskoNheight "Iheight"
|
||||||
|
|
||||||
#define MilskoNtitle "Stitle"
|
#define MilskoNtitle "Stitle"
|
||||||
|
#define MilskoNbackground "Sbackground"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ typedef struct _MilskoClass {
|
|||||||
MilskoHandler destroy;
|
MilskoHandler destroy;
|
||||||
MilskoHandler draw;
|
MilskoHandler draw;
|
||||||
MilskoHandler click;
|
MilskoHandler click;
|
||||||
|
|
||||||
|
MilskoTextKeyValue* text;
|
||||||
|
MilskoIntegerKeyValue* integer;
|
||||||
} *MilskoClass, MilskoClassRec;
|
} *MilskoClass, MilskoClassRec;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
41
src/core.c
41
src/core.c
@@ -162,3 +162,44 @@ void MilskoApply(MilskoWidget handle, ...) {
|
|||||||
}
|
}
|
||||||
va_end(va);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
16
src/window.c
16
src/window.c
@@ -1,8 +1,12 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Milsko/Milsko.h>
|
||||||
|
|
||||||
|
static void create(MilskoWidget handle) {
|
||||||
|
MilskoSetText(handle, MilskoNbackground, MILSKO_BACKGROUND);
|
||||||
|
}
|
||||||
|
|
||||||
static void draw(MilskoWidget handle) {
|
static void draw(MilskoWidget handle) {
|
||||||
MilskoLLColor c = MilskoLLAllocColor(handle->lowlevel, 255, 0, 0);
|
MilskoLLColor c = MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground));
|
||||||
MilskoPoint p[4];
|
MilskoPoint p[4];
|
||||||
|
|
||||||
p[0].x = 0;
|
p[0].x = 0;
|
||||||
@@ -23,10 +27,10 @@ static void draw(MilskoWidget handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MilskoClassRec MilskoWindowClassRec = {
|
MilskoClassRec MilskoWindowClassRec = {
|
||||||
NULL, /* opaque */
|
NULL, /* opaque */
|
||||||
NULL, /* create */
|
create, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL /* click */
|
NULL /* click */
|
||||||
};
|
};
|
||||||
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;
|
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;
|
||||||
|
|||||||
Reference in New Issue
Block a user