void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; /* 설정 전의 높이를 기억한다. */ /* 지정한 높이가 너무 낮거나 너무 높으면 수정한다. */ if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; /* 높이를 설정 */ /* 이하는 주로 sheets[] 의 대체 */ if (old > height) { /* 이전보다도 낮아진다. */ if (height >= 0) { /* 사이에 있는 것을 하나씩 끌어 올린다. */ for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { /* 비표시화 */ if (ctl->top > old) { /* 위에 있는 것을 하나씩 내린다. */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; /* 표시 중의 레이어가 1개 줄어들게되므로, 맨위의 높이가 줄어든다. */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } else if (old < height) { /* 이전보다 높아진다. */ if (old >= 0) { /* 사이에 있는 것을 하나씩 내린다. */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* 비표시 상태에서 표시 상태로 */ /* 위에 있는 것을 하나씩 들어 올린다. */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; /* 표시 중의 레이어가 1개 증가하므로, 맨 위의 높이가 증가한다. */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } return; }
// set the specified sheet's height, and meanwhile rearrange sheets[] according to the order of height void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; // save the old height if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; // rearrange sheets[] if (old > height) { // lower than before if (height >= 0) { // move up for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { // hide if (ctl->top > old) { // move down for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; // because reduce a sheet sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } //sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); // repaint the frame according the new sheets } else if (old < height) { if (old >= 0) { //move down for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { // from hidden to revealable // move up for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } return; }
void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; if (old > height) { if (height >= 0) { for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { if (ctl->top > old) { for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } } else if (old < height) { if (old >= 0) { for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } return; }
void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; /* 設定前の高さを記憶する */ /* 指定が低すぎや高すぎだったら、修正する */ if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; /* 高さを設定 */ /* 以下は主にsheets[]の並べ替え */ if (old > height) { /* 以前よりも低くなる */ if (height >= 0) { /* 間のものを引き上げる */ for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { /* 非表示化 */ if (ctl->top > old) { /* 上になっているものをおろす */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; /* 表示中の下じきが一つ減るので、一番上の高さが減る */ sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } } else if (old < height) { /* 以前よりも高くなる */ if (old >= 0) { /* 間のものを押し下げる */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* 非表示状態から表示状態へ */ /* 上になるものを持ち上げる */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; /* 表示中の下じきが一つ増えるので、一番上の高さが増える */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } return; }
///////////////////////////////////////////////////////////////////////////////////// //功能:设定底板高度函数 //参数: void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; /* 存储设置前的高度信息 */ /* 指定高度过高过低都要修正 */ if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; /* 设定高度 */ /* 主要是进行sheets[]的重新排列 */ if (old > height) { /* 比以前低 */ if (height >= 0) { /* 把中间的往上提 */ for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { /* 隐藏 */ if (ctl->top > old) { /* 降下来 */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; /* 由于显示中图层少了一个,所以最上面的图层的高度下降 */ sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); } } else if (old < height) { /* 比以前高 */ if (old >= 0) { /* 把中间的拉下去 */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* 由隐藏状态转为显示状态 */ /* 将已在上面的提上来 */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; /* 由于显示图层增加了一个,所以最上面的图层高度增加 */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } return; }
void sheet_updown(struct SHEET *sht, int height) { int h, old = sht->height; /* save old height value */ struct SHTCTL *ctl = sht->ctl; /* correct height value */ if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; /* set height */ /* rearrange sheets[] */ if (old > height) { /* new height lower than old value */ if (height >= 0) { /* shift the sheets in between towards up */ for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height+1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height+1, old); } else { /* height == -1, hide the sheet */ if (ctl->top > old) { /* shift sheets between old height and top towards down */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; /* top height reduced */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old-1); /* repaint */ } else if (old < height) { /* new height larger than old value */ if (old >= 0) { /* shift sheets inbetween down */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* old == -1, means from hidden status to a new height */ /* shift sheets above upwards */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; /* top height increased */ } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height,height); /* repaint */ } return; }
/* 若对算法不明白的可参考任意一本关于数据结构的书籍 */ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height) { int h, old = sht->height; /* 保存原来的高度 */ /* 如果新的高度比所有图层的最大的高度还大 则调整它 */ if (height > ctl->top + 1) { height = ctl->top + 1; } /* 如果新高度小于-1 就设置为-1 我们只需要用-1来表示隐藏就足够了 */ if (height < -1) { height = -1; } sht->height = height; /* 更新图层的高度 */ /* 对sheets[]的排列(sheets[]就是一个按高度排序的有序数组) */ if (old > height) { /* 原来的高度比新高度还要大 */ if (height >= 0) { /* 不是要隐藏原来图层 */ /* 把中间的往上提 */ for (h = old; h > height; h--) { /* 我们可以认为高度就是图层在sheets数组中的下标 */ ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; /* 调整原来sheets[]中指向的图层的高度 */ } /* 即更改原来的图层在sheets[]中的下标 */ ctl->sheets[height] = sht; /* 插入新的图层指针 */ } else { /* 隐藏原来图层 */ if (ctl->top > old) { /* 如果原来的图层不是最上层的图层 */ /* 把上面的降下来 */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; /* 调整原来sheets[]中指向的图层的高度 */ } } ctl->top--; /* 由于显示中的图层减少了一个, 所以最上层的图层高度减一 */ } /* 描绘这个图层 */ sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } else if (old < height) { /* 原来的高度比新高度还要小 */ if (old >= 0) { /* 原来的图层如果不是隐藏的 */ /* 把中间的拉下去 */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; /* 调整原来sheets[]中指向的图层的高度 */ } ctl->sheets[height] = sht; /* 插入新的图层指针 */ } else { /* 原来的图层是隐藏的 */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; /* 调整原来sheets[]中指向的图层的高度 */ } ctl->sheets[height] = sht; /* 插入新的图层指针 */ ctl->top++; /* 由于增加了一个要显示的图层,所以最上层的图层高度需要加一 */ } /* 描绘这个图层 */ sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } return; }
/* 移动图层的函数 */ void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0) { sht->vx0 = vx0; /* 设置图层新的坐标 */ sht->vy0 = vy0; if (sht->height >= 0) { /* 如果该图层不是一个隐藏图层 */ sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize); } return; }
// adjust sheet relative position void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height) { int h, old = sht->height; if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } // set height according to given sht->height = height; if (old > height) { // the sheet become lower if (height >= 0) { for (h = old; h > height; h--) { // grap behind one to front ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { // the sheet is hidden if (ctl->top > old) { for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; } //refresh the origin position sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } else if (old < height) { // the sheet become lower if (old >= 0) { for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; } sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } return; }
/* 设定底板高度 */ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height) { int h, old = sht->height; /* 存储设置前的高度信息 */ /* 如果指定的高度过高或过低,则进行修正 */ if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; /* 设定高度 */ /* 下面主要是进行heets[]的重新排序 */ if (old > height) { /* 比以前低 */ if (height >= 0) { /* 把中间的往上提 */ for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* 隐藏 */ if (ctl->top > old) { /* 把上面的降下来 */ for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; /* 由于显示中的图层减少了一个,所以最上面的图层高度下降 */ } sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } else if (old < height) { /* 比以前高 */ if (old >= 0) { /* 把中间的拉下去 */ for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { /* 由隐藏状态转为显示状态 */ /* 将已在上面的提上来 */ for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; /* 由于已显示的图层增加了1个,所以最上面的图层高度增加 */ } sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); } return; }
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0) { int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */ sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize); } return; }
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0) { int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面 */ sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize); } return; }
void sheet_slide(struct SHEET *sht, int vx0, int vy0) { int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0); sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height); } return; }
/** * @description 设置图层高度 * @param sht:欲设置高度的图层的指针 * height:欲设置的高度 */ void sheet_updown(struct SHEET *sht, int height){ struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; /* 愝掕慜偺崅偝傪婰壇偡傞 */ //TODO 高度有效修正 if (height > ctl->top + 1) { height = ctl->top + 1; } if (height < -1) { height = -1; } sht->height = height; if (old > height) { //TODO 比之前低,做下降动作 if (height >= 0) { for (h = old; h > height; h--) { ctl->sheets[h] = ctl->sheets[h - 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old); } else { if (ctl->top > old) { for (h = old; h < ctl->top; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } } ctl->top--; sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1); }//end of if (height >= 0)else } else if (old < height) { //TODO 图层做上升动作 if (old >= 0) { for (h = old; h < height; h++) { ctl->sheets[h] = ctl->sheets[h + 1]; ctl->sheets[h]->height = h; } ctl->sheets[height] = sht; } else { for (h = ctl->top; h >= height; h--) { ctl->sheets[h + 1] = ctl->sheets[h]; ctl->sheets[h + 1]->height = h + 1; } ctl->sheets[height] = sht; ctl->top++; } sheet_refreshmap(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height); } }
void sheet_slide(struct SHEET *sht, int vx0, int vy0) { int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { /* if it is active (visible) */ sheet_refreshmap(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0); sheet_refreshmap(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height); sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0, sht->height -1); //paint old area from height "0" on sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height, sht->height); //paint new area from height "sht->height" on } return; }
void sheet_slide(struct SHEET *sht, int vx0, int vy0) { struct SHTCTL *ctl = sht->ctl; int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { /* 만약 표시 중이라면 */ sheet_refreshmap(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0); sheet_refreshmap(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height); sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0, sht->height - 1); /* 새로운 레이어 정보에 따라 화면을 다시 그린다. */ sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height, sht->height); } return; }
/** * @description 平移图层 * @param sht:欲平移的图层的指针 * vx0:x方向的平移数 * vy0:y方向的平移数 */ void sheet_slide(struct SHEET *sht, int vx0, int vy0){ struct SHTCTL *ctl = sht->ctl; int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if (sht->height >= 0) { //TODO 图层高度不为-1,即正在显示,则刷新显示 sheet_refreshmap(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0); sheet_refreshmap(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height); sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0, sht->height - 1); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height, sht->height); } return; }
///////////////////////////////////////////////////////////////////////////////////// //功能:上下左右移动窗口 //参数: void sheet_slide(struct SHEET *sht, int vx0, int vy0) { struct SHTCTL *ctl = sht->ctl; int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0;//更新位置 sht->vy0 = vy0; if (sht->height >= 0) { /* 如果正在显示,按照新图层刷新画面 */ sheet_refreshmap(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0); sheet_refreshmap(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height); sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0, sht->height - 1); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height, sht->height); } return; }
void sheet_slide(struct SHTCTL* ctl, struct SHEET* sht, int vx0, int vy0) { int old_vx0, old_vy0; old_vx0 = sht->vx0; old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; if(sht->height >= 0) //非隐藏图层被移动的时候,要刷新 { /* 只更新被移动的部分 */ sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize); } return ; }
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */ sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
/* void sheet_refresh(struct SHTCTL *ctl) { int h, bx, by, vx, vy; unsigned char *buf, c, *vram = ctl->vram; struct SHEET *sht; for (h = 0; h <= ctl->top; h++) { sht = ctl->sheets[h]; buf = sht->buf; for (by = 0; by < sht->bysize; by++) { vy = sht->vy0 + by; for (bx = 0; bx < sht->bxsize; bx++) { //逐个像素进行更新 vx = sht->vx0 + bx; c = buf[by*sht->bxsize + bx]; if (c != sht->col_inv) { vram[vy*ctl->xsize + vx] = c; } } } } return; } */ void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) // 某图层重绘区域左上角和区域大小 { if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息进行刷新 */ sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
/** * @description 刷新图层 * @param sht:欲刷新的图层 * bx0、by0: */ void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1){ if (sht->height >= 0) { //TODO 图层高度不为-1,即正在显示,则刷新显示 sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0){ int old_vx0 = sht->vx0, old_vy0 = sht->vy0; sht->vx0 = vx0; sht->vy0 = vy0; // refresh only in vx0~vx1, vy0~vy1 // two step: // 1. move origin position layer // 2. add new position layer if(sht->height >= 0){ sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize); sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize); } return; }
//bx and by are coordinates of sheet buffer. void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { /* if it is active, repaint */ sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
// aim at one sheet, refresh a local area void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { // if the sheet is being showed, refresh it according to the information of new sheet sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
///////////////////////////////////////////////////////////////////////////////////// //功能:刷新屏幕函数 //参数: void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { /* 如果正在显示,按照新图层的信息刷新画面 */ sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
void sheet_refresh(struct SHTCTL *ctl, struct SHEET *sht, int bx0, int by0, int bx1, int by1) // 某图层重绘区域左上角和区域大小 { if (sht->height >= 0) { sheet_refreshsub(ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1); } return; }
/* recheck the stack and paint to vram, we need to refresh stack from the height of this layer and up */ void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { struct SHTCTL *ctl = sht->ctl; if(sht->height >= 0) { /* (bx0, by0) and (bx1, by1) are the coordinates within this sheet, need to transfer it to absolute coordinates */ sheet_refreshsub(ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) { if (sht->height >= 0) { /* 만약 표시 중이라면, 새로운 레이어 정보에 따라 화면을 다시 그린다. */ sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height); } return; }