forked from pyrite-dev/milsko
cleanup
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@349 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
ac1e102dee
commit
b04e1a76a6
3 changed files with 10 additions and 61 deletions
|
|
@ -82,18 +82,6 @@ MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int in
|
||||||
*/
|
*/
|
||||||
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
||||||
|
|
||||||
/*!
|
|
||||||
* %brief Draws a text
|
|
||||||
* %param handle Widget
|
|
||||||
* %param point Center point of the text
|
|
||||||
* %param text Text
|
|
||||||
* %param bold Bold
|
|
||||||
* %param align Align
|
|
||||||
* %param color Color
|
|
||||||
* %param bgcolor Background color
|
|
||||||
*/
|
|
||||||
MWDECL void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color, MwLLColor bgcolor);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* %brief Creates a pixmap from image
|
* %brief Creates a pixmap from image
|
||||||
* %param handle Widget
|
* %param handle Widget
|
||||||
|
|
@ -145,15 +133,6 @@ MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int
|
||||||
*/
|
*/
|
||||||
MWDECL MwLLPixmap MwLoadXPM(MwWidget handle, char** data);
|
MWDECL MwLLPixmap MwLoadXPM(MwWidget handle, char** data);
|
||||||
|
|
||||||
/*!
|
|
||||||
* %brief Creates a pixmap from XPM data with background
|
|
||||||
* %param handle Widget
|
|
||||||
* %param data Data
|
|
||||||
* %param bgcolor RGBA data for background
|
|
||||||
* %return Pixmap
|
|
||||||
*/
|
|
||||||
MWDECL MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor);
|
|
||||||
|
|
||||||
/* color.c */
|
/* color.c */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
48
src/draw.c
48
src/draw.c
|
|
@ -363,12 +363,6 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
MwLLColor bg = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
|
||||||
MwDrawTextEx(handle, point, text, bold, align, color, bg);
|
|
||||||
MwLLFreeColor(bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color, MwLLColor bgcolor) {
|
|
||||||
int i = 0, x, y, sx, sy;
|
int i = 0, x, y, sx, sy;
|
||||||
int tw = MwTextWidth(handle, text);
|
int tw = MwTextWidth(handle, text);
|
||||||
int th = MwTextHeight(handle, text);
|
int th = MwTextHeight(handle, text);
|
||||||
|
|
@ -400,10 +394,10 @@ void MwDrawTextEx(MwWidget handle, MwPoint* point, const char* text, int bold, i
|
||||||
ppx[2] = color->blue;
|
ppx[2] = color->blue;
|
||||||
ppx[3] = 255;
|
ppx[3] = 255;
|
||||||
} else {
|
} else {
|
||||||
ppx[0] = bgcolor->red;
|
ppx[0] = 0;
|
||||||
ppx[1] = bgcolor->green;
|
ppx[1] = 0;
|
||||||
ppx[2] = bgcolor->blue;
|
ppx[2] = 0;
|
||||||
ppx[3] = 255;
|
ppx[3] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -604,26 +598,9 @@ 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;
|
||||||
MwLLColor bg = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
|
||||||
unsigned char* out = malloc(width * height * 4);
|
|
||||||
int y, x;
|
|
||||||
for(y = 0; y < height; y++) {
|
|
||||||
for(x = 0; x < width; x++) {
|
|
||||||
unsigned char* pin = &rgb[(y * width + x) * 4];
|
|
||||||
unsigned char* pout = &out[(y * width + x) * 4];
|
|
||||||
pout[0] = pin[0] * (pin[3] / 255.0) + bg->red * (1.0 - pin[3] / 255.0);
|
|
||||||
pout[1] = pin[1] * (pin[3] / 255.0) + bg->green * (1.0 - pin[3] / 255.0);
|
|
||||||
pout[2] = pin[2] * (pin[3] / 255.0) + bg->blue * (1.0 - pin[3] / 255.0);
|
|
||||||
pout[3] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLFreeColor(bg);
|
|
||||||
|
|
||||||
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||||
|
|
||||||
free(out);
|
|
||||||
|
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -642,7 +619,7 @@ typedef struct color {
|
||||||
int a;
|
int a;
|
||||||
} color_t;
|
} color_t;
|
||||||
|
|
||||||
MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) {
|
MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
|
||||||
int col, row, colors, cpp;
|
int col, row, colors, cpp;
|
||||||
unsigned char* rgb;
|
unsigned char* rgb;
|
||||||
MwLLPixmap px;
|
MwLLPixmap px;
|
||||||
|
|
@ -665,10 +642,10 @@ MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) {
|
||||||
shput(c, k, v);
|
shput(c, k, v);
|
||||||
ind = shgeti(c, k);
|
ind = shgeti(c, k);
|
||||||
|
|
||||||
c[ind].r = bgcolor[0];
|
c[ind].r = 0;
|
||||||
c[ind].g = bgcolor[1];
|
c[ind].g = 0;
|
||||||
c[ind].b = bgcolor[2];
|
c[ind].b = 0;
|
||||||
c[ind].a = bgcolor[3];
|
c[ind].a = 0;
|
||||||
} else {
|
} else {
|
||||||
MwLLColor color = MwParseColor(handle, v);
|
MwLLColor color = MwParseColor(handle, v);
|
||||||
|
|
||||||
|
|
@ -714,10 +691,3 @@ MwLLPixmap MwLoadXPMEx(MwWidget handle, char** data, unsigned char* bgcolor) {
|
||||||
|
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
|
|
||||||
unsigned char rgba[4];
|
|
||||||
memset(rgba, 0, 4);
|
|
||||||
|
|
||||||
return MwLoadXPMEx(handle, data, rgba);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ static void frame_draw(MwWidget handle) {
|
||||||
MwDrawRect(handle, &r2, text);
|
MwDrawRect(handle, &r2, text);
|
||||||
}
|
}
|
||||||
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
||||||
MwDrawTextEx(handle, &p, lb->list[i], 0, MwALIGNMENT_BEGINNING, selected ? base : text, selected ? text : base);
|
MwDrawText(handle, &p, lb->list[i], 0, MwALIGNMENT_BEGINNING, selected ? base : text);
|
||||||
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue