mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
rahhh
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@37 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
TARGET = $(shell uname -s)
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -fPIC -Iinclude -D_MILSKO
|
||||
CFLAGS = -fPIC -Iinclude -D_MW
|
||||
LDFLAGS =
|
||||
LIBS =
|
||||
|
||||
@@ -40,12 +40,12 @@ endif
|
||||
.PHONY: all format clean
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
all: $(LIB)milsko$(SO)
|
||||
all: $(LIB)Mw$(SO)
|
||||
|
||||
format:
|
||||
clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h")
|
||||
|
||||
$(LIB)milsko$(SO): $(L_OBJS)
|
||||
$(LIB)Mw$(SO): $(L_OBJS)
|
||||
$(CC) $(LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS)
|
||||
|
||||
clean:
|
||||
|
||||
14
example.c
14
example.c
@@ -1,18 +1,18 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include <Milsko/Milsko.h>
|
||||
#include <Mw/Mw.h>
|
||||
|
||||
void handler(MilskoWidget handle, void* user_data, void* call_data){
|
||||
void handler(MwWidget handle, void* user_data, void* call_data){
|
||||
printf("hello world!\n");
|
||||
}
|
||||
|
||||
int main(){
|
||||
MilskoWidget window = MilskoVaCreateWidget(MilskoWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MilskoNtitle, "hello world",
|
||||
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
MilskoWidget button = MilskoVaCreateWidget(MilskoButtonClass, "button", window, 50, 50, 300, 300, NULL);
|
||||
MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 300, NULL);
|
||||
|
||||
MilskoAddUserHandler(button, MilskoNactivateHandler, handler, NULL);
|
||||
MwAddUserHandler(button, MwNactivateHandler, handler, NULL);
|
||||
|
||||
MilskoLoop(window);
|
||||
MwLoop(window);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_BUTTON_H__
|
||||
#define __MILSKO_BUTTON_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MILSKODECL MwClass MwButtonClass;
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_CORE_H__
|
||||
#define __MILSKO_CORE_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#define MwDispatch(x, y) \
|
||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||
|
||||
MILSKODECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget 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 MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
|
||||
MILSKODECL void MwDestroyWidget(MwWidget handle);
|
||||
|
||||
MILSKODECL void MwLoop(MwWidget handle);
|
||||
MILSKODECL void MwStep(MwWidget handle);
|
||||
MILSKODECL int MwPending(MwWidget handle);
|
||||
|
||||
MILSKODECL void MwSetInteger(MwWidget handle, const char* key, int n);
|
||||
MILSKODECL void MwSetText(MwWidget handle, const char* key, const char* value);
|
||||
MILSKODECL int MwGetInteger(MwWidget handle, const char* key);
|
||||
MILSKODECL const char* MwGetText(MwWidget handle, const char* key);
|
||||
MILSKODECL void MwSetDefault(MwWidget handle);
|
||||
MILSKODECL void MwVaApply(MwWidget handle, ...);
|
||||
MILSKODECL void MwVaListApply(MwWidget handle, va_list va);
|
||||
|
||||
MILSKODECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data);
|
||||
MILSKODECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data);
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_DEFAULT_H__
|
||||
#define __MILSKO_DEFAULT_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MILSKODECL const char* MwDefaultBackground;
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_DRAW_H__
|
||||
#define __MILSKO_DRAW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
|
||||
MILSKODECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||
|
||||
MILSKODECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
||||
MILSKODECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_LOWLEVEL_H__
|
||||
#define __MILSKO_LOWLEVEL_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec;
|
||||
#ifdef _MILSKO
|
||||
typedef struct _MwLL * MwLL, MwLLRec;
|
||||
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
|
||||
#else
|
||||
typedef void* MwLL;
|
||||
typedef void* MwLLColor;
|
||||
#endif
|
||||
|
||||
#ifdef _MILSKO
|
||||
#ifdef USE_X11
|
||||
#include <Mw/X11.h>
|
||||
#endif
|
||||
#ifdef USE_GDI
|
||||
#include <Mw/GDI.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#define MwLLDispatch(x, y) \
|
||||
if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x)
|
||||
|
||||
struct _MwLLHandler {
|
||||
void (*draw)(MwLL handle);
|
||||
void (*up)(MwLL handle);
|
||||
void (*down)(MwLL handle);
|
||||
};
|
||||
|
||||
/* lowlevel.c, common part */
|
||||
MILSKODECL void MwLLCreateCommon(MwLL handle);
|
||||
MILSKODECL void MwLLDestroyCommon(MwLL handle);
|
||||
|
||||
/* driver-specific */
|
||||
MILSKODECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height);
|
||||
MILSKODECL void MwLLDestroy(MwLL handle);
|
||||
|
||||
MILSKODECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
||||
|
||||
MILSKODECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b);
|
||||
MILSKODECL void MwLLFreeColor(MwLLColor color);
|
||||
|
||||
MILSKODECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||
MILSKODECL void MwLLSetXY(MwLL handle, int x, int y);
|
||||
MILSKODECL void MwLLSetWH(MwLL handle, int w, int h);
|
||||
|
||||
MILSKODECL void MwLLSetTitle(MwLL handle, const char* title);
|
||||
|
||||
MILSKODECL int MwLLPending(MwLL handle);
|
||||
MILSKODECL void MwLLNextEvent(MwLL handle);
|
||||
MILSKODECL void MwLLSleep(int ms);
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_MACHDEP_H__
|
||||
#define __MILSKO_MACHDEP_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MILSKO) && defined(_WIN32)
|
||||
#define MILSKODECL extern __declspec(dllexport)
|
||||
#elif defined(_WIN32)
|
||||
#define MILSKODECL extern __declspec(dllimport)
|
||||
#else
|
||||
#define MILSKODECL extern
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_WINDOW_H__
|
||||
#define __MILSKO_WINDOW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MILSKODECL MwClass MwWindowClass;
|
||||
|
||||
#endif
|
||||
9
include/Mw/Button.h
Normal file
9
include/Mw/Button.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_BUTTON_H__
|
||||
#define __MW_BUTTON_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MWDECL MwClass MwButtonClass;
|
||||
|
||||
#endif
|
||||
31
include/Mw/Core.h
Normal file
31
include/Mw/Core.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_CORE_H__
|
||||
#define __MW_CORE_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#define MwDispatch(x, y) \
|
||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||
|
||||
MWDECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height);
|
||||
MWDECL MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
|
||||
MWDECL MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
|
||||
MWDECL void MwDestroyWidget(MwWidget handle);
|
||||
|
||||
MWDECL void MwLoop(MwWidget handle);
|
||||
MWDECL void MwStep(MwWidget handle);
|
||||
MWDECL int MwPending(MwWidget handle);
|
||||
|
||||
MWDECL void MwSetInteger(MwWidget handle, const char* key, int n);
|
||||
MWDECL void MwSetText(MwWidget handle, const char* key, const char* value);
|
||||
MWDECL int MwGetInteger(MwWidget handle, const char* key);
|
||||
MWDECL const char* MwGetText(MwWidget handle, const char* key);
|
||||
MWDECL void MwSetDefault(MwWidget handle);
|
||||
MWDECL void MwVaApply(MwWidget handle, ...);
|
||||
MWDECL void MwVaListApply(MwWidget handle, va_list va);
|
||||
|
||||
MWDECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data);
|
||||
MWDECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data);
|
||||
|
||||
#endif
|
||||
9
include/Mw/Default.h
Normal file
9
include/Mw/Default.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_DEFAULT_H__
|
||||
#define __MW_DEFAULT_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MWDECL const char* MwDefaultBackground;
|
||||
|
||||
#endif
|
||||
14
include/Mw/Draw.h
Normal file
14
include/Mw/Draw.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_DRAW_H__
|
||||
#define __MW_DRAW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
|
||||
MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
|
||||
|
||||
MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
|
||||
MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_GDI_H__
|
||||
#define __MILSKO_GDI_H__
|
||||
#ifndef __MW_GDI_H__
|
||||
#define __MW_GDI_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
58
include/Mw/LowLevel.h
Normal file
58
include/Mw/LowLevel.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_LOWLEVEL_H__
|
||||
#define __MW_LOWLEVEL_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec;
|
||||
#ifdef _MW
|
||||
typedef struct _MwLL * MwLL, MwLLRec;
|
||||
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
|
||||
#else
|
||||
typedef void* MwLL;
|
||||
typedef void* MwLLColor;
|
||||
#endif
|
||||
|
||||
#ifdef _MW
|
||||
#ifdef USE_X11
|
||||
#include <Mw/X11.h>
|
||||
#endif
|
||||
#ifdef USE_GDI
|
||||
#include <Mw/GDI.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#define MwLLDispatch(x, y) \
|
||||
if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x)
|
||||
|
||||
struct _MwLLHandler {
|
||||
void (*draw)(MwLL handle);
|
||||
void (*up)(MwLL handle);
|
||||
void (*down)(MwLL handle);
|
||||
};
|
||||
|
||||
/* lowlevel.c, common part */
|
||||
MWDECL void MwLLCreateCommon(MwLL handle);
|
||||
MWDECL void MwLLDestroyCommon(MwLL handle);
|
||||
|
||||
/* driver-specific */
|
||||
MWDECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height);
|
||||
MWDECL void MwLLDestroy(MwLL handle);
|
||||
|
||||
MWDECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
||||
|
||||
MWDECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b);
|
||||
MWDECL void MwLLFreeColor(MwLLColor color);
|
||||
|
||||
MWDECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||
MWDECL void MwLLSetXY(MwLL handle, int x, int y);
|
||||
MWDECL void MwLLSetWH(MwLL handle, int w, int h);
|
||||
|
||||
MWDECL void MwLLSetTitle(MwLL handle, const char* title);
|
||||
|
||||
MWDECL int MwLLPending(MwLL handle);
|
||||
MWDECL void MwLLNextEvent(MwLL handle);
|
||||
MWDECL void MwLLSleep(int ms);
|
||||
|
||||
#endif
|
||||
23
include/Mw/MachDep.h
Normal file
23
include/Mw/MachDep.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_MACHDEP_H__
|
||||
#define __MW_MACHDEP_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MW) && defined(_WIN32)
|
||||
#define MWDECL extern __declspec(dllexport)
|
||||
#elif defined(_WIN32)
|
||||
#define MWDECL extern __declspec(dllimport)
|
||||
#else
|
||||
#define MWDECL extern
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_MILSKO_H__
|
||||
#define __MILSKO_MILSKO_H__
|
||||
#ifndef __MW_MW_H__
|
||||
#define __MW_MW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_STRINGDEFS_H__
|
||||
#define __MILSKO_STRINGDEFS_H__
|
||||
#ifndef __MW_STRINGDEFS_H__
|
||||
#define __MW_STRINGDEFS_H__
|
||||
|
||||
#define MwNx "Ix"
|
||||
#define MwNy "Iy"
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_TYPEDEFS_H__
|
||||
#define __MILSKO_TYPEDEFS_H__
|
||||
#ifndef __MW_TYPEDEFS_H__
|
||||
#define __MW_TYPEDEFS_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct _MwRect MwRect;
|
||||
typedef struct _MwIntegerKeyValue MwIntegerKeyValue;
|
||||
typedef struct _MwTextKeyValue MwTextKeyValue;
|
||||
typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue;
|
||||
#ifdef _MILSKO
|
||||
#ifdef _MW
|
||||
typedef struct _MwWidget *MwWidget, MwWidgetRec;
|
||||
#else
|
||||
typedef void* MwWidget;
|
||||
@@ -18,7 +18,7 @@ typedef void* MwWidget;
|
||||
typedef void (*MwHandler)(MwWidget handle);
|
||||
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||
|
||||
#ifdef _MILSKO
|
||||
#ifdef _MW
|
||||
#include <Mw/LowLevel.h>
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,7 @@ struct _MwUserHandlerKeyValue {
|
||||
MwUserHandler value;
|
||||
};
|
||||
|
||||
#ifdef _MILSKO
|
||||
#ifdef _MW
|
||||
struct _MwWidget {
|
||||
char* name;
|
||||
|
||||
9
include/Mw/Window.h
Normal file
9
include/Mw/Window.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MW_WINDOW_H__
|
||||
#define __MW_WINDOW_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
MWDECL MwClass MwWindowClass;
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_X11_H__
|
||||
#define __MILSKO_X11_H__
|
||||
#ifndef __MW_X11_H__
|
||||
#define __MW_X11_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
Reference in New Issue
Block a user