listbox looks nicer
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@798 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
88b3e3b068
commit
9b91e90877
2 changed files with 17 additions and 6 deletions
|
|
@ -217,7 +217,7 @@ static void frame_draw(MwWidget handle) {
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
|
|
||||||
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
||||||
ent = area / MwTextHeight(handle, "M") + 2;
|
ent = area / (MwTextHeight(handle, "M") + Padding) + 2;
|
||||||
|
|
||||||
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
||||||
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
||||||
|
|
@ -250,10 +250,21 @@ static void frame_draw(MwWidget handle) {
|
||||||
|
|
||||||
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
||||||
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
||||||
|
char* str = MwStringDuplicate(t);
|
||||||
|
int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0);
|
||||||
|
|
||||||
|
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, "M")) {
|
||||||
|
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, "M");
|
||||||
|
str[ind] = 0;
|
||||||
|
memset(str + ind - 3, '.', 3);
|
||||||
|
}
|
||||||
|
|
||||||
p.x += 4;
|
p.x += 4;
|
||||||
MwDrawText(handle, &p, t, 0, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
||||||
p.x -= 4;
|
p.x -= 4;
|
||||||
p.x += get_col_width(lb, j);
|
p.x += get_col_width(lb, j);
|
||||||
|
|
||||||
|
free(str);
|
||||||
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
||||||
int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0);
|
int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0);
|
||||||
p.x += (get_col_width(lb, j) - l) / 2;
|
p.x += (get_col_width(lb, j) - l) / 2;
|
||||||
|
|
@ -307,7 +318,7 @@ static void resize(MwWidget handle) {
|
||||||
|
|
||||||
h -= y;
|
h -= y;
|
||||||
|
|
||||||
if(ih <= (h / MwTextHeight(handle, "M"))) {
|
if(ih <= (h / (MwTextHeight(handle, "M") + Padding))) {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 0);
|
MwLLShow(lb->vscroll->lowlevel, 0);
|
||||||
} else {
|
} else {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 1);
|
MwLLShow(lb->vscroll->lowlevel, 1);
|
||||||
|
|
@ -331,7 +342,7 @@ static void resize(MwWidget handle) {
|
||||||
h -= MwDefaultBorderWidth(handle) * 2;
|
h -= MwDefaultBorderWidth(handle) * 2;
|
||||||
|
|
||||||
MwVaApply(lb->vscroll,
|
MwVaApply(lb->vscroll,
|
||||||
MwNareaShown, h / MwTextHeight(handle, "M"),
|
MwNareaShown, h / (MwTextHeight(handle, "M") + Padding),
|
||||||
MwNmaxValue, ih,
|
MwNmaxValue, ih,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue