forked from pyrite-dev/milsko
better
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@172 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
2041b11e23
commit
6e1d4472b1
3 changed files with 12 additions and 14 deletions
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 500, 500,
|
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 500, 500,
|
||||||
MwNtitle, "main",
|
MwNtitle, "main",
|
||||||
NULL);
|
NULL);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 500 / 16; i++){
|
for(i = 0; i < 500 / 16; i++) {
|
||||||
MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500,
|
MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500,
|
||||||
MwNorientation, MwVERTICAL,
|
MwNorientation, MwVERTICAL,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLoop(window);
|
MwLoop(window);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ struct _MwMenu {
|
||||||
int keep;
|
int keep;
|
||||||
MwWidget wsub;
|
MwWidget wsub;
|
||||||
MwMenu* sub;
|
MwMenu* sub;
|
||||||
int wait;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ static int create(MwWidget handle) {
|
||||||
m->name = NULL;
|
m->name = NULL;
|
||||||
m->wsub = NULL;
|
m->wsub = NULL;
|
||||||
m->sub = NULL;
|
m->sub = NULL;
|
||||||
m->wait = 0;
|
|
||||||
handle->internal = m;
|
handle->internal = m;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
@ -66,6 +65,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
MwMenu m = handle->internal;
|
MwMenu m = handle->internal;
|
||||||
int i;
|
int i;
|
||||||
|
int first = 1;
|
||||||
|
|
||||||
p.x = 10;
|
p.x = 10;
|
||||||
p.y = MwGetInteger(handle, MwNheight) / 2;
|
p.y = MwGetInteger(handle, MwNheight) / 2;
|
||||||
|
|
@ -77,7 +77,6 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
MwDrawFrame(handle, &r, base, 0);
|
MwDrawFrame(handle, &r, base, 0);
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
if(!handle->pressed) m->wait = 0;
|
|
||||||
for(i = 0; i < arrlen(m->sub); i++) {
|
for(i = 0; i < arrlen(m->sub); i++) {
|
||||||
int incr = m->sub[i]->name[0] == '?' ? 1 : 0;
|
int incr = m->sub[i]->name[0] == '?' ? 1 : 0;
|
||||||
int tw = MwTextWidth(handle, m->sub[i]->name + incr);
|
int tw = MwTextWidth(handle, m->sub[i]->name + incr);
|
||||||
|
|
@ -96,7 +95,8 @@ static void draw(MwWidget handle) {
|
||||||
r.height = th + 10;
|
r.height = th + 10;
|
||||||
|
|
||||||
in_area = (r.x <= handle->mouse_point.x && r.y <= handle->mouse_point.y && handle->mouse_point.x <= (int)(r.x + r.width) && handle->mouse_point.y <= (int)(r.y + r.height)) ? 1 : 0;
|
in_area = (r.x <= handle->mouse_point.x && r.y <= handle->mouse_point.y && handle->mouse_point.x <= (int)(r.x + r.width) && handle->mouse_point.y <= (int)(r.y + r.height)) ? 1 : 0;
|
||||||
if(!m->wait && handle->pressed && in_area) {
|
if(first && handle->pressed && in_area) {
|
||||||
|
first = 0;
|
||||||
MwDrawFrame(handle, &r, base, 0);
|
MwDrawFrame(handle, &r, base, 0);
|
||||||
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0) {
|
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0) {
|
||||||
MwPoint p2;
|
MwPoint p2;
|
||||||
|
|
@ -110,7 +110,6 @@ static void draw(MwWidget handle) {
|
||||||
MwDestroyWidget(m->sub[i]->wsub);
|
MwDestroyWidget(m->sub[i]->wsub);
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
m->wait = 1;
|
|
||||||
} else if(arrlen(m->sub[i]->sub) == 0) {
|
} else if(arrlen(m->sub[i]->sub) == 0) {
|
||||||
MwDispatchUserHandler(handle, MwNmenuHandler, m->sub[i]);
|
MwDispatchUserHandler(handle, MwNmenuHandler, m->sub[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -123,10 +122,11 @@ static void draw(MwWidget handle) {
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
}
|
}
|
||||||
} else if(handle->pressed && m->sub[i]->keep && m->sub[i]->wsub != NULL) {
|
} else if(first && handle->pressed && m->sub[i]->keep && m->sub[i]->wsub != NULL) {
|
||||||
MwDestroyWidget(m->sub[i]->wsub);
|
MwDestroyWidget(m->sub[i]->wsub);
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
|
first = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, &p, m->sub[i]->name + incr, 1, text);
|
MwDrawText(handle, &p, m->sub[i]->name + incr, 1, text);
|
||||||
|
|
@ -162,7 +162,6 @@ MwMenu MwMenuAdd(MwWidget handle, MwMenu menu, const char* name) {
|
||||||
new->sub = NULL;
|
new->sub = NULL;
|
||||||
new->wsub = NULL;
|
new->wsub = NULL;
|
||||||
new->keep = 0;
|
new->keep = 0;
|
||||||
new->wait = 0;
|
|
||||||
|
|
||||||
strcpy(new->name, name);
|
strcpy(new->name, name);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue