From 5170d6c0db9c67934dede9fdbd7dfb1c54538fbd Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 28 Sep 2025 09:08:53 +0000 Subject: [PATCH] example git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@16 b9cfdab3-6d41-4d17-bbe4-086880011989 --- example.c | 14 ++++++++++++++ include/Milsko/Core.h | 1 + include/Milsko/LowLevel.h | 1 + include/Milsko/StringDefs.h | 2 ++ src/core.c | 9 +++++++++ src/x11.c | 4 ++++ 6 files changed, 31 insertions(+) create mode 100644 example.c diff --git a/example.c b/example.c new file mode 100644 index 0000000..694e230 --- /dev/null +++ b/example.c @@ -0,0 +1,14 @@ +/* $Id$ */ + +#include + +int main(){ + HMILSKO window = MilskoCreateWidget(MilskoWindowClass, NULL, 0, 0, 640, 480); + + MilskoApply(window, + MilskoNwidth, 480 * 2, + MilskoNtitle, "hello world", + NULL); + + MilskoLoop(window); +} diff --git a/include/Milsko/Core.h b/include/Milsko/Core.h index 560b29e..3a96596 100644 --- a/include/Milsko/Core.h +++ b/include/Milsko/Core.h @@ -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 diff --git a/include/Milsko/LowLevel.h b/include/Milsko/LowLevel.h index 8e437ab..8d5b030 100644 --- a/include/Milsko/LowLevel.h +++ b/include/Milsko/LowLevel.h @@ -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); diff --git a/include/Milsko/StringDefs.h b/include/Milsko/StringDefs.h index 2c47c31..b2c5ec8 100644 --- a/include/Milsko/StringDefs.h +++ b/include/Milsko/StringDefs.h @@ -7,4 +7,6 @@ #define MilskoNwidth "Iwidth" #define MilskoNheight "Iheight" +#define MilskoNtitle "Stitle" + #endif diff --git a/src/core.c b/src/core.c index d2579d1..eeaabb4 100644 --- a/src/core.c +++ b/src/core.c @@ -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); diff --git a/src/x11.c b/src/x11.c index 7cdbe10..6ce0642 100644 --- a/src/x11.c +++ b/src/x11.c @@ -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); +}