mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 18:33:30 +00:00
more methods
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@330 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user