From 81b3edd023f88874f9accbd022a61c4886181ab7 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 14 Oct 2025 17:09:48 +0000 Subject: [PATCH] more methods git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@330 b9cfdab3-6d41-4d17-bbe4-086880011989 --- doc/index.html | 117 ++++++++++++++++++++++++++++++++++ include/Mw/Widget/ListBox.h | 7 ++ include/MwOO/Widget/ListBox.h | 2 + oosrc/widget/listbox.cc | 6 ++ resource/icon/error.png | Bin 663 -> 663 bytes resource/icon/info.png | Bin 434 -> 434 bytes resource/icon/news.png | Bin 542 -> 542 bytes resource/icon/note.png | Bin 594 -> 594 bytes resource/icon/question.png | Bin 529 -> 529 bytes resource/icon/warning.png | Bin 498 -> 498 bytes src/widget/listbox.c | 44 +++++++++---- 11 files changed, 165 insertions(+), 11 deletions(-) diff --git a/doc/index.html b/doc/index.html index d70f40d..0edc75d 100644 --- a/doc/index.html +++ b/doc/index.html @@ -188,6 +188,9 @@
MwDrawText
+
+ MwDrawTextEx +
MwLoadImage
@@ -335,6 +338,12 @@
MwListBoxClass
+
+ MwListBoxInsert +
+
+ MwListBoxDelete +
Mw/Widget/Menu.h
@@ -1684,6 +1693,63 @@
+
MWDECL void MwDrawTextEx (
+	MwWidget handle,
+	MwPoint* point,
+	const char* text,
+	int bold,
+	int align,
+	MwLLColor color,
+	MwLLColor bgcolor
+);
+
+
+ Draws a text. +
+
+ Parameter handle +
+
+ Widget. +
+
+ Parameter point +
+
+ Center point of the text. +
+
+ Parameter text +
+
+ Text. +
+
+ Parameter bold +
+
+ Bold. +
+
+ Parameter align +
+
+ Align. +
+
+ Parameter color +
+
+ Color. +
+
+ Parameter bgcolor +
+
+ Background color. +
+
+
MWDECL MwLLPixmap MwLoadImage (
 	MwWidget handle,
 	const char* path
@@ -2289,6 +2355,57 @@
 
 
 
+
MWDECL void MwListBoxInsert (
+	MwWidget handle,
+	int index,
+	const char* text
+);
+
+
+ Inserts item on the listbox. +
+
+ Parameter handle +
+
+ Widget. +
+
+ Parameter index +
+
+ Index. +
+
+ Parameter text +
+
+ Text. +
+
+
+
MWDECL void MwListBoxDelete (
+	MwWidget handle,
+	int index
+);
+
+
+ Deletes item from the listbox. +
+
+ Parameter handle +
+
+ Widget. +
+
+ Parameter index +
+
+ Index. +
+
+

Mw/Widget/Menu.h

diff --git a/include/Mw/Widget/ListBox.h b/include/Mw/Widget/ListBox.h index 354f534..d152eeb 100644 --- a/include/Mw/Widget/ListBox.h +++ b/include/Mw/Widget/ListBox.h @@ -26,6 +26,13 @@ MWDECL MwClass MwListBoxClass; */ MWDECL void MwListBoxInsert(MwWidget handle, int index, const char* text); +/*! + * %brief Deletes item from the listbox + * %param handle Widget + * %param index Index + */ +MWDECL void MwListBoxDelete(MwWidget handle, int index); + #ifdef __cplusplus } #endif diff --git a/include/MwOO/Widget/ListBox.h b/include/MwOO/Widget/ListBox.h index 6572190..345a09b 100644 --- a/include/MwOO/Widget/ListBox.h +++ b/include/MwOO/Widget/ListBox.h @@ -8,6 +8,8 @@ namespace MwOO { class ListBox : public MwOO::Base { public: ListBox(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); + void Insert(int index, const char* text); + void Delete(int index); void SetBackground(const char* value); const char* GetBackground(void); void SetForeground(const char* value); diff --git a/oosrc/widget/listbox.cc b/oosrc/widget/listbox.cc index 4a09e4a..accafbe 100644 --- a/oosrc/widget/listbox.cc +++ b/oosrc/widget/listbox.cc @@ -5,6 +5,12 @@ MwOO::ListBox::ListBox(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwListBoxClass, widget_name, parent, x, y, w, h){ } +void MwOO::ListBox::Insert(int index, const char* text){ + MwListBoxInsert(this->widget, index, text); +} +void MwOO::ListBox::Delete(int index){ + MwListBoxDelete(this->widget, index); +} void MwOO::ListBox::SetBackground(const char* value){ MwSetText(this->widget, MwNbackground, value); } diff --git a/resource/icon/error.png b/resource/icon/error.png index 70f0b855a77a096395fa3abfabb3ef86711db6b7..bf2726c1473d76a86469e8a79ed604ca4730426e 100644 GIT binary patch delta 48 zcmbQvI-PaGbap{bmE~6@mv5YRhf&tt%D~df*i75Nz{gTe~DWM4f Df6)&& delta 48 zcmbQvI-PaGbap;V6JUoU}a#i%G;-m0SG)@{an^LB{Ts5 DZ~YEd diff --git a/resource/icon/info.png b/resource/icon/info.png index 94cb26dec5fcffb6ef11a1ee00432762829c61e9..5b5e0432dbed69bc80bcefa5f753e50a110032f1 100644 GIT binary patch delta 48 zcmdnQyoq^2H@hIG%JQp{%QsG9W|TFzGO)BVHq$mRure@MHrwkR0}yz+`njxgN@xNA DYEuq) delta 48 zcmdnQyoq^2H#?s?M`ytd)s2&w8D&kZj4iDUEVK;_tPBidm~G}W0D-5gpUXO@geCw) C-VCt- diff --git a/resource/icon/news.png b/resource/icon/news.png index dc2a88d1fdd581ca63e60384bea2e768ebdfb94b..c87e210db89b826b212ba09056b2c218c41c9eed 100644 GIT binary patch delta 48 zcmbQoGLL1#M0P<=mE~6@mv5Yr$tY`XWngJ#Y^H5sU}a#iY_``s1|aZs^>bP0l+XkK Dao-Na delta 48 zcmbQoGLL1#M0P%Pj?RJ^svBoyGRm4*8CzNzSZEsgTe~DWM4f DjDHVi delta 48 zcmcb_a*1Wabap;bP0l+XkK DYk3Zx delta 48 zcmbQpGLdD%M0P%Pj?RJ^svBp-Fv^-(8CzNzSZEsbP0l+XkK DirWu9 delta 48 zcmeyw{E2zOM0P%Pj?RJ^svBq6GRm4*8CzNzSZEsparent->internal; MwLLMouse* m = call; - int st = 0; - int i; - int y = MwDefaultBorderWidth; - int h = MwGetInteger(handle, MwNheight); + if(m->button == MwLLMouseLeft) { + int st = 0; + int i; + int y = MwDefaultBorderWidth; + int h = MwGetInteger(handle, MwNheight); - st = get_first_entry(lb); - for(i = 0; i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) { - if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M"))) { - lb->selected = st + i; + st = get_first_entry(lb); + for(i = 0; i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) { + if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M"))) { + lb->selected = st + i; + } + y += MwTextHeight(handle, "M"); } - y += MwTextHeight(handle, "M"); - } - MwForceRender(lb->frame); + MwForceRender(lb->frame); + } } static void frame_draw(MwWidget handle) { @@ -107,6 +109,7 @@ static void resize(MwWidget handle) { } ih = arrlen(lb->list); + if(ih == 0) ih = 1; MwVaApply(lb->vscroll, MwNareaShown, h / MwTextHeight(handle, "M"), @@ -183,3 +186,22 @@ void MwListBoxInsert(MwWidget handle, int index, const char* text) { MwForceRender(lb->frame); } } + +void MwListBoxDelete(MwWidget handle, int index) { + MwListBox lb = handle->internal; + + if(index == -1) index = arrlen(lb->list) - 1; + arrdel(lb->list, index); + + if(lb->selected >= arrlen(lb->list)) { + lb->selected = arrlen(lb->list) - 1; + } + if(lb->selected < 0) { + lb->selected = -1; + } + + resize(handle); + if(index < (MwGetInteger(lb->vscroll, MwNvalue) + MwGetInteger(lb->vscroll, MwNareaShown))) { + MwForceRender(lb->frame); + } +}