git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@37 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-29 00:06:16 +00:00
parent b490488422
commit 1f0fee4df9
21 changed files with 176 additions and 176 deletions

9
include/Mw/Button.h Normal file
View 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
View 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
View 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
View 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

27
include/Mw/GDI.h Normal file
View File

@@ -0,0 +1,27 @@
/* $Id$ */
#ifndef __MW_GDI_H__
#define __MW_GDI_H__
#include <Mw/MachDep.h>
typedef struct _MwLL * MwLL, MwLLRec;
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
#include <windows.h>
struct _MwLL {
void* user;
MwLLHandler handler;
};
struct _MwColor {
int red;
int green;
int blue;
};
#endif

58
include/Mw/LowLevel.h Normal file
View 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
View 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

16
include/Mw/Mw.h Normal file
View File

@@ -0,0 +1,16 @@
/* $Id$ */
#ifndef __MW_MW_H__
#define __MW_MW_H__
#include <Mw/MachDep.h>
#include <Mw/LowLevel.h>
#include <Mw/StringDefs.h>
#include <Mw/TypeDefs.h>
#include <Mw/Core.h>
#include <Mw/Default.h>
#include <Mw/Draw.h>
#include <Mw/Window.h>
#include <Mw/Button.h>
#endif

15
include/Mw/StringDefs.h Normal file
View File

@@ -0,0 +1,15 @@
/* $Id$ */
#ifndef __MW_STRINGDEFS_H__
#define __MW_STRINGDEFS_H__
#define MwNx "Ix"
#define MwNy "Iy"
#define MwNwidth "Iwidth"
#define MwNheight "Iheight"
#define MwNtitle "Stitle"
#define MwNbackground "Sbackground"
#define MwNactivateHandler "Cactivate"
#endif

78
include/Mw/TypeDefs.h Normal file
View File

@@ -0,0 +1,78 @@
/* $Id$ */
#ifndef __MW_TYPEDEFS_H__
#define __MW_TYPEDEFS_H__
#include <Mw/MachDep.h>
typedef struct _MwClass * MwClass, MwClassRec;
typedef struct _MwPoint MwPoint;
typedef struct _MwRect MwRect;
typedef struct _MwIntegerKeyValue MwIntegerKeyValue;
typedef struct _MwTextKeyValue MwTextKeyValue;
typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue;
#ifdef _MW
typedef struct _MwWidget *MwWidget, MwWidgetRec;
#else
typedef void* MwWidget;
#endif
typedef void (*MwHandler)(MwWidget handle);
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
#ifdef _MW
#include <Mw/LowLevel.h>
#endif
struct _MwPoint {
int x;
int y;
};
struct _MwRect {
int x;
int y;
unsigned int width;
unsigned int height;
};
struct _MwTextKeyValue {
char* key;
char* value;
};
struct _MwIntegerKeyValue {
char* key;
int value;
};
struct _MwUserHandlerKeyValue {
char* key;
void* user_data;
MwUserHandler value;
};
#ifdef _MW
struct _MwWidget {
char* name;
MwLL lowlevel;
MwWidget parent;
MwWidget* children;
MwClass class;
int pressed;
MwIntegerKeyValue* integer;
MwTextKeyValue* text;
MwUserHandlerKeyValue* handler;
};
#endif
struct _MwClass {
void* opaque;
MwHandler create;
MwHandler destroy;
MwHandler draw;
MwHandler click;
};
#endif

9
include/Mw/Window.h Normal file
View File

@@ -0,0 +1,9 @@
/* $Id$ */
#ifndef __MW_WINDOW_H__
#define __MW_WINDOW_H__
#include <Mw/MachDep.h>
MWDECL MwClass MwWindowClass;
#endif

33
include/Mw/X11.h Normal file
View File

@@ -0,0 +1,33 @@
/* $Id$ */
#ifndef __MW_X11_H__
#define __MW_X11_H__
#include <Mw/MachDep.h>
typedef struct _MwLL * MwLL, MwLLRec;
typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
#include <X11/X.h>
#include <X11/Xutil.h>
struct _MwLL {
Display* display;
Window window;
GC gc;
Colormap colormap;
void* user;
MwLLHandler handler;
};
struct _MwLLColor {
unsigned long pixel;
int red;
int green;
int blue;
};
#endif