mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 10:23:27 +00:00
better
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@745 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -134,7 +134,6 @@ struct _MwListBox {
|
|||||||
struct _MwComboBox {
|
struct _MwComboBox {
|
||||||
char** list;
|
char** list;
|
||||||
int opened;
|
int opened;
|
||||||
int selected;
|
|
||||||
MwWidget listbox;
|
MwWidget listbox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ static int create(MwWidget handle) {
|
|||||||
|
|
||||||
cb->list = NULL;
|
cb->list = NULL;
|
||||||
cb->opened = 0;
|
cb->opened = 0;
|
||||||
cb->selected = 0;
|
|
||||||
cb->listbox = NULL;
|
cb->listbox = NULL;
|
||||||
handle->internal = cb;
|
handle->internal = cb;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNareaShown, 6);
|
MwSetInteger(handle, MwNareaShown, 6);
|
||||||
|
MwSetInteger(handle, MwNvalue, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -46,13 +46,13 @@ static void draw(MwWidget handle) {
|
|||||||
rc = r;
|
rc = r;
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
if(arrlen(cb->list) > cb->selected) {
|
if(arrlen(cb->list) > MwGetInteger(handle, MwNvalue)) {
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
|
|
||||||
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
||||||
p.y = MwGetInteger(handle, MwNheight) / 2;
|
p.y = MwGetInteger(handle, MwNheight) / 2;
|
||||||
|
|
||||||
MwDrawText(handle, &p, cb->list[cb->selected], 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, &p, cb->list[MwGetInteger(handle, MwNvalue)], 0, MwALIGNMENT_BEGINNING, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rc;
|
r = rc;
|
||||||
@@ -84,7 +84,7 @@ static void listbox_activate(MwWidget handle, void* user, void* client) {
|
|||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
cb->selected = *(int*)client;
|
MwSetInteger(handle->parent, MwNvalue, *(int*)client);
|
||||||
cb->opened = 0;
|
cb->opened = 0;
|
||||||
cb->listbox = NULL;
|
cb->listbox = NULL;
|
||||||
|
|
||||||
@@ -154,6 +154,12 @@ static void click(MwWidget handle) {
|
|||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prop_change(MwWidget handle, const char* prop) {
|
||||||
|
if(strcmp(prop, MwNvalue) == 0) {
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text) {
|
static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text) {
|
||||||
MwComboBox cb = handle->internal;
|
MwComboBox cb = handle->internal;
|
||||||
char* t = MwStringDupliacte(text);
|
char* t = MwStringDupliacte(text);
|
||||||
@@ -162,7 +168,7 @@ static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text) {
|
|||||||
|
|
||||||
arrins(cb->list, index, t);
|
arrins(cb->list, index, t);
|
||||||
|
|
||||||
if(index <= cb->selected) MwForceRender(handle);
|
if(index <= MwGetInteger(handle, MwNvalue)) MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* mwComboBoxGetImpl(MwWidget handle, int index) {
|
static const char* mwComboBoxGetImpl(MwWidget handle, int index) {
|
||||||
@@ -189,7 +195,7 @@ MwClassRec MwComboBoxClassRec = {
|
|||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
click, /* click */
|
click, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
NULL, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
MwForceRender2, /* mouse_up */
|
MwForceRender2, /* mouse_up */
|
||||||
MwForceRender2, /* mouse_down */
|
MwForceRender2, /* mouse_down */
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ static int create(MwWidget handle) {
|
|||||||
|
|
||||||
MwSetInteger(handle, MwNsingleClickSelectable, 0);
|
MwSetInteger(handle, MwNsingleClickSelectable, 0);
|
||||||
MwSetInteger(handle, MwNhasHeading, 0);
|
MwSetInteger(handle, MwNhasHeading, 0);
|
||||||
MwSetInteger(handle, MwNhasHeading, 0);
|
MwSetInteger(handle, MwNvalue, 0);
|
||||||
|
|
||||||
resize(handle);
|
resize(handle);
|
||||||
lb->list = NULL;
|
lb->list = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user