From aa4ba428ec915939f0f2f3bee0e860a2c27a74c5 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 30 Sep 2025 12:34:18 +0000 Subject: [PATCH] what am i doing git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@79 b9cfdab3-6d41-4d17-bbe4-086880011989 --- doc/index.html | 279 ++++++++++++++++++++++++++++++++++++++++++++-- include/Mw/Core.h | 55 ++++++++- tools/doc.pl | 73 +++++++++++- 3 files changed, 388 insertions(+), 19 deletions(-) diff --git a/doc/index.html b/doc/index.html index d11c2fe..70b7b27 100644 --- a/doc/index.html +++ b/doc/index.html @@ -6,22 +6,66 @@

Milsko GUI Toolkit Documentation


-

Mw/Button.h

-

- Button widget. -

+

Table of Contents

+
+
+ Mw/Button.h +
+
+ MwButtonClass +
+
+ Mw/Core.h +
+
+ MwDispatch +
+
+ MwCreateWidget +
+
+ MwVaCreateWidget +
+
+ MwVaListCreateWidget +
+
+ MwDestroyWidget +
+
+ MwLoop +
+
+ MwStep +
+
+ MwPending +
+

-
MWDECL MwClass MwButtonClass;
+

Mw/Button.h

+
+
+ Button widget. +
+
+
+
MWDECL MwClass MwButtonClass;
+
Button class.
+

-

Mw/Core.h

-

+

Mw/Core.h

+
+
Core. -

+
+

-
#define MwDispatch(x, y)
+
#define MwDispatch(x, y)
+
Dispatches a handler of widget class.
@@ -43,8 +87,9 @@
Handler name.
+

-
MWDECL MwWidget MwCreateWidget (
+
MWDECL MwWidget MwCreateWidget (
 	MwClass widget_class,
 	const char* name,
 	MwWidget parent,
@@ -53,6 +98,7 @@
 	unsigned int width,
 	unsigned int height
 );
+
Creates a widget.
@@ -98,6 +144,219 @@
Height.
+
+ Returns +
+
+ Widget. +
+
+
+
MWDECL MwWidget MwVaCreateWidget (
+	MwClass widget_class,
+	const char* name,
+	MwWidget parent,
+	int x,
+	int y,
+	unsigned int width,
+	unsigned int height,
+	...
+);
+
+
+ Creates a widget. +
+
+ Parameter widget_class +
+
+ Widget class. +
+
+ Parameter name +
+
+ Widget name. +
+
+ Parameter parent +
+
+ Parent widget or NULL. +
+
+ Parameter x +
+
+ X. +
+
+ Parameter y +
+
+ Y. +
+
+ Parameter width +
+
+ Width. +
+
+ Parameter height +
+
+ Height. +
+
+ Parameter ... +
+
+ Same with MwVaApply. +
+
+ Returns +
+
+ Widget. +
+
+
+
MWDECL MwWidget MwVaListCreateWidget (
+	MwClass widget_class,
+	const char* name,
+	MwWidget parent,
+	int x,
+	int y,
+	unsigned int width,
+	unsigned int height,
+	va_list va
+);
+
+
+ Creates a widget. +
+
+ Parameter widget_class +
+
+ Widget class. +
+
+ Parameter name +
+
+ Widget name. +
+
+ Parameter parent +
+
+ Parent widget or NULL. +
+
+ Parameter x +
+
+ X. +
+
+ Parameter y +
+
+ Y. +
+
+ Parameter width +
+
+ Width. +
+
+ Parameter height +
+
+ Height. +
+
+ Parameter va +
+
+ Same with MwVaListApply. +
+
+ Returns +
+
+ Widget. +
+
+
+
MWDECL void MwDestroyWidget (
+	MwWidget handle
+);
+
+
+ Destroys the widget and its child widgets. +
+
+ Parameter handle +
+
+ Widget. +
+
+
+
MWDECL void MwLoop (
+	MwWidget handle
+);
+
+
+ Runs the main loop. +
+
+ Parameter handle +
+
+ Widget. +
+
+
+
MWDECL void MwStep (
+	MwWidget handle
+);
+
+
+ Runs the single step. +
+
+ Parameter handle +
+
+ Widget. +
+
+
+
MWDECL int MwPending (
+	MwWidget handle
+);
+
+
+ Check if any event is pending. +
+
+ Parameter handle +
+
+ Widget. +
+
+ Returns +
+
+ 1 if any event is pending. +
+

diff --git a/include/Mw/Core.h b/include/Mw/Core.h index 2d94e17..7343c39 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -33,15 +33,62 @@ extern "C" { * %param y Y * %param width Width * %param height Height + * %return Widget */ MWDECL MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height); -MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...); -MWDECL MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va); -MWDECL void MwDestroyWidget(MwWidget handle); +/*! + * %brief Creates a widget + * %param widget_class Widget class + * %param name Widget name + * %param parent Parent widget or `NULL` + * %param x X + * %param y Y + * %param width Width + * %param height Height + * %param ... Same with MwVaApply + * %return Widget + */ +MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...); + +/*! + * %brief Creates a widget + * %param widget_class Widget class + * %param name Widget name + * %param parent Parent widget or `NULL` + * %param x X + * %param y Y + * %param width Width + * %param height Height + * %param va Same with MwVaListApply + * %return Widget + */ +MWDECL MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va); + +/*! + * %brief Destroys the widget and its child widgets + * %param handle Widget + */ +MWDECL void MwDestroyWidget(MwWidget handle); + +/*! + * %brief Runs the main loop + * %param handle Widget + */ MWDECL void MwLoop(MwWidget handle); + +/*! + * %brief Runs the single step + * %param handle Widget + */ MWDECL void MwStep(MwWidget handle); -MWDECL int MwPending(MwWidget handle); + +/*! + * %brief Check if any event is pending + * %param handle Widget + * %return `1` if any event is pending + */ +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); diff --git a/tools/doc.pl b/tools/doc.pl index a81ce71..0b00776 100755 --- a/tools/doc.pl +++ b/tools/doc.pl @@ -6,6 +6,9 @@ our $title = "Milsko GUI Toolkit Documentation"; our @pathlist = ("include"); our @notes = ("warning", "unsure", "note"); +our @files = (); +our %files_sections = (); + sub sentence { my $str = $_[0]; $str =~ s/([^\.])$/\1./g; @@ -40,6 +43,15 @@ sub arguments { return $out; } +sub replace_special { + my $ret = $_[0]; + + $ret =~ s/[\r\n]+//g; + $ret =~ s/[^A-Za-z0-9_]/_/g; + + return $ret; +} + sub scan_dir { my ($first, $path) = @_; $path =~ s/\/+$//g; @@ -64,6 +76,7 @@ sub scan_dir { my %kv = (); my %param = (); my @paramlist = (); + my $current = ""; print(STDERR "$path is a file\n"); open(IN, "<", "$path"); @@ -77,7 +90,7 @@ sub scan_dir { } if ($out) { - my $para = "p"; + my $para = "dt"; my $brief = $kv{brief} or ""; $brief = sentence($brief); @@ -93,16 +106,37 @@ sub scan_dir { next; } if (!$file && defined($kv{brief})) { + my $id = ""; + my $sl = ""; + my $attr = ""; + $para = "dd"; - $l =~ s/[ \t]*\\$//g; - $l =~ s/[ \t]*(?:;|\{.+)[ \t]*$/;/g; + $l =~ s/[ \t]+/ /g; + $l =~ s/[ ]*\\$//g; + $l =~ s/[ ]*(?:;|\{.+)[ ]*$/;/g; if (!($l =~ /^#/)) { $l =~ s/\(([^\)]+)\)/arguments($1)/ge; } - out("
$l
"); + $sl = $l; + $sl =~ s/\n//g; + $sl =~ s/^.+[ \t]+([^ ]+)[ \t]*\(.+\);?$/\1/g; + $sl =~ s/^.+[ \t]+([^ ]+);$/\1/g; + + $id = replace_special($current . "__" . $sl); + $attr = " id=\"$id\""; + + if (!defined($files_sections{ replace_special($current) })) + { + @{ $files_sections{ replace_special($current) } } = (); + } + push(@{ $files_sections{ replace_special($current) } }, + $sl); + + out("$l
"); } + out("
"); out("<$para>"); out(" $brief"); out(""); @@ -135,6 +169,7 @@ sub scan_dir { out(" " . sentence($kv{return})); out(""); } + out("
"); out("
"); } elsif ($l =~ /^([ \t]*)\/\*\!/) { @@ -155,11 +190,15 @@ sub scan_dir { $kv{$1} = $2; if ($1 eq "file") { if (!$has_file) { - out("

$2

"); + out( "

$2

"); + push(@files, $2); } $file = 1; $has_file = 1; + $current = $2; } elsif ($1 eq "param") { my $p = $2; @@ -182,10 +221,34 @@ out(" "); out(" "); out("

$title

"); out("
"); +out("

Table of Contents

"); +my $old = $html; +$html = ""; foreach my $f (@pathlist) { scan_dir($f, $f); } +my $stuff = $html; +$html = $old; + +out("
"); +foreach my $f (@files) { + out("
"); + out(" $f"); + out("
"); + foreach my $sect (@{ $files_sections{ replace_special($f) } }) { + out("
"); + out( " $sect"); + out("
"); + } +} +out("
"); + +out("
"); + +$html = $html . $stuff; out(" "); out("");