mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
better
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@366 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -98,8 +98,8 @@ static void mouse_move(MwWidget handle, void* user, void* call) {
|
|||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
mx = point->x;
|
mx = point->x;
|
||||||
my = point->y;
|
my = point->y;
|
||||||
|
|
||||||
if(click == 2) {
|
if(click == 2) {
|
||||||
t[ct].points[2 * 2 + 0] = point->x;
|
t[ct].points[2 * 2 + 0] = point->x;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ typedef struct _MwMenu* MwMenu;
|
|||||||
typedef struct _MwEntry* MwEntry;
|
typedef struct _MwEntry* MwEntry;
|
||||||
typedef struct _MwViewport* MwViewport;
|
typedef struct _MwViewport* MwViewport;
|
||||||
typedef struct _MwListBox* MwListBox;
|
typedef struct _MwListBox* MwListBox;
|
||||||
|
typedef struct _MwListBoxEntry MwListBoxEntry;
|
||||||
typedef struct _MwSizeHints MwSizeHints;
|
typedef struct _MwSizeHints MwSizeHints;
|
||||||
typedef struct _MwDirectoryEntry MwDirectoryEntry;
|
typedef struct _MwDirectoryEntry MwDirectoryEntry;
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
@@ -119,14 +120,18 @@ struct _MwViewport {
|
|||||||
MwWidget inframe;
|
MwWidget inframe;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MwListBoxEntry {
|
||||||
|
char* name;
|
||||||
|
MwLLPixmap pixmap;
|
||||||
|
};
|
||||||
|
|
||||||
struct _MwListBox {
|
struct _MwListBox {
|
||||||
MwWidget vscroll;
|
MwWidget vscroll;
|
||||||
MwWidget frame;
|
MwWidget frame;
|
||||||
char** list;
|
MwListBoxEntry* list;
|
||||||
MwLLPixmap* pixmap_list;
|
int selected;
|
||||||
int selected;
|
unsigned long click_time;
|
||||||
unsigned long click_time;
|
int pressed;
|
||||||
int pressed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwSizeHints {
|
struct _MwSizeHints {
|
||||||
|
|||||||
@@ -113,21 +113,21 @@ static void frame_draw(MwWidget handle) {
|
|||||||
r2.x = 0;
|
r2.x = 0;
|
||||||
r2.y = p.y;
|
r2.y = p.y;
|
||||||
r2.width = r.width;
|
r2.width = r.width;
|
||||||
r2.height = MwTextHeight(handle, lb->list[i]);
|
r2.height = MwTextHeight(handle, lb->list[i].name);
|
||||||
MwDrawRect(handle, &r2, text);
|
MwDrawRect(handle, &r2, text);
|
||||||
}
|
}
|
||||||
if(lb->pixmap_list[i] != NULL) {
|
if(lb->list[i].pixmap != NULL) {
|
||||||
MwRect r2;
|
MwRect r2;
|
||||||
int h = (lb->pixmap_list[i]->height > MwTextHeight(handle, "M")) ? MwTextHeight(handle, "M") : lb->pixmap_list[i]->height;
|
int h = (lb->list[i].pixmap->height > MwTextHeight(handle, "M")) ? MwTextHeight(handle, "M") : lb->list[i].pixmap->height;
|
||||||
r2.x = MwDefaultBorderWidth;
|
r2.x = MwDefaultBorderWidth;
|
||||||
r2.y = p.y + (MwTextHeight(handle, "M") - h) / 2;
|
r2.y = p.y + (MwTextHeight(handle, "M") - h) / 2;
|
||||||
r2.width = h * lb->pixmap_list[i]->width / lb->pixmap_list[i]->height;
|
r2.width = h * lb->list[i].pixmap->width / lb->list[i].pixmap->height;
|
||||||
r2.height = h;
|
r2.height = h;
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r2, lb->pixmap_list[i]);
|
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
||||||
}
|
}
|
||||||
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
p.y += MwTextHeight(handle, lb->list[i].name) / 2;
|
||||||
MwDrawText(handle, &p, lb->list[i], 0, MwALIGNMENT_BEGINNING, selected ? base : text);
|
MwDrawText(handle, &p, lb->list[i].name, 0, MwALIGNMENT_BEGINNING, selected ? base : text);
|
||||||
p.y += MwTextHeight(handle, lb->list[i]) / 2;
|
p.y += MwTextHeight(handle, lb->list[i].name) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawFrame(handle, &r, base, 1);
|
MwDrawFrame(handle, &r, base, 1);
|
||||||
@@ -185,10 +185,9 @@ static int create(MwWidget handle) {
|
|||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
resize(handle);
|
resize(handle);
|
||||||
lb->list = NULL;
|
lb->list = NULL;
|
||||||
lb->pixmap_list = NULL;
|
lb->selected = -1;
|
||||||
lb->selected = -1;
|
lb->click_time = 0;
|
||||||
lb->click_time = 0;
|
|
||||||
|
|
||||||
MwSetInteger(handle, MwNleftPadding, 0);
|
MwSetInteger(handle, MwNleftPadding, 0);
|
||||||
|
|
||||||
@@ -197,8 +196,11 @@ static int create(MwWidget handle) {
|
|||||||
|
|
||||||
static void destroy(MwWidget handle) {
|
static void destroy(MwWidget handle) {
|
||||||
MwListBox lb = handle->internal;
|
MwListBox lb = handle->internal;
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < arrlen(lb->list); i++) {
|
||||||
|
free(lb->list[i].name);
|
||||||
|
}
|
||||||
arrfree(lb->list);
|
arrfree(lb->list);
|
||||||
arrfree(lb->pixmap_list);
|
|
||||||
free(handle->internal);
|
free(handle->internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,14 +245,16 @@ MwClassRec MwListBoxClassRec = {
|
|||||||
MwClass MwListBoxClass = &MwListBoxClassRec;
|
MwClass MwListBoxClass = &MwListBoxClassRec;
|
||||||
|
|
||||||
void MwListBoxInsert(MwWidget handle, int index, const char* text, MwLLPixmap pixmap) {
|
void MwListBoxInsert(MwWidget handle, int index, const char* text, MwLLPixmap pixmap) {
|
||||||
char* str = malloc(strlen(text) + 1);
|
MwListBox lb = handle->internal;
|
||||||
MwListBox lb = handle->internal;
|
MwListBoxEntry entry;
|
||||||
|
|
||||||
strcpy(str, text);
|
entry.name = malloc(strlen(text) + 1);
|
||||||
|
strcpy(entry.name, text);
|
||||||
|
|
||||||
|
entry.pixmap = pixmap;
|
||||||
|
|
||||||
if(index == -1) index = arrlen(lb->list);
|
if(index == -1) index = arrlen(lb->list);
|
||||||
arrins(lb->list, index, str);
|
arrins(lb->list, index, entry);
|
||||||
arrins(lb->pixmap_list, index, pixmap);
|
|
||||||
|
|
||||||
resize(handle);
|
resize(handle);
|
||||||
if(index < (MwGetInteger(lb->vscroll, MwNvalue) + MwGetInteger(lb->vscroll, MwNareaShown))) {
|
if(index < (MwGetInteger(lb->vscroll, MwNvalue) + MwGetInteger(lb->vscroll, MwNareaShown))) {
|
||||||
@@ -266,15 +270,15 @@ void MwListBoxInsertMultiple(MwWidget handle, int index, char** text, MwLLPixmap
|
|||||||
old = index;
|
old = index;
|
||||||
|
|
||||||
for(i = 0; i < count; i++) {
|
for(i = 0; i < count; i++) {
|
||||||
char* str = malloc(strlen(text[i]) + 1);
|
MwListBoxEntry entry;
|
||||||
strcpy(str, text[i]);
|
|
||||||
|
|
||||||
arrins(lb->list, index, str);
|
entry.name = malloc(strlen(text[i]) + 1);
|
||||||
if(pixmap == NULL) {
|
strcpy(entry.name, text[i]);
|
||||||
arrins(lb->pixmap_list, index, NULL);
|
|
||||||
} else {
|
entry.pixmap = NULL;
|
||||||
arrins(lb->pixmap_list, index, pixmap[i]);
|
if(pixmap != NULL) entry.pixmap = pixmap[i];
|
||||||
}
|
|
||||||
|
arrins(lb->list, index, entry);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +292,8 @@ void MwListBoxDelete(MwWidget handle, int index) {
|
|||||||
MwListBox lb = handle->internal;
|
MwListBox lb = handle->internal;
|
||||||
|
|
||||||
if(index == -1) index = arrlen(lb->list) - 1;
|
if(index == -1) index = arrlen(lb->list) - 1;
|
||||||
|
free(lb->list[index].name);
|
||||||
arrdel(lb->list, index);
|
arrdel(lb->list, index);
|
||||||
arrdel(lb->pixmap_list, index);
|
|
||||||
|
|
||||||
if(lb->selected >= arrlen(lb->list)) {
|
if(lb->selected >= arrlen(lb->list)) {
|
||||||
lb->selected = arrlen(lb->list) - 1;
|
lb->selected = arrlen(lb->list) - 1;
|
||||||
@@ -310,5 +314,5 @@ const char* MwListBoxGet(MwWidget handle, int index) {
|
|||||||
if(index < 0) return NULL;
|
if(index < 0) return NULL;
|
||||||
if(index >= arrlen(lb->list)) return NULL;
|
if(index >= arrlen(lb->list)) return NULL;
|
||||||
|
|
||||||
return lb->list[index];
|
return lb->list[index].name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user