mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 03:43:29 +00:00
things
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@36 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
#ifndef __MILSKO_BUTTON_H__
|
#ifndef __MILSKO_BUTTON_H__
|
||||||
#define __MILSKO_BUTTON_H__
|
#define __MILSKO_BUTTON_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
MILSKODECL MilskoClass MilskoButtonClass;
|
MILSKODECL MwClass MwButtonClass;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,30 +2,30 @@
|
|||||||
#ifndef __MILSKO_CORE_H__
|
#ifndef __MILSKO_CORE_H__
|
||||||
#define __MILSKO_CORE_H__
|
#define __MILSKO_CORE_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
|
|
||||||
#define MilskoDispatch(x, y) \
|
#define MwDispatch(x, y) \
|
||||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||||
|
|
||||||
MILSKODECL MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height);
|
MILSKODECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height);
|
||||||
MILSKODECL MilskoWidget MilskoVaCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
|
MILSKODECL MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
|
||||||
MILSKODECL MilskoWidget MilskoVaListCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
|
MILSKODECL MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
|
||||||
MILSKODECL void MilskoDestroyWidget(MilskoWidget handle);
|
MILSKODECL void MwDestroyWidget(MwWidget handle);
|
||||||
|
|
||||||
MILSKODECL void MilskoLoop(MilskoWidget handle);
|
MILSKODECL void MwLoop(MwWidget handle);
|
||||||
MILSKODECL void MilskoStep(MilskoWidget handle);
|
MILSKODECL void MwStep(MwWidget handle);
|
||||||
MILSKODECL int MilskoPending(MilskoWidget handle);
|
MILSKODECL int MwPending(MwWidget handle);
|
||||||
|
|
||||||
MILSKODECL void MilskoSetInteger(MilskoWidget handle, const char* key, int n);
|
MILSKODECL void MwSetInteger(MwWidget handle, const char* key, int n);
|
||||||
MILSKODECL void MilskoSetText(MilskoWidget handle, const char* key, const char* value);
|
MILSKODECL void MwSetText(MwWidget handle, const char* key, const char* value);
|
||||||
MILSKODECL int MilskoGetInteger(MilskoWidget handle, const char* key);
|
MILSKODECL int MwGetInteger(MwWidget handle, const char* key);
|
||||||
MILSKODECL const char* MilskoGetText(MilskoWidget handle, const char* key);
|
MILSKODECL const char* MwGetText(MwWidget handle, const char* key);
|
||||||
MILSKODECL void MilskoSetDefault(MilskoWidget handle);
|
MILSKODECL void MwSetDefault(MwWidget handle);
|
||||||
MILSKODECL void MilskoVaApply(MilskoWidget handle, ...);
|
MILSKODECL void MwVaApply(MwWidget handle, ...);
|
||||||
MILSKODECL void MilskoVaListApply(MilskoWidget handle, va_list va);
|
MILSKODECL void MwVaListApply(MwWidget handle, va_list va);
|
||||||
|
|
||||||
MILSKODECL void MilskoAddUserHandler(MilskoWidget handle, const char* key, MilskoUserHandler handler, void* user_data);
|
MILSKODECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data);
|
||||||
MILSKODECL void MilskoDispatchUserHandler(MilskoWidget handle, const char* key, void* handler_data);
|
MILSKODECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#ifndef __MILSKO_DEFAULT_H__
|
#ifndef __MILSKO_DEFAULT_H__
|
||||||
#define __MILSKO_DEFAULT_H__
|
#define __MILSKO_DEFAULT_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
MILSKODECL const char* MilskoDefaultBackground;
|
MILSKODECL const char* MwDefaultBackground;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
#ifndef __MILSKO_DRAW_H__
|
#ifndef __MILSKO_DRAW_H__
|
||||||
#define __MILSKO_DRAW_H__
|
#define __MILSKO_DRAW_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Milsko/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
|
||||||
MILSKODECL MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text);
|
MILSKODECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||||
|
|
||||||
MILSKODECL void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color);
|
MILSKODECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
||||||
MILSKODECL void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, int invert);
|
MILSKODECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,23 +2,23 @@
|
|||||||
#ifndef __MILSKO_GDI_H__
|
#ifndef __MILSKO_GDI_H__
|
||||||
#define __MILSKO_GDI_H__
|
#define __MILSKO_GDI_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
typedef struct _MwLL * MwLL, MwLLRec;
|
||||||
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
|
||||||
|
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Milsko/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
struct _MilskoLL {
|
struct _MwLL {
|
||||||
void* user;
|
void* user;
|
||||||
|
|
||||||
MilskoLLHandler handler;
|
MwLLHandler handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoColor {
|
struct _MwColor {
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
int blue;
|
int blue;
|
||||||
|
|||||||
@@ -2,57 +2,57 @@
|
|||||||
#ifndef __MILSKO_LOWLEVEL_H__
|
#ifndef __MILSKO_LOWLEVEL_H__
|
||||||
#define __MILSKO_LOWLEVEL_H__
|
#define __MILSKO_LOWLEVEL_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MilskoLLHandler *MilskoLLHandler, MilskoLLHandlerRec;
|
typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec;
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
typedef struct _MwLL * MwLL, MwLLRec;
|
||||||
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
|
||||||
#else
|
#else
|
||||||
typedef void* MilskoLL;
|
typedef void* MwLL;
|
||||||
typedef void* MilskoLLColor;
|
typedef void* MwLLColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
#include <Milsko/X11.h>
|
#include <Mw/X11.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_GDI
|
#ifdef USE_GDI
|
||||||
#include <Milsko/GDI.h>
|
#include <Mw/GDI.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
|
|
||||||
#define MilskoLLDispatch(x, y) \
|
#define MwLLDispatch(x, y) \
|
||||||
if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x)
|
if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x)
|
||||||
|
|
||||||
struct _MilskoLLHandler {
|
struct _MwLLHandler {
|
||||||
void (*draw)(MilskoLL handle);
|
void (*draw)(MwLL handle);
|
||||||
void (*up)(MilskoLL handle);
|
void (*up)(MwLL handle);
|
||||||
void (*down)(MilskoLL handle);
|
void (*down)(MwLL handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* lowlevel.c, common part */
|
/* lowlevel.c, common part */
|
||||||
MILSKODECL void MilskoLLCreateCommon(MilskoLL handle);
|
MILSKODECL void MwLLCreateCommon(MwLL handle);
|
||||||
MILSKODECL void MilskoLLDestroyCommon(MilskoLL handle);
|
MILSKODECL void MwLLDestroyCommon(MwLL handle);
|
||||||
|
|
||||||
/* driver-specific */
|
/* driver-specific */
|
||||||
MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height);
|
MILSKODECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height);
|
||||||
MILSKODECL void MilskoLLDestroy(MilskoLL handle);
|
MILSKODECL void MwLLDestroy(MwLL handle);
|
||||||
|
|
||||||
MILSKODECL void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, MilskoLLColor color);
|
MILSKODECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
||||||
|
|
||||||
MILSKODECL MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b);
|
MILSKODECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b);
|
||||||
MILSKODECL void MilskoLLFreeColor(MilskoLLColor color);
|
MILSKODECL void MwLLFreeColor(MwLLColor color);
|
||||||
|
|
||||||
MILSKODECL void MilskoLLGetXYWH(MilskoLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
MILSKODECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||||
MILSKODECL void MilskoLLSetXY(MilskoLL handle, int x, int y);
|
MILSKODECL void MwLLSetXY(MwLL handle, int x, int y);
|
||||||
MILSKODECL void MilskoLLSetWH(MilskoLL handle, int w, int h);
|
MILSKODECL void MwLLSetWH(MwLL handle, int w, int h);
|
||||||
|
|
||||||
MILSKODECL void MilskoLLSetTitle(MilskoLL handle, const char* title);
|
MILSKODECL void MwLLSetTitle(MwLL handle, const char* title);
|
||||||
|
|
||||||
MILSKODECL int MilskoLLPending(MilskoLL handle);
|
MILSKODECL int MwLLPending(MwLL handle);
|
||||||
MILSKODECL void MilskoLLNextEvent(MilskoLL handle);
|
MILSKODECL void MwLLNextEvent(MwLL handle);
|
||||||
MILSKODECL void MilskoLLSleep(int ms);
|
MILSKODECL void MwLLSleep(int ms);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
#ifndef __MILSKO_MILSKO_H__
|
#ifndef __MILSKO_MILSKO_H__
|
||||||
#define __MILSKO_MILSKO_H__
|
#define __MILSKO_MILSKO_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Milsko/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
#include <Milsko/StringDefs.h>
|
#include <Mw/StringDefs.h>
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Milsko/Core.h>
|
#include <Mw/Core.h>
|
||||||
#include <Milsko/Default.h>
|
#include <Mw/Default.h>
|
||||||
#include <Milsko/Draw.h>
|
#include <Mw/Draw.h>
|
||||||
|
|
||||||
#include <Milsko/Window.h>
|
#include <Mw/Window.h>
|
||||||
#include <Milsko/Button.h>
|
#include <Mw/Button.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
#ifndef __MILSKO_STRINGDEFS_H__
|
#ifndef __MILSKO_STRINGDEFS_H__
|
||||||
#define __MILSKO_STRINGDEFS_H__
|
#define __MILSKO_STRINGDEFS_H__
|
||||||
|
|
||||||
#define MilskoNx "Ix"
|
#define MwNx "Ix"
|
||||||
#define MilskoNy "Iy"
|
#define MwNy "Iy"
|
||||||
#define MilskoNwidth "Iwidth"
|
#define MwNwidth "Iwidth"
|
||||||
#define MilskoNheight "Iheight"
|
#define MwNheight "Iheight"
|
||||||
|
|
||||||
#define MilskoNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MilskoNbackground "Sbackground"
|
#define MwNbackground "Sbackground"
|
||||||
|
|
||||||
#define MilskoNactivateHandler "Cactivate"
|
#define MwNactivateHandler "Cactivate"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,77 +2,77 @@
|
|||||||
#ifndef __MILSKO_TYPEDEFS_H__
|
#ifndef __MILSKO_TYPEDEFS_H__
|
||||||
#define __MILSKO_TYPEDEFS_H__
|
#define __MILSKO_TYPEDEFS_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MilskoClass * MilskoClass, MilskoClassRec;
|
typedef struct _MwClass * MwClass, MwClassRec;
|
||||||
typedef struct _MilskoPoint MilskoPoint;
|
typedef struct _MwPoint MwPoint;
|
||||||
typedef struct _MilskoRect MilskoRect;
|
typedef struct _MwRect MwRect;
|
||||||
typedef struct _MilskoIntegerKeyValue MilskoIntegerKeyValue;
|
typedef struct _MwIntegerKeyValue MwIntegerKeyValue;
|
||||||
typedef struct _MilskoTextKeyValue MilskoTextKeyValue;
|
typedef struct _MwTextKeyValue MwTextKeyValue;
|
||||||
typedef struct _MilskoUserHandlerKeyValue MilskoUserHandlerKeyValue;
|
typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue;
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
typedef struct _MilskoWidget *MilskoWidget, MilskoWidgetRec;
|
typedef struct _MwWidget *MwWidget, MwWidgetRec;
|
||||||
#else
|
#else
|
||||||
typedef void* MilskoWidget;
|
typedef void* MwWidget;
|
||||||
#endif
|
#endif
|
||||||
typedef void (*MilskoHandler)(MilskoWidget handle);
|
typedef void (*MwHandler)(MwWidget handle);
|
||||||
typedef void (*MilskoUserHandler)(MilskoWidget handle, void* user_data, void* call_data);
|
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
#include <Milsko/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _MilskoPoint {
|
struct _MwPoint {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoRect {
|
struct _MwRect {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoTextKeyValue {
|
struct _MwTextKeyValue {
|
||||||
char* key;
|
char* key;
|
||||||
char* value;
|
char* value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoIntegerKeyValue {
|
struct _MwIntegerKeyValue {
|
||||||
char* key;
|
char* key;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoUserHandlerKeyValue {
|
struct _MwUserHandlerKeyValue {
|
||||||
char* key;
|
char* key;
|
||||||
void* user_data;
|
void* user_data;
|
||||||
MilskoUserHandler value;
|
MwUserHandler value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
struct _MilskoWidget {
|
struct _MwWidget {
|
||||||
char* name;
|
char* name;
|
||||||
|
|
||||||
MilskoLL lowlevel;
|
MwLL lowlevel;
|
||||||
MilskoWidget parent;
|
MwWidget parent;
|
||||||
MilskoWidget* children;
|
MwWidget* children;
|
||||||
MilskoClass class;
|
MwClass class;
|
||||||
|
|
||||||
int pressed;
|
int pressed;
|
||||||
|
|
||||||
MilskoIntegerKeyValue* integer;
|
MwIntegerKeyValue* integer;
|
||||||
MilskoTextKeyValue* text;
|
MwTextKeyValue* text;
|
||||||
MilskoUserHandlerKeyValue* handler;
|
MwUserHandlerKeyValue* handler;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _MilskoClass {
|
struct _MwClass {
|
||||||
void* opaque;
|
void* opaque;
|
||||||
MilskoHandler create;
|
MwHandler create;
|
||||||
MilskoHandler destroy;
|
MwHandler destroy;
|
||||||
MilskoHandler draw;
|
MwHandler draw;
|
||||||
MilskoHandler click;
|
MwHandler click;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#ifndef __MILSKO_WINDOW_H__
|
#ifndef __MILSKO_WINDOW_H__
|
||||||
#define __MILSKO_WINDOW_H__
|
#define __MILSKO_WINDOW_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
MILSKODECL MilskoClass MilskoWindowClass;
|
MILSKODECL MwClass MwWindowClass;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,28 +2,28 @@
|
|||||||
#ifndef __MILSKO_X11_H__
|
#ifndef __MILSKO_X11_H__
|
||||||
#define __MILSKO_X11_H__
|
#define __MILSKO_X11_H__
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
typedef struct _MwLL * MwLL, MwLLRec;
|
||||||
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
|
||||||
|
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Milsko/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
struct _MilskoLL {
|
struct _MwLL {
|
||||||
Display* display;
|
Display* display;
|
||||||
Window window;
|
Window window;
|
||||||
GC gc;
|
GC gc;
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
void* user;
|
void* user;
|
||||||
|
|
||||||
MilskoLLHandler handler;
|
MwLLHandler handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MilskoLLColor {
|
struct _MwLLColor {
|
||||||
unsigned long pixel;
|
unsigned long pixel;
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
|
|||||||
26
src/button.c
26
src/button.c
@@ -1,32 +1,32 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
static void create(MilskoWidget handle) {
|
static void create(MwWidget handle) {
|
||||||
MilskoSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MilskoWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MilskoRect r;
|
MwRect r;
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = MilskoGetInteger(handle, MilskoNwidth);
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
r.height = MilskoGetInteger(handle, MilskoNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MilskoDrawFrame(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)), handle->pressed);
|
MwDrawFrame(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground)), handle->pressed);
|
||||||
|
|
||||||
MilskoDrawRect(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)));
|
MwDrawRect(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void click(MilskoWidget handle) {
|
static void click(MwWidget handle) {
|
||||||
MilskoDispatchUserHandler(handle, MilskoNactivateHandler, NULL);
|
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoClassRec MilskoButtonClassRec = {
|
MwClassRec MwButtonClassRec = {
|
||||||
NULL, /* opaque */
|
NULL, /* opaque */
|
||||||
create, /* create */
|
create, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
click /* click */
|
click /* click */
|
||||||
};
|
};
|
||||||
MilskoClass MilskoButtonClass = &MilskoButtonClassRec;
|
MwClass MwButtonClass = &MwButtonClassRec;
|
||||||
|
|||||||
126
src/core.c
126
src/core.c
@@ -1,34 +1,34 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
#include "stb_ds.h"
|
#include "stb_ds.h"
|
||||||
|
|
||||||
static void lldrawhandler(MilskoLL handle) {
|
static void lldrawhandler(MwLL handle) {
|
||||||
MilskoWidget h = (MilskoWidget)handle->user;
|
MwWidget h = (MwWidget)handle->user;
|
||||||
MilskoDispatch(h, draw);
|
MwDispatch(h, draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lluphandler(MilskoLL handle) {
|
static void lluphandler(MwLL handle) {
|
||||||
MilskoWidget h = (MilskoWidget)handle->user;
|
MwWidget h = (MwWidget)handle->user;
|
||||||
h->pressed = 0;
|
h->pressed = 0;
|
||||||
|
|
||||||
MilskoDispatch(h, click);
|
MwDispatch(h, click);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lldownhandler(MilskoLL handle) {
|
static void lldownhandler(MwLL handle) {
|
||||||
MilskoWidget h = (MilskoWidget)handle->user;
|
MwWidget h = (MwWidget)handle->user;
|
||||||
h->pressed = 1;
|
h->pressed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
MilskoWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
h->name = malloc(strlen(name) + 1);
|
h->name = malloc(strlen(name) + 1);
|
||||||
strcpy(h->name, name);
|
strcpy(h->name, name);
|
||||||
|
|
||||||
h->parent = parent;
|
h->parent = parent;
|
||||||
h->children = NULL;
|
h->children = NULL;
|
||||||
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
||||||
h->class = class;
|
h->class = class;
|
||||||
h->pressed = 0;
|
h->pressed = 0;
|
||||||
|
|
||||||
@@ -46,42 +46,42 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
|||||||
shdefault(h->text, NULL);
|
shdefault(h->text, NULL);
|
||||||
shdefault(h->handler, NULL);
|
shdefault(h->handler, NULL);
|
||||||
|
|
||||||
MilskoDispatch(h, create);
|
MwDispatch(h, create);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoWidget MilskoVaCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, ...) {
|
MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) {
|
||||||
MilskoWidget h;
|
MwWidget h;
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
va_start(va, height);
|
va_start(va, height);
|
||||||
h = MilskoVaListCreateWidget(class, name, parent, x, y, width, height, va);
|
h = MwVaListCreateWidget(class, name, parent, x, y, width, height, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoWidget MilskoVaListCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) {
|
MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) {
|
||||||
MilskoWidget h;
|
MwWidget h;
|
||||||
|
|
||||||
h = MilskoCreateWidget(class, name, parent, x, y, width, height);
|
h = MwCreateWidget(class, name, parent, x, y, width, height);
|
||||||
MilskoVaListApply(h, va);
|
MwVaListApply(h, va);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoDestroyWidget(MilskoWidget handle) {
|
void MwDestroyWidget(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
MilskoDispatch(handle, destroy);
|
MwDispatch(handle, destroy);
|
||||||
|
|
||||||
free(handle->name);
|
free(handle->name);
|
||||||
|
|
||||||
if(handle->children != NULL) {
|
if(handle->children != NULL) {
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
if(handle->children[i] == handle) {
|
if(handle->children[i] == handle) {
|
||||||
MilskoDestroyWidget(handle->children[i]);
|
MwDestroyWidget(handle->children[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ void MilskoDestroyWidget(MilskoWidget handle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MilskoLLDestroy(handle->lowlevel);
|
MwLLDestroy(handle->lowlevel);
|
||||||
|
|
||||||
shfree(handle->integer);
|
shfree(handle->integer);
|
||||||
|
|
||||||
@@ -110,49 +110,49 @@ void MilskoDestroyWidget(MilskoWidget handle) {
|
|||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoStep(MilskoWidget handle) {
|
void MwStep(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < arrlen(handle->children); i++) MilskoStep(handle->children[i]);
|
for(i = 0; i < arrlen(handle->children); i++) MwStep(handle->children[i]);
|
||||||
MilskoLLNextEvent(handle->lowlevel);
|
MwLLNextEvent(handle->lowlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MilskoPending(MilskoWidget handle) {
|
int MwPending(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
if(MilskoPending(handle->children[i])) return 1;
|
if(MwPending(handle->children[i])) return 1;
|
||||||
}
|
}
|
||||||
return MilskoLLPending(handle->lowlevel);
|
return MwLLPending(handle->lowlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLoop(MilskoWidget handle) {
|
void MwLoop(MwWidget handle) {
|
||||||
while(1) {
|
while(1) {
|
||||||
MilskoStep(handle);
|
MwStep(handle);
|
||||||
MilskoLLSleep(5);
|
MwLLSleep(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoSetInteger(MilskoWidget handle, const char* key, int n) {
|
void MwSetInteger(MwWidget handle, const char* key, int n) {
|
||||||
int xy = 0;
|
int xy = 0;
|
||||||
int wh = 0;
|
int wh = 0;
|
||||||
if((xy = (strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0)) || (wh = (strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0))) {
|
if((xy = (strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0)) || (wh = (strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0))) {
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
|
|
||||||
MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
MwLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
||||||
if(strcmp(key, MilskoNx) == 0) x = n;
|
if(strcmp(key, MwNx) == 0) x = n;
|
||||||
if(strcmp(key, MilskoNy) == 0) y = n;
|
if(strcmp(key, MwNy) == 0) y = n;
|
||||||
if(strcmp(key, MilskoNwidth) == 0) w = n;
|
if(strcmp(key, MwNwidth) == 0) w = n;
|
||||||
if(strcmp(key, MilskoNheight) == 0) h = n;
|
if(strcmp(key, MwNheight) == 0) h = n;
|
||||||
if(xy) MilskoLLSetXY(handle->lowlevel, x, y);
|
if(xy) MwLLSetXY(handle->lowlevel, x, y);
|
||||||
if(wh) MilskoLLSetWH(handle->lowlevel, w, h);
|
if(wh) MwLLSetWH(handle->lowlevel, w, h);
|
||||||
} else {
|
} else {
|
||||||
shput(handle->integer, key, n);
|
shput(handle->integer, key, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoSetText(MilskoWidget handle, const char* key, const char* value) {
|
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||||
if(strcmp(key, MilskoNtitle) == 0) {
|
if(strcmp(key, MwNtitle) == 0) {
|
||||||
MilskoLLSetTitle(handle->lowlevel, value);
|
MwLLSetTitle(handle->lowlevel, value);
|
||||||
} else {
|
} else {
|
||||||
char* v = malloc(strlen(value) + 1);
|
char* v = malloc(strlen(value) + 1);
|
||||||
strcpy(v, value);
|
strcpy(v, value);
|
||||||
@@ -163,47 +163,47 @@ void MilskoSetText(MilskoWidget handle, const char* key, const char* value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MilskoGetInteger(MilskoWidget handle, const char* key) {
|
int MwGetInteger(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0 || strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0) {
|
if(strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0 || strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0) {
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
|
|
||||||
MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
MwLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
||||||
|
|
||||||
if(strcmp(key, MilskoNx) == 0) return x;
|
if(strcmp(key, MwNx) == 0) return x;
|
||||||
if(strcmp(key, MilskoNy) == 0) return y;
|
if(strcmp(key, MwNy) == 0) return y;
|
||||||
if(strcmp(key, MilskoNwidth) == 0) return w;
|
if(strcmp(key, MwNwidth) == 0) return w;
|
||||||
if(strcmp(key, MilskoNheight) == 0) return h;
|
if(strcmp(key, MwNheight) == 0) return h;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return shget(handle->integer, key);
|
return shget(handle->integer, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MilskoGetText(MilskoWidget handle, const char* key) {
|
const char* MwGetText(MwWidget handle, const char* key) {
|
||||||
return shget(handle->text, key);
|
return shget(handle->text, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoVaApply(MilskoWidget handle, ...) {
|
void MwVaApply(MwWidget handle, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
va_start(va, handle);
|
va_start(va, handle);
|
||||||
MilskoVaListApply(handle, va);
|
MwVaListApply(handle, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoVaListApply(MilskoWidget handle, va_list va) {
|
void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
char* key;
|
char* key;
|
||||||
|
|
||||||
while((key = va_arg(va, char*)) != NULL) {
|
while((key = va_arg(va, char*)) != NULL) {
|
||||||
if(key[0] == 'I') {
|
if(key[0] == 'I') {
|
||||||
int n = va_arg(va, int);
|
int n = va_arg(va, int);
|
||||||
MilskoSetInteger(handle, key, n);
|
MwSetInteger(handle, key, n);
|
||||||
} else if(key[0] == 'S') {
|
} else if(key[0] == 'S') {
|
||||||
char* t = va_arg(va, char*);
|
char* t = va_arg(va, char*);
|
||||||
MilskoSetText(handle, key, t);
|
MwSetText(handle, key, t);
|
||||||
} else if(key[0] == 'C') {
|
} else if(key[0] == 'C') {
|
||||||
MilskoUserHandler h = va_arg(va, MilskoUserHandler);
|
MwUserHandler h = va_arg(va, MwUserHandler);
|
||||||
int ind;
|
int ind;
|
||||||
|
|
||||||
shput(handle->handler, key, h);
|
shput(handle->handler, key, h);
|
||||||
@@ -213,18 +213,18 @@ void MilskoVaListApply(MilskoWidget handle, va_list va) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoSetDefault(MilskoWidget handle) {
|
void MwSetDefault(MwWidget handle) {
|
||||||
MilskoSetText(handle, MilskoNbackground, MilskoDefaultBackground);
|
MwSetText(handle, MwNbackground, MwDefaultBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoDispatchUserHandler(MilskoWidget handle, const char* key, void* handler_data) {
|
void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data) {
|
||||||
int ind = shgeti(handle->handler, key);
|
int ind = shgeti(handle->handler, key);
|
||||||
if(ind == -1) return;
|
if(ind == -1) return;
|
||||||
|
|
||||||
handle->handler[ind].value(handle, handle->handler[ind].user_data, handler_data);
|
handle->handler[ind].value(handle, handle->handler[ind].user_data, handler_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoAddUserHandler(MilskoWidget handle, const char* key, MilskoUserHandler handler, void* user_data) {
|
void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data) {
|
||||||
int ind;
|
int ind;
|
||||||
|
|
||||||
shput(handle->handler, key, handler);
|
shput(handle->handler, key, handler);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
const char* MilskoDefaultBackground = "#ddd";
|
const char* MwDefaultBackground = "#ddd";
|
||||||
|
|||||||
28
src/draw.c
28
src/draw.c
@@ -1,5 +1,5 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
static int hex(const char* txt, int len) {
|
static int hex(const char* txt, int len) {
|
||||||
int i;
|
int i;
|
||||||
@@ -20,7 +20,7 @@ static int hex(const char* txt, int len) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) {
|
MwLLColor MwParseColor(MwWidget handle, const char* text) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int g = 0;
|
int g = 0;
|
||||||
int b = 0;
|
int b = 0;
|
||||||
@@ -39,11 +39,11 @@ MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) {
|
|||||||
b = hex(text + 5, 2);
|
b = hex(text + 5, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MilskoLLAllocColor(handle->lowlevel, r, g, b);
|
return MwLLAllocColor(handle->lowlevel, r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color) {
|
void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||||
MilskoPoint p[4];
|
MwPoint p[4];
|
||||||
|
|
||||||
p[0].x = rect->x;
|
p[0].x = rect->x;
|
||||||
p[0].y = rect->y;
|
p[0].y = rect->y;
|
||||||
@@ -57,15 +57,15 @@ void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color)
|
|||||||
p[3].x = rect->x;
|
p[3].x = rect->x;
|
||||||
p[3].y = rect->y + rect->height;
|
p[3].y = rect->y + rect->height;
|
||||||
|
|
||||||
MilskoLLPolygon(handle->lowlevel, p, 4, color);
|
MwLLPolygon(handle->lowlevel, p, 4, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, int invert) {
|
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
MilskoPoint p[6];
|
MwPoint p[6];
|
||||||
const int diff = 128;
|
const int diff = 128;
|
||||||
const int border = 2;
|
const int border = 2;
|
||||||
MilskoLLColor darker = MilskoLLAllocColor(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);
|
||||||
MilskoLLColor lighter = MilskoLLAllocColor(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 = rect->x;
|
p[0].x = rect->x;
|
||||||
p[0].y = rect->y;
|
p[0].y = rect->y;
|
||||||
@@ -85,7 +85,7 @@ void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color,
|
|||||||
p[5].x = rect->x;
|
p[5].x = rect->x;
|
||||||
p[5].y = rect->y + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MilskoLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
||||||
|
|
||||||
p[0].x = rect->x + rect->width;
|
p[0].x = rect->x + rect->width;
|
||||||
p[0].y = rect->y;
|
p[0].y = rect->y;
|
||||||
@@ -105,10 +105,10 @@ void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color,
|
|||||||
p[5].x = rect->x + rect->height;
|
p[5].x = rect->x + rect->height;
|
||||||
p[5].y = rect->y + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MilskoLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||||
|
|
||||||
MilskoLLFreeColor(lighter);
|
MwLLFreeColor(lighter);
|
||||||
MilskoLLFreeColor(darker);
|
MwLLFreeColor(darker);
|
||||||
|
|
||||||
rect->x += border;
|
rect->x += border;
|
||||||
rect->y += border;
|
rect->y += border;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
void MilskoLLCreateCommon(MilskoLL handle) {
|
void MwLLCreateCommon(MwLL handle) {
|
||||||
handle->handler = malloc(sizeof(*handle->handler));
|
handle->handler = malloc(sizeof(*handle->handler));
|
||||||
memset(handle->handler, 0, sizeof(*handle->handler));
|
memset(handle->handler, 0, sizeof(*handle->handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLDestroyCommon(MilskoLL handle) {
|
void MwLLDestroyCommon(MwLL handle) {
|
||||||
free(handle->handler);
|
free(handle->handler);
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/window.c
24
src/window.c
@@ -1,29 +1,29 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
static void create(MilskoWidget handle) {
|
static void create(MwWidget handle) {
|
||||||
MilskoSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MilskoWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MilskoLLColor c = MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground));
|
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MilskoRect r;
|
MwRect r;
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = MilskoGetInteger(handle, MilskoNwidth);
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
r.height = MilskoGetInteger(handle, MilskoNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
MilskoDrawRect(handle, &r, c);
|
MwDrawRect(handle, &r, c);
|
||||||
|
|
||||||
MilskoLLFreeColor(c);
|
MwLLFreeColor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoClassRec MilskoWindowClassRec = {
|
MwClassRec MwWindowClassRec = {
|
||||||
NULL, /* opaque */
|
NULL, /* opaque */
|
||||||
create, /* create */
|
create, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL /* click */
|
NULL /* click */
|
||||||
};
|
};
|
||||||
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;
|
MwClass MwWindowClass = &MwWindowClassRec;
|
||||||
|
|||||||
46
src/x11.c
46
src/x11.c
@@ -1,17 +1,17 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Mw/Mw.h>
|
||||||
|
|
||||||
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
|
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
|
|
||||||
MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
|
||||||
MilskoLL r;
|
MwLL r;
|
||||||
Window p;
|
Window p;
|
||||||
Window root;
|
Window root;
|
||||||
unsigned int border, depth;
|
unsigned int border, depth;
|
||||||
|
|
||||||
r = malloc(sizeof(*r));
|
r = malloc(sizeof(*r));
|
||||||
|
|
||||||
MilskoLLCreateCommon(r);
|
MwLLCreateCommon(r);
|
||||||
|
|
||||||
if(parent == NULL) {
|
if(parent == NULL) {
|
||||||
r->display = XOpenDisplay(NULL);
|
r->display = XOpenDisplay(NULL);
|
||||||
@@ -31,15 +31,15 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLDestroy(MilskoLL handle) {
|
void MwLLDestroy(MwLL handle) {
|
||||||
MilskoLLDestroyCommon(handle);
|
MwLLDestroyCommon(handle);
|
||||||
|
|
||||||
XFreeGC(handle->display, handle->gc);
|
XFreeGC(handle->display, handle->gc);
|
||||||
XDestroyWindow(handle->display, handle->window);
|
XDestroyWindow(handle->display, handle->window);
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, MilskoLLColor color) {
|
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
int i;
|
int i;
|
||||||
XPoint* p = malloc(sizeof(*p) * points_count);
|
XPoint* p = malloc(sizeof(*p) * points_count);
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@ void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, Mil
|
|||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b) {
|
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
|
||||||
MilskoLLColor c = malloc(sizeof(*c));
|
MwLLColor c = malloc(sizeof(*c));
|
||||||
XColor xc;
|
XColor xc;
|
||||||
|
|
||||||
if(r > 255) r = 255;
|
if(r > 255) r = 255;
|
||||||
@@ -77,26 +77,26 @@ MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLGetXYWH(MilskoLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||||
Window root;
|
Window root;
|
||||||
unsigned int border, depth;
|
unsigned int border, depth;
|
||||||
|
|
||||||
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLSetXY(MilskoLL handle, int x, int y) {
|
void MwLLSetXY(MwLL handle, int x, int y) {
|
||||||
XMoveWindow(handle->display, handle->window, x, y);
|
XMoveWindow(handle->display, handle->window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLSetWH(MilskoLL handle, int w, int h) {
|
void MwLLSetWH(MwLL handle, int w, int h) {
|
||||||
XResizeWindow(handle->display, handle->window, w, h);
|
XResizeWindow(handle->display, handle->window, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLFreeColor(MilskoLLColor color) {
|
void MwLLFreeColor(MwLLColor color) {
|
||||||
free(color);
|
free(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MilskoLLPending(MilskoLL handle) {
|
int MwLLPending(MwLL handle) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
||||||
XPutBackEvent(handle->display, &ev);
|
XPutBackEvent(handle->display, &ev);
|
||||||
@@ -105,29 +105,29 @@ int MilskoLLPending(MilskoLL handle) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLNextEvent(MilskoLL handle) {
|
void MwLLNextEvent(MwLL handle) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
||||||
if(ev.type == Expose) {
|
if(ev.type == Expose) {
|
||||||
MilskoLLDispatch(handle, draw);
|
MwLLDispatch(handle, draw);
|
||||||
} else if(ev.type == ButtonPress) {
|
} else if(ev.type == ButtonPress) {
|
||||||
if(ev.xbutton.button == Button1) {
|
if(ev.xbutton.button == Button1) {
|
||||||
MilskoLLDispatch(handle, down);
|
MwLLDispatch(handle, down);
|
||||||
MilskoLLDispatch(handle, draw);
|
MwLLDispatch(handle, draw);
|
||||||
}
|
}
|
||||||
} else if(ev.type == ButtonRelease) {
|
} else if(ev.type == ButtonRelease) {
|
||||||
if(ev.xbutton.button == Button1) {
|
if(ev.xbutton.button == Button1) {
|
||||||
MilskoLLDispatch(handle, up);
|
MwLLDispatch(handle, up);
|
||||||
MilskoLLDispatch(handle, draw);
|
MwLLDispatch(handle, draw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLSleep(int ms) {
|
void MwLLSleep(int ms) {
|
||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLSetTitle(MilskoLL handle, const char* title) {
|
void MwLLSetTitle(MwLL handle, const char* title) {
|
||||||
XSetStandardProperties(handle->display, handle->window, title, "Milsko Widget Toolkit", None, (char**)NULL, 0, NULL);
|
XSetStandardProperties(handle->display, handle->window, title, "Mw Widget Toolkit", None, (char**)NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user