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 70f0b85..bf2726c 100644 Binary files a/resource/icon/error.png and b/resource/icon/error.png differ diff --git a/resource/icon/info.png b/resource/icon/info.png index 94cb26d..5b5e043 100644 Binary files a/resource/icon/info.png and b/resource/icon/info.png differ diff --git a/resource/icon/news.png b/resource/icon/news.png index dc2a88d..c87e210 100644 Binary files a/resource/icon/news.png and b/resource/icon/news.png differ diff --git a/resource/icon/note.png b/resource/icon/note.png index 1124f8e..0a3f6f0 100644 Binary files a/resource/icon/note.png and b/resource/icon/note.png differ diff --git a/resource/icon/question.png b/resource/icon/question.png index 407405b..ae7b994 100644 Binary files a/resource/icon/question.png and b/resource/icon/question.png differ diff --git a/resource/icon/warning.png b/resource/icon/warning.png index b9beb34..77b1167 100644 Binary files a/resource/icon/warning.png and b/resource/icon/warning.png differ diff --git a/src/widget/listbox.c b/src/widget/listbox.c index be49d60..049d9e3 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -20,20 +20,22 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) { static void frame_mouse_down(MwWidget handle, void* user, void* call) { MwListBox lb = handle->parent->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); + } +}