mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-03 08:00:50 +00:00
uh
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@756 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -143,6 +143,7 @@ struct _MwTreeViewEntry {
|
|||||||
char* label;
|
char* label;
|
||||||
MwLLPixmap pixmap;
|
MwLLPixmap pixmap;
|
||||||
MwTreeViewEntry* tree;
|
MwTreeViewEntry* tree;
|
||||||
|
int opened;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwTreeView {
|
struct _MwTreeView {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
|||||||
sh.min_width = sh.max_width = w;
|
sh.min_width = sh.max_width = w;
|
||||||
sh.min_height = sh.max_height = h;
|
sh.min_height = sh.max_height = h;
|
||||||
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "messagebox", NULL, wx, wy, w, h,
|
window = MwVaCreateWidget(MwWindowClass, "messagebox", window, wx, wy, w, h,
|
||||||
MwNtitle, title,
|
MwNtitle, title,
|
||||||
MwNsizeHints, &sh,
|
MwNsizeHints, &sh,
|
||||||
NULL);
|
NULL);
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "../../external/stb_ds.h"
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
|
#define OpenerSize 10
|
||||||
|
#define LineSpace 24
|
||||||
|
|
||||||
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||||
MwTreeView tv = handle->parent->internal;
|
MwTreeView tv = handle->parent->internal;
|
||||||
|
|
||||||
@@ -12,23 +15,26 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
|||||||
tv->changed = 1;
|
tv->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwLLColor text, MwPoint* p, int next, int shift, int* skip, int* shared){
|
static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwLLColor base, MwLLColor text, MwPoint* p, int next, int shift, int* skip, int* shared){
|
||||||
int i;
|
int i;
|
||||||
MwPoint l[2];
|
MwPoint l[2];
|
||||||
|
int skipped = 0;
|
||||||
if((*skip) > 0){
|
if((*skip) > 0){
|
||||||
(*skip)--;
|
(*skip)--;
|
||||||
|
skipped = 1;
|
||||||
}else if((*shared) < (MwGetInteger(handle, MwNheight) / MwTextHeight(handle, "M"))){
|
}else if((*shared) < (MwGetInteger(handle, MwNheight) / MwTextHeight(handle, "M"))){
|
||||||
|
MwRect r;
|
||||||
p->x += shift;
|
p->x += shift;
|
||||||
p->y += MwTextHeight(handle, "M") / 2;
|
p->y += MwTextHeight(handle, "M") / 2;
|
||||||
|
|
||||||
if(shift > 0){
|
if(shift > 0){
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
l[0].x -= 16 / 2;
|
l[0].x -= LineSpace / 2;
|
||||||
l[1] = *p;
|
l[1] = *p;
|
||||||
MwLLLine(handle->lowlevel, &l[0], text);
|
MwLLLine(handle->lowlevel, &l[0], text);
|
||||||
|
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
l[0].x -= 16 / 2;
|
l[0].x -= LineSpace / 2;
|
||||||
l[1] = l[0];
|
l[1] = l[0];
|
||||||
l[0].y -= MwTextHeight(handle, "M") / 2;
|
l[0].y -= MwTextHeight(handle, "M") / 2;
|
||||||
if(next){
|
if(next){
|
||||||
@@ -37,8 +43,15 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwLLColor text, Mw
|
|||||||
MwLLLine(handle->lowlevel, &l[0], text);
|
MwLLLine(handle->lowlevel, &l[0], text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tree->tree != NULL){
|
||||||
|
r.width = OpenerSize;
|
||||||
|
r.height = OpenerSize;
|
||||||
|
r.x = p->x - LineSpace + (LineSpace - r.width) / 2;
|
||||||
|
r.y = p->y - MwTextHeight(handle, "M") / 2 + (MwTextHeight(handle, "M") - r.height) / 2;
|
||||||
|
MwDrawWidgetBack(handle, &r, base, tree->opened, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if(tree->pixmap != NULL){
|
if(tree->pixmap != NULL){
|
||||||
MwRect r;
|
|
||||||
|
|
||||||
r.height = MwTextHeight(handle, "M");
|
r.height = MwTextHeight(handle, "M");
|
||||||
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
||||||
@@ -56,17 +69,22 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwLLColor text, Mw
|
|||||||
|
|
||||||
(*shared)++;
|
(*shared)++;
|
||||||
}
|
}
|
||||||
|
if(!tree->opened) return;
|
||||||
for(i = 0; i < arrlen(tree->tree); i++){
|
for(i = 0; i < arrlen(tree->tree); i++){
|
||||||
l[0] = *p;
|
l[0] = *p;
|
||||||
l[0].x += shift + 16 / 2;
|
l[0].x += shift + LineSpace / 2;
|
||||||
l[0].y += MwTextHeight(handle, "M") / 2;
|
l[0].y += MwTextHeight(handle, "M") - (MwTextHeight(handle, "M") - OpenerSize) / 2;
|
||||||
|
|
||||||
recursion(handle, &tree->tree[i], text, p, i != (arrlen(tree->tree) - 1) ? 1 : 0, shift+16, skip, shared);
|
recursion(handle, &tree->tree[i], base, text, p, i != (arrlen(tree->tree) - 1) ? 1 : 0, shift + LineSpace, skip, shared);
|
||||||
|
|
||||||
l[1] = *p;
|
l[1] = *p;
|
||||||
l[1].x += shift + 16 / 2;
|
l[1].x += shift + LineSpace / 2;
|
||||||
|
|
||||||
if(i != (arrlen(tree->tree) - 1)) MwLLLine(handle->lowlevel, &l[0], text);
|
if(skipped && p->y > l[0].y){
|
||||||
|
l[0].y -= MwTextHeight(handle, "M");
|
||||||
|
skipped = 0;
|
||||||
|
}
|
||||||
|
if(!skipped && i != (arrlen(tree->tree) - 1)) MwLLLine(handle->lowlevel, &l[0], text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +108,7 @@ static void frame_draw(MwWidget handle) {
|
|||||||
|
|
||||||
for(i = 0; i < arrlen(tv->tree); i++){
|
for(i = 0; i < arrlen(tv->tree); i++){
|
||||||
if(shared > (r.height / MwTextHeight(handle, "M"))) break;
|
if(shared > (r.height / MwTextHeight(handle, "M"))) break;
|
||||||
recursion(handle, &tv->tree[i], text, &p, 0, 0, &skip, &shared);
|
recursion(handle, &tv->tree[i], base, text, &p, 0, 0, &skip, &shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawFrame(handle, &r, base, 1);
|
MwDrawFrame(handle, &r, base, 1);
|
||||||
@@ -103,7 +121,7 @@ static int recursive_length(MwTreeViewEntry* e){
|
|||||||
int l = 0;
|
int l = 0;
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < arrlen(e); i++){
|
for(i = 0; i < arrlen(e); i++){
|
||||||
l += recursive_length(e->tree);
|
if(e[i].opened && e[i].tree != NULL) l += recursive_length(e[i].tree);
|
||||||
l++;
|
l++;
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@@ -118,6 +136,7 @@ static void resize(MwWidget handle) {
|
|||||||
if(tv->vscroll == NULL) {
|
if(tv->vscroll == NULL) {
|
||||||
tv->vscroll = MwCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h);
|
tv->vscroll = MwCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h);
|
||||||
MwAddUserHandler(tv->vscroll, MwNchangedHandler, vscroll_changed, NULL);
|
MwAddUserHandler(tv->vscroll, MwNchangedHandler, vscroll_changed, NULL);
|
||||||
|
MwSetInteger(tv->vscroll, MwNvalue, 7);
|
||||||
} else {
|
} else {
|
||||||
MwVaApply(tv->vscroll,
|
MwVaApply(tv->vscroll,
|
||||||
MwNx, w - 16,
|
MwNx, w - 16,
|
||||||
@@ -149,6 +168,13 @@ static void resize(MwWidget handle) {
|
|||||||
MwNareaShown, h / MwTextHeight(handle, "M"),
|
MwNareaShown, h / MwTextHeight(handle, "M"),
|
||||||
MwNmaxValue, ih,
|
MwNmaxValue, ih,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
if(ih <= (h / MwTextHeight(handle, "M"))){
|
||||||
|
MwLLShow(tv->vscroll->lowlevel, 0);
|
||||||
|
MwSetInteger(tv->frame, MwNwidth, w);
|
||||||
|
}else{
|
||||||
|
MwLLShow(tv->vscroll->lowlevel, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int create(MwWidget handle) {
|
||||||
@@ -166,24 +192,28 @@ static int create(MwWidget handle) {
|
|||||||
e.label = MwStringDupliacte(str);
|
e.label = MwStringDupliacte(str);
|
||||||
e.pixmap = p;
|
e.pixmap = p;
|
||||||
e.tree = NULL;
|
e.tree = NULL;
|
||||||
|
e.opened = 1;
|
||||||
for(j = 0; j < 3; j++){
|
for(j = 0; j < 3; j++){
|
||||||
MwTreeViewEntry e2;
|
MwTreeViewEntry e2;
|
||||||
sprintf(str, "hello %d", ++c);
|
sprintf(str, "hello %d", ++c);
|
||||||
e2.label = MwStringDupliacte(str);
|
e2.label = MwStringDupliacte(str);
|
||||||
e2.pixmap = p;
|
e2.pixmap = p;
|
||||||
e2.tree = NULL;
|
e2.tree = NULL;
|
||||||
|
e2.opened = j == 1 ? 0 : 1;
|
||||||
for(k = 0; k < 3; k++){
|
for(k = 0; k < 3; k++){
|
||||||
MwTreeViewEntry e3;
|
MwTreeViewEntry e3;
|
||||||
sprintf(str, "hello %d", ++c);
|
sprintf(str, "hello %d", ++c);
|
||||||
e3.label = MwStringDupliacte(str);
|
e3.label = MwStringDupliacte(str);
|
||||||
e3.pixmap = p;
|
e3.pixmap = p;
|
||||||
e3.tree = NULL;
|
e3.tree = NULL;
|
||||||
|
e3.opened = 1;
|
||||||
for(l = 0; l < 3; l++){
|
for(l = 0; l < 3; l++){
|
||||||
MwTreeViewEntry e4;
|
MwTreeViewEntry e4;
|
||||||
sprintf(str, "hello %d", ++c);
|
sprintf(str, "hello %d", ++c);
|
||||||
e4.label = MwStringDupliacte(str);
|
e4.label = MwStringDupliacte(str);
|
||||||
e4.pixmap = p;
|
e4.pixmap = p;
|
||||||
e4.tree = NULL;
|
e4.tree = NULL;
|
||||||
|
e4.opened = 1;
|
||||||
arrput(e3.tree, e4);
|
arrput(e3.tree, e4);
|
||||||
}
|
}
|
||||||
arrput(e2.tree, e3);
|
arrput(e2.tree, e3);
|
||||||
|
|||||||
Reference in New Issue
Block a user