frame
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@68 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
d15ecd71ec
commit
99c28db60d
9 changed files with 82 additions and 30 deletions
|
|
@ -16,7 +16,7 @@ E_LDFLAGS = $(LDFLAGS) -Lsrc
|
||||||
E_LIBS = $(LIBS) -lMw
|
E_LIBS = $(LIBS) -lMw
|
||||||
|
|
||||||
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o
|
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o
|
||||||
L_OBJS += src/window.o src/button.o src/opengl.o
|
L_OBJS += src/window.o src/button.o src/opengl.o src/frame.o
|
||||||
|
|
||||||
ifeq ($(TARGET),NetBSD)
|
ifeq ($(TARGET),NetBSD)
|
||||||
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
|
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
MwWidget window, button, button2, button3, button4;
|
MwWidget window, button, button2, button3, button4;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* this demo does not work well on windows */
|
/* this demo does not work well on windows */
|
||||||
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||||
|
|
||||||
MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
||||||
MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||||
|
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border);
|
||||||
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor color);
|
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor color);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
18
include/Mw/Frame.h
Normal file
18
include/Mw/Frame.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
/* $Id$ */
|
||||||
|
#ifndef __MW_FRAME_H__
|
||||||
|
#define __MW_FRAME_H__
|
||||||
|
|
||||||
|
#include <Mw/MachDep.h>
|
||||||
|
#include <Mw/TypeDefs.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MWDECL MwClass MwFrameClass;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <Mw/Window.h>
|
#include <Mw/Window.h>
|
||||||
#include <Mw/Button.h>
|
#include <Mw/Button.h>
|
||||||
|
#include <Mw/Frame.h>
|
||||||
#include <Mw/OpenGL.h>
|
#include <Mw/OpenGL.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
57
src/draw.c
57
src/draw.c
|
|
@ -61,49 +61,54 @@ void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
|
const int border = 2;
|
||||||
|
|
||||||
|
MwDrawFrameEx(handle, rect, color, invert, border);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||||
MwPoint p[6];
|
MwPoint p[6];
|
||||||
const int diff = 128;
|
const int diff = 128;
|
||||||
const int border = 2;
|
|
||||||
MwLLColor darker = MwLLAllocColor(handle->lowlevel, color->red - diff, color->green - diff, color->blue - diff);
|
MwLLColor darker = MwLLAllocColor(handle->lowlevel, color->red - diff, color->green - diff, color->blue - diff);
|
||||||
MwLLColor lighter = MwLLAllocColor(handle->lowlevel, color->red + diff, color->green + diff, color->blue + diff);
|
MwLLColor lighter = MwLLAllocColor(handle->lowlevel, color->red + diff, color->green + diff, color->blue + diff);
|
||||||
|
|
||||||
p[0].x = 0;
|
p[0].x = rect->x;
|
||||||
p[0].y = 0;
|
p[0].y = rect->y;
|
||||||
|
|
||||||
p[1].x = 0 + rect->width;
|
p[1].x = rect->x + rect->width;
|
||||||
p[1].y = 0;
|
p[1].y = rect->y;
|
||||||
|
|
||||||
p[2].x = 0 + rect->width - border;
|
p[2].x = rect->x + rect->width - border;
|
||||||
p[2].y = 0 + border;
|
p[2].y = rect->y + border;
|
||||||
|
|
||||||
p[3].x = 0 + border;
|
p[3].x = rect->x + border;
|
||||||
p[3].y = 0 + border;
|
p[3].y = rect->y + border;
|
||||||
|
|
||||||
p[4].x = 0 + border;
|
p[4].x = rect->x + border;
|
||||||
p[4].y = 0 + rect->height - border;
|
p[4].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
p[5].x = 0;
|
p[5].x = rect->x;
|
||||||
p[5].y = 0 + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
||||||
|
|
||||||
p[0].x = 0 + rect->width;
|
p[0].x = rect->x + rect->width;
|
||||||
p[0].y = 0;
|
p[0].y = rect->y;
|
||||||
|
|
||||||
p[1].x = 0 + rect->width - border;
|
p[1].x = rect->x + rect->width - border;
|
||||||
p[1].y = 0 + border;
|
p[1].y = rect->y + border;
|
||||||
|
|
||||||
p[2].x = 0 + rect->width - border;
|
p[2].x = rect->x + rect->width - border;
|
||||||
p[2].y = 0 + rect->height - border;
|
p[2].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
p[3].x = 0 + border;
|
p[3].x = rect->x + border;
|
||||||
p[3].y = 0 + rect->height - border;
|
p[3].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
p[4].x = 0;
|
p[4].x = rect->x;
|
||||||
p[4].y = 0 + rect->height;
|
p[4].y = rect->y + rect->height;
|
||||||
|
|
||||||
p[5].x = 0 + rect->width;
|
p[5].x = rect->x + rect->width;
|
||||||
p[5].y = 0 + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||||
|
|
||||||
|
|
@ -137,6 +142,6 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor col
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sx += 8 * sc;
|
sx += fw * sc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
src/frame.c
Normal file
30
src/frame.c
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* $Id$ */
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
static void create(MwWidget handle) {
|
||||||
|
MwSetDefault(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw(MwWidget handle) {
|
||||||
|
MwRect r;
|
||||||
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
|
|
||||||
|
r.x = 0;
|
||||||
|
r.y = 0;
|
||||||
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
MwDrawFrameEx(handle, &r, base, 1, 1);
|
||||||
|
MwDrawFrameEx(handle, &r, base, 0, 1);
|
||||||
|
MwDrawRect(handle, &r, base);
|
||||||
|
|
||||||
|
MwLLFreeColor(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwClassRec MwFrameClassRec = {
|
||||||
|
create, /* create */
|
||||||
|
NULL, /* destroy */
|
||||||
|
draw, /* draw */
|
||||||
|
NULL /* click */
|
||||||
|
};
|
||||||
|
MwClass MwFrameClass = &MwFrameClassRec;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue