seems to work
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@276 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
8532ac96ec
commit
1574d9af33
2 changed files with 27 additions and 9 deletions
|
|
@ -32,7 +32,7 @@ static int calc_length(MwWidget handle) {
|
||||||
int max = MwScrollBarGetVisibleLength(handle);
|
int max = MwScrollBarGetVisibleLength(handle);
|
||||||
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
||||||
int area = MwGetInteger(handle, MwNareaShown);
|
int area = MwGetInteger(handle, MwNareaShown);
|
||||||
if(area > MwGetInteger(handle, MwNmaxValue)) area = MwGetInteger(handle, MwNmaxValue);
|
if(area > len) area = len;
|
||||||
|
|
||||||
return max * (double)area / len;
|
return max * (double)area / len;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ typedef struct viewport {
|
||||||
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||||
viewport_t* vp = user;
|
viewport_t* vp = user;
|
||||||
int v = MwGetInteger(handle, MwNvalue);
|
int v = MwGetInteger(handle, MwNvalue);
|
||||||
|
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||||
|
int l = MwGetInteger(vp->frame, MwNheight);
|
||||||
|
v = (mv - l) * (double)v / mv;
|
||||||
|
if(v < 0) v = 0;
|
||||||
MwVaApply(vp->inframe,
|
MwVaApply(vp->inframe,
|
||||||
MwNy, -v,
|
MwNy, -v,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
@ -19,6 +23,10 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||||
static void hscroll_changed(MwWidget handle, void* user, void* call) {
|
static void hscroll_changed(MwWidget handle, void* user, void* call) {
|
||||||
viewport_t* vp = user;
|
viewport_t* vp = user;
|
||||||
int v = MwGetInteger(handle, MwNvalue);
|
int v = MwGetInteger(handle, MwNvalue);
|
||||||
|
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||||
|
int l = MwGetInteger(vp->frame, MwNwidth);
|
||||||
|
v = (mv - l) * (double)v / mv;
|
||||||
|
if(v < 0) v = 0;
|
||||||
MwVaApply(vp->inframe,
|
MwVaApply(vp->inframe,
|
||||||
MwNx, -v,
|
MwNx, -v,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
@ -28,6 +36,8 @@ static void resize(MwWidget handle) {
|
||||||
viewport_t* vp = handle->internal;
|
viewport_t* vp = handle->internal;
|
||||||
int w = MwGetInteger(handle, MwNwidth);
|
int w = MwGetInteger(handle, MwNwidth);
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
int iw, ix;
|
||||||
|
int ih, iy;
|
||||||
if(vp->vscroll == NULL) {
|
if(vp->vscroll == NULL) {
|
||||||
vp->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h - 16, NULL);
|
vp->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h - 16, NULL);
|
||||||
MwAddUserHandler(vp->vscroll, MwNchangedHandler, vscroll_changed, vp);
|
MwAddUserHandler(vp->vscroll, MwNchangedHandler, vscroll_changed, vp);
|
||||||
|
|
@ -64,13 +74,27 @@ static void resize(MwWidget handle) {
|
||||||
vp->inframe = MwCreateWidget(MwFrameClass, "inframe", vp->frame, 0, 0, w - 16, h - 16);
|
vp->inframe = MwCreateWidget(MwFrameClass, "inframe", vp->frame, 0, 0, w - 16, h - 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iw = MwGetInteger(vp->inframe, MwNwidth);
|
||||||
|
ih = MwGetInteger(vp->inframe, MwNheight);
|
||||||
|
|
||||||
|
iy = MwGetInteger(vp->vscroll, MwNvalue);
|
||||||
|
if(iy > ih) iy = ih;
|
||||||
MwVaApply(vp->vscroll,
|
MwVaApply(vp->vscroll,
|
||||||
MwNareaShown, h - 16,
|
MwNareaShown, h - 16,
|
||||||
|
MwNmaxValue, ih,
|
||||||
|
MwNvalue, iy,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
ix = MwGetInteger(vp->hscroll, MwNvalue);
|
||||||
|
if(ix > iw) ix = iw;
|
||||||
MwVaApply(vp->hscroll,
|
MwVaApply(vp->hscroll,
|
||||||
MwNareaShown, w - 16,
|
MwNareaShown, w - 16,
|
||||||
|
MwNmaxValue, iw,
|
||||||
|
MwNvalue, ix,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
vscroll_changed(vp->vscroll, vp, NULL);
|
||||||
|
hscroll_changed(vp->hscroll, vp, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int create(MwWidget handle) {
|
||||||
|
|
@ -131,16 +155,10 @@ MwWidget MwViewportGetViewport(MwWidget handle) {
|
||||||
void MwViewportSetSize(MwWidget handle, int w, int h) {
|
void MwViewportSetSize(MwWidget handle, int w, int h) {
|
||||||
viewport_t* vp = handle->internal;
|
viewport_t* vp = handle->internal;
|
||||||
|
|
||||||
MwVaApply(vp->vscroll,
|
|
||||||
MwNmaxValue, h,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
MwVaApply(vp->hscroll,
|
|
||||||
MwNmaxValue, w,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
MwVaApply(vp->inframe,
|
MwVaApply(vp->inframe,
|
||||||
MwNwidth, w,
|
MwNwidth, w,
|
||||||
MwNheight, h,
|
MwNheight, h,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
resize(handle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue