git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@16 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-28 09:08:53 +00:00
parent 09ae765d0a
commit 5170d6c0db
6 changed files with 31 additions and 0 deletions

14
example.c Normal file
View 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);
}

View File

@@ -12,6 +12,7 @@ MILSKODECL void MilskoStep(HMILSKO handle);
MILSKODECL int MilskoPending(HMILSKO handle);
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, ...);
#endif

View File

@@ -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 MilskoLLSetXY(HMILSKOLL handle, int x, int y);
MILSKODECL void MilskoLLSetWH(HMILSKOLL handle, int w, int h);
MILSKODECL void MilskoLLSetTitle(HMILSKOLL handle, const char* title);
MILSKODECL int MilskoLLPending(HMILSKOLL handle);
MILSKODECL void MilskoLLNextEvent(HMILSKOLL handle);
MILSKODECL void MilskoLLSleep(int ms);

View File

@@ -7,4 +7,6 @@
#define MilskoNwidth "Iwidth"
#define MilskoNheight "Iheight"
#define MilskoNtitle "Stitle"
#endif

View File

@@ -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, ...) {
va_list va;
char* key;
@@ -86,6 +92,9 @@ void MilskoApply(HMILSKO handle, ...) {
if(key[0] == 'I') {
int n = va_arg(va, int);
MilskoSetInteger(handle, key, n);
} else if(key[0] == 'S') {
char* t = va_arg(va, char*);
MilskoSetText(handle, key, t);
}
}
va_end(va);

View File

@@ -108,3 +108,7 @@ void MilskoLLNextEvent(HMILSKOLL handle) {
void MilskoLLSleep(int ms) {
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);
}