mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-10 03:13:28 +00:00
example
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@16 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
14
example.c
Normal file
14
example.c
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#include <Milsko/Milsko.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
HMILSKO window = MilskoCreateWidget(MilskoWindowClass, NULL, 0, 0, 640, 480);
|
||||||
|
|
||||||
|
MilskoApply(window,
|
||||||
|
MilskoNwidth, 480 * 2,
|
||||||
|
MilskoNtitle, "hello world",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MilskoLoop(window);
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ MILSKODECL void MilskoStep(HMILSKO handle);
|
|||||||
MILSKODECL int MilskoPending(HMILSKO handle);
|
MILSKODECL int MilskoPending(HMILSKO handle);
|
||||||
|
|
||||||
MILSKODECL void MilskoSetInteger(HMILSKO handle, const char* key, int n);
|
MILSKODECL void MilskoSetInteger(HMILSKO handle, const char* key, int n);
|
||||||
|
MILSKODECL void MilskoSetText(HMILSKO handle, const char* key, const char* value);
|
||||||
MILSKODECL void MilskoApply(HMILSKO handle, ...);
|
MILSKODECL void MilskoApply(HMILSKO handle, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ 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 MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||||
MILSKODECL void MilskoLLSetXY(HMILSKOLL handle, int x, int y);
|
MILSKODECL void MilskoLLSetXY(HMILSKOLL handle, int x, int y);
|
||||||
MILSKODECL void MilskoLLSetWH(HMILSKOLL handle, int w, int h);
|
MILSKODECL void MilskoLLSetWH(HMILSKOLL handle, int w, int h);
|
||||||
|
MILSKODECL void MilskoLLSetTitle(HMILSKOLL handle, const char* title);
|
||||||
MILSKODECL int MilskoLLPending(HMILSKOLL handle);
|
MILSKODECL int MilskoLLPending(HMILSKOLL handle);
|
||||||
MILSKODECL void MilskoLLNextEvent(HMILSKOLL handle);
|
MILSKODECL void MilskoLLNextEvent(HMILSKOLL handle);
|
||||||
MILSKODECL void MilskoLLSleep(int ms);
|
MILSKODECL void MilskoLLSleep(int ms);
|
||||||
|
|||||||
@@ -7,4 +7,6 @@
|
|||||||
#define MilskoNwidth "Iwidth"
|
#define MilskoNwidth "Iwidth"
|
||||||
#define MilskoNheight "Iheight"
|
#define MilskoNheight "Iheight"
|
||||||
|
|
||||||
|
#define MilskoNtitle "Stitle"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ void MilskoSetInteger(HMILSKO handle, const char* key, int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MilskoSetText(HMILSKO handle, const char* key, const char* value) {
|
||||||
|
if(strcmp(key, MilskoNtitle) == 0) {
|
||||||
|
MilskoLLSetTitle(handle->lowlevel, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MilskoApply(HMILSKO handle, ...) {
|
void MilskoApply(HMILSKO handle, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
char* key;
|
char* key;
|
||||||
@@ -86,6 +92,9 @@ void MilskoApply(HMILSKO handle, ...) {
|
|||||||
if(key[0] == 'I') {
|
if(key[0] == 'I') {
|
||||||
int n = va_arg(va, int);
|
int n = va_arg(va, int);
|
||||||
MilskoSetInteger(handle, key, n);
|
MilskoSetInteger(handle, key, n);
|
||||||
|
} else if(key[0] == 'S') {
|
||||||
|
char* t = va_arg(va, char*);
|
||||||
|
MilskoSetText(handle, key, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|||||||
@@ -108,3 +108,7 @@ void MilskoLLNextEvent(HMILSKOLL handle) {
|
|||||||
void MilskoLLSleep(int ms) {
|
void MilskoLLSleep(int ms) {
|
||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MILSKODECL void MilskoLLSetTitle(HMILSKOLL handle, const char* title) {
|
||||||
|
XSetStandardProperties(handle->display, handle->window, title, "Milsko Widget Toolkit", None, (char**)NULL, 0, NULL);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user