mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
thing
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@15 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -10,6 +10,8 @@ MILSKODECL void MilskoDestroyWidget(HMILSKO handle);
|
||||
MILSKODECL void MilskoLoop(HMILSKO handle);
|
||||
MILSKODECL void MilskoStep(HMILSKO handle);
|
||||
MILSKODECL int MilskoPending(HMILSKO handle);
|
||||
MILSKODECL void MilskoApply(HMILSKO handle, ...);
|
||||
|
||||
MILSKODECL void MilskoSetInteger(HMILSKO handle, const char* key, int n);
|
||||
MILSKODECL void MilskoApply(HMILSKO handle, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,8 @@ MILSKODECL void MilskoLLDestroy(HMILSKOLL handle);
|
||||
MILSKODECL void MilskoLLPolygon(HMILSKOLL handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color);
|
||||
MILSKODECL HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b);
|
||||
MILSKODECL void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||
MILSKODECL void MilskoLLSetXYWH(HMILSKOLL handle, int x, int y, unsigned int w, unsigned int h);
|
||||
MILSKODECL void MilskoLLSetXY(HMILSKOLL handle, int x, int y);
|
||||
MILSKODECL void MilskoLLSetWH(HMILSKOLL handle, int w, int h);
|
||||
MILSKODECL int MilskoLLPending(HMILSKOLL handle);
|
||||
MILSKODECL void MilskoLLNextEvent(HMILSKOLL handle);
|
||||
MILSKODECL void MilskoLLSleep(int ms);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <Milsko/MachDep.h>
|
||||
#include <Milsko/LowLevel.h>
|
||||
#include <Milsko/StringDefs.h>
|
||||
#include <Milsko/TypeDefs.h>
|
||||
#include <Milsko/Core.h>
|
||||
|
||||
#include <Milsko/Window.h>
|
||||
|
||||
10
include/Milsko/StringDefs.h
Normal file
10
include/Milsko/StringDefs.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MILSKO_STRINGDEFS_H__
|
||||
#define __MILSKO_STRINGDEFS_H__
|
||||
|
||||
#define MilskoNx "Ix"
|
||||
#define MilskoNy "Iy"
|
||||
#define MilskoNwidth "Iwidth"
|
||||
#define MilskoNheight "Iheight"
|
||||
|
||||
#endif
|
||||
25
src/core.c
25
src/core.c
@@ -60,12 +60,33 @@ MILSKODECL void MilskoLoop(HMILSKO handle) {
|
||||
}
|
||||
}
|
||||
|
||||
void MilskoSetInteger(HMILSKO handle, const char* key, int n) {
|
||||
int xy = 0;
|
||||
int wh = 0;
|
||||
if((xy = (strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0)) || (wh = (strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0))) {
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
|
||||
MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
||||
if(strcmp(key, MilskoNx) == 0) x = n;
|
||||
if(strcmp(key, MilskoNy) == 0) y = n;
|
||||
if(strcmp(key, MilskoNwidth) == 0) w = n;
|
||||
if(strcmp(key, MilskoNheight) == 0) h = n;
|
||||
if(xy) MilskoLLSetXY(handle->lowlevel, x, y);
|
||||
if(wh) MilskoLLSetWH(handle->lowlevel, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
void MilskoApply(HMILSKO handle, ...) {
|
||||
va_list va;
|
||||
char* key;
|
||||
char* key;
|
||||
|
||||
va_start(va, handle);
|
||||
while((key = va_arg(va, char*)) != NULL){
|
||||
while((key = va_arg(va, char*)) != NULL) {
|
||||
if(key[0] == 'I') {
|
||||
int n = va_arg(va, int);
|
||||
MilskoSetInteger(handle, key, n);
|
||||
}
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
30
src/x11.c
30
src/x11.c
@@ -4,8 +4,10 @@
|
||||
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
|
||||
|
||||
HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height) {
|
||||
HMILSKOLL r;
|
||||
Window p;
|
||||
HMILSKOLL r;
|
||||
Window p;
|
||||
Window root;
|
||||
unsigned int border, depth;
|
||||
|
||||
r = malloc(sizeof(*r));
|
||||
r->x = x;
|
||||
@@ -22,7 +24,8 @@ HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height)
|
||||
}
|
||||
r->window = XCreateSimpleWindow(r->display, p, x, y, width, height, 0, 0, WhitePixel(r->display, XDefaultScreen(r->display)));
|
||||
r->colormap = DefaultColormap(r->display, XDefaultScreen(r->display));
|
||||
r->gc = XCreateGC(r->display, r->window, 0, 0);
|
||||
|
||||
r->gc = XCreateGC(r->display, r->window, 0, 0);
|
||||
|
||||
XSelectInput(r->display, r->window, mask);
|
||||
XMapWindow(r->display, r->window);
|
||||
@@ -64,14 +67,23 @@ HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b) {
|
||||
}
|
||||
|
||||
void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||
*x = handle->x;
|
||||
*y = handle->y;
|
||||
*w = handle->width;
|
||||
*h = handle->height;
|
||||
Window root;
|
||||
unsigned int border, depth;
|
||||
|
||||
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
||||
|
||||
handle->x = *x;
|
||||
handle->y = *y;
|
||||
handle->width = *w;
|
||||
handle->height = *h;
|
||||
}
|
||||
|
||||
void MilskoLLSetXYWH(HMILSKOLL handle, int x, int y, unsigned int w, unsigned int h) {
|
||||
XMoveResizeWindow(handle->display, handle->window, x, y, w, h);
|
||||
void MilskoLLSetXY(HMILSKOLL handle, int x, int y) {
|
||||
XMoveWindow(handle->display, handle->window, x, y);
|
||||
}
|
||||
|
||||
void MilskoLLSetWH(HMILSKOLL handle, int w, int h) {
|
||||
XResizeWindow(handle->display, handle->window, w, h);
|
||||
}
|
||||
|
||||
void MilskoLLFreeColor(HMILSKOCOLOR color) {
|
||||
|
||||
Reference in New Issue
Block a user