📄 edt_rate.c
字号:
---------------------------------------------------*/
void pgup_tbl(void)
{
/***** IF THE FIRST PAGE, RETURN. *****/
if((Count-16) < 0)
{
sound_bell();
return;
}
/***** DISPLAY THE LAST PAGE. *****/
hide_finger();
brush_tbl(ITEMS, 16, 7);
Count = Count-16;
disp_tbl(&Tbltop[Count-1], Count);
locate_finger(15,1);
}
/*------------------------------------------------------
--------------------- pgdn_tbl() -------------------
Function: Change a page towards down.
Calls: clr_tbl,disp_tbl
Called by: input_data
Input: None
Output: None
Return: None
----------------------------------------------------*/
void pgdn_tbl(void)
{
UC *title = "注意:";
UC *warn = "最多只能有这么多区号!";
/***** IF MORE THAN THE MAX LENGTH, WARN AND RETURN. *****/
if(Count+15 >= Max_len)
{
warn_mesg(title, warn);
return;
}
/***** IF END OF TABLE, RETURN. *****/
if((Count+15) > Tbllen)
{
sound_bell();
return;
}
/***** DISPLAY THE NEXT PAGE. *****/
Count = Count+16;
hide_finger();
brush_tbl(ITEMS, 16, 7);
disp_tbl(&Tbltop[Count-1], Count);
locate_finger(0,1);
}
/*-------------------------------------------------------
--------------------- delet_item() ------------------
Function: Delete a item in the rate table.
Calls: clr_tbl,disp_tbl
Called by: input_data()
Input: None
Output: None
Return: None
-----------------------------------------------------*/
void delet_item(void)
{
UI i;
UI x, y, cur_pos;
UI xs, ys, xe, ye;
UC result;
UNIT_STRUCT cur_unit;
RATE_STRUCT huge *tbl;
get_current(&cur_unit);
if((Count+cur_unit.unit_x)>Tbllen)
{
sound_bell();
return;
}
/***** CLEAR THE ITEM DELETED WITH "- - -". *****/
move_finger(2, cur_unit.unit_y-1);
for(i = 0; i <= 5; i++)
{
hide_finger();
get_current(&cur_unit);
xs = cur_unit.dot_sx;
ys = cur_unit.dot_sy;
xe = cur_unit.dot_ex;
ye = cur_unit.dot_ey;
setfillstyle(1,0);
bar(xs,ys,xe,ye);
x = (cur_unit.dot_ex-cur_unit.dot_sx-8)/2+cur_unit.dot_sx;
y = (cur_unit.dot_ey-cur_unit.dot_sy-16)/2+cur_unit.dot_sy;
outf(x, y, 0, 14, "%s", "-");
move_finger(3,1);
}
/***** DISPLAY THE DELETE MENU. *****/
move_finger(2,2);
sound_alarm();
result = select_1in2(10);
/***** NOT DELETE *****/
if(!result || result==1)
{
hide_finger();
brush_tbl(ITEMS, 16, 7);
disp_tbl(&Tbltop[Count-1], Count);
echo_finger();
return;
}
/***** DELETE A ITEM *****/
tbl = &Tbltop[Count+cur_unit.unit_x-1];
cur_pos = Count+cur_unit.unit_x;
while((tbl->length) && (cur_pos<Tbllen) )
{
*tbl= *(tbl+1);
tbl++;
cur_pos++;
}
memset(&Tbltop[Tbllen-1], 0, sizeof(RATE_STRUCT));
Tbllen--;
if((Count+cur_unit.unit_x-1) < Oldend)
Oldend--;
hide_finger();
brush_tbl(ITEMS, 16, 7);
disp_tbl(&Tbltop[Count-1], Count); /* REDISPLAY */
locate_finger(cur_unit.unit_x,1);
echo_finger();
}
/*---------------------------------------------------------
--------------------- loc_page() ----------------------
Function: Locate according to the page No..
Calls: clr_tbl,disp_tbl
Called by: input_data()
Input: None
Output: None
Return: None
-------------------------------------------------------*/
void loc_page(void)
{
UL locate_no;
UI page_no;
UC result;
UC *msg="定位页号";
UC *warn="没有该页号!";
/***** DISPLAY THE PAGE LOCATE WINDOW. *****/
message_disp(8," 输入页号 Enter 确认"); /*page no.*/
pop_back(250, 295, 400, 335, 7);
draw_back(330, 304, 390, 326, 11);
outf(260, 308, 7, 0, "%s", msg);
/***** LOCATE ACCODING TO THE PAGE No. USERS INPUT. *****/
set_get_color(11, 0, 12, 11, 0);
result=get_dec(335, 306, 18, 24, 0, 3, &locate_no, 0x00);
rid_pop();
message_end();
if(!result) /* "Esc" */
return;
if(!(Tbllen%16) && Tbllen) /* calculate the pages */
page_no = Tbllen/16;
else
page_no = (UI)(Tbllen/16)+1;
if(!locate_no || locate_no > page_no)
{
warn_mesg("", warn);
return;
}
/***** DISPLAY THE PAGE. *****/
hide_finger();
brush_tbl(ITEMS, 16, 7);
Count = (UI)(locate_no-1)*16+1;
disp_tbl(&Tbltop[Count-1], Count);
locate_finger(0,1); /* LOCATTED */
}
/*------------------------------------------------------------
---------------------- search_area_no() --------------------
Function: Search according to the inputing No..
Calls: maxnum,clr_tbl,disp_tbl
Called by: input_data()
Input: None
Output: None
Return: None
-----------------------------------------------------------*/
void search_area_no(void)
{
RATE_STRUCT huge *tbl;
UC locate_no[6] = "";
UC result;
UC *msg="查找区号"; /* DING WEI QU HAO */
pop_back(250, 295, 400, 335, 7);
draw_back(330, 304, 390, 326, 11);
outf(260, 308, 7, 0, "%s", msg);
/***** LOCATE ACCODING TO THE PAGE No. USERS INPUT. *****/
set_get_color(11, 0, 12, 11, 0);
result = get_no(335, 306, 18, 24, 0, 5, locate_no, 0x00);
rid_pop();
if(!result) /* IF USER TYPE "Esc", RETRUN. */
return;
/***** Locate the position in the rate table according
to the area number user typeed. *****/
tbl = blocate_area(locate_no);
tbl++;
Count = ((UI)(tbl-Tbltop)/16)*16+1;
hide_finger();
brush_tbl(ITEMS, 16, 7);
disp_tbl(&Tbltop[Count-1], Count);
locate_finger(tbl-Tbltop-Count+1, 1); /* LOCATTED */
}
/*------------------------------------------------------
------------------- blocate_area() -------------------
Function: Locate last position smaller than input_no.
Calls: None
Called by: loc_tbl(), search_area_no()
Input: input_no -- telephone number
Output: None
Return: The position of location.
Note: the first position could not be returned, otherwise
in loc_tbl(), there could be error when tbl--
------------------------------------------------------*/
RATE_STRUCT huge *blocate_area(UC *input_no)
{
RATE_STRUCT huge *tbl, huge *tbl_top;
UI tbllen,comp_len,comp_len1,input_len;
UI position;
UI top, bottom;
int result;
tbl_top = Tbltop;
tbl = Tbltop;
tbllen = tbl_len();
input_len = strlen(input_no);
top = 0;
if(tbllen > 0)
bottom = tbllen-1;
else
bottom = 0;
/***** Compare with the first item. *****/
comp_len = maxnum(tbl->length, input_len);
comp_len1 = maxnum((tbl+1)->length, input_len);
if(memicmp(tbl->area_no,input_no,comp_len)<0 && \
memicmp((tbl+1)->area_no,input_no,comp_len1)>0)
return(tbl+1);
if(memicmp(tbl->area_no,input_no,comp_len) > 0)
return(tbl+1);
/***** Compare with the last item. *****/
comp_len = maxnum(tbl[bottom].length, input_len);
if(memicmp(tbl[bottom].area_no,input_no,comp_len) < 0)
return(&tbl[bottom]);
/***** Compare and locate in the rate table. *****/
for(;;)
{
position = (UI) (top+bottom)/2;
tbl = &tbl_top[position];
comp_len = maxnum(tbl->length, input_len);
result = memicmp(tbl->area_no,input_no,comp_len);
if(!result)
return(tbl);
if(result < 0)
{
tbl++;
comp_len = maxnum(tbl->length, input_len);
result = memicmp(tbl->area_no, input_no, comp_len);
if(!result)
return(tbl);
if(result > 0)
return(tbl-1);
top = position; /* SEARCH DOWN */
}
else
{
tbl--;
comp_len = maxnum(tbl->length, input_len);
result = memicmp(tbl->area_no, input_no, comp_len);
if(result <= 0)
return(tbl);
bottom = position; /* SEARCH UP */
}
}/* END OF FOR */
}
/* function : copy the first_rate, first_time, formal_rate and formal_time
* of the last item
* called by : input_data()
* date : 1993.11.19
*/
void copy_last_item(void)
{
int result;
UC res;
UI seq_no,num;
UI comp_len;
UL no;
UC areano_buf[9] = "";
UC *title = "注意:";
UC *warn = "该区号已有, 请重新输入!";
RATE_STRUCT huge *tbl;
UNIT_STRUCT cur_unit;
get_current(&cur_unit);
seq_no = Count+cur_unit.unit_x; /* sequence no of item being edited */
if(seq_no==1 || seq_no>Max_len)
return;
if(Tbltop[seq_no-1].length == 0) /* have not area no yet */
{
no = atol(Tbltop[seq_no-2].area_no);
no++;
ltoa(no,areano_buf,10);
res = strlen(areano_buf);
/* compare with all the area no before, to see whether there is one
* that is the same
*/
tbl = Tbltop;
num = 0;
do
{
comp_len = maxnum(res, tbl->length);
result = memicmp(tbl->area_no, areano_buf, comp_len);
/*** THE AREA No. INPUTTED ALREADY EXIST, REINPUT ***/
/* Tbltop[Count+cur_unit.unit_x-1] is the item being
* editted, so not judge it
*/
if(!result && (tbl!=&Tbltop[seq_no-1]))
{
warn_mesg(title, warn);
return;
}
tbl++;
num++;
}while(tbl->length && num<Max_len);
strcpy(Tbltop[seq_no-1].area_no,areano_buf);
Tbltop[seq_no-1].length = strlen(Tbltop[seq_no-1].area_no);
}
Tbltop[seq_no-1].first_rate = Tbltop[seq_no-2].first_rate;
Tbltop[seq_no-1].first_time = Tbltop[seq_no-2].first_time;
Tbltop[seq_no-1].formal_rate = Tbltop[seq_no-2].formal_rate;
Tbltop[seq_no-1].formal_time = Tbltop[seq_no-2].formal_time;
Tbltop[seq_no-1].add_fee = Tbltop[seq_no-2].add_fee;
hide_finger();
clr_one_row(cur_unit.unit_x);
disp_one_row(cur_unit.unit_x);
if(seq_no < Max_len)
{
move_finger(1,1);
move_finger(2,cur_unit.unit_y-1);
}
echo_finger();
Tbllen = tbl_len();
return;
}
/* function : display one row of the rate table
* date : 1993.11.19
*/
void disp_one_row(UC row)
{
UI j;
UI x, y;
UNIT_STRUCT cer_unit;
RATE_STRUCT huge *tbl;
tbl = Tbltop+Count+row-1;
cer_unit.unit_x = row;
for(j = 1; j < ITEMS; j++)
{
cer_unit.unit_y = j;
get_certain(&cer_unit);
x = cer_unit.dot_sx;
y = cer_unit.dot_sy+1;
switch(j)
{
case 1: /* AREA No. */
if(!strcmp(tbl->area_no,""))
break;
outf(x+3,y,BK_CLR,CHR_CLR,"%-8s",tbl->area_no);
break;
case 2: /* AREA NAME */
outf(x+2, y, BK_CLR, CHR_CLR, "%s", tbl->area_name);
break;
case 3: /* first_RATE */
outf(x+2, y, BK_CLR, CHR_CLR, "%6.2f", ((double)tbl->first_rate)/100);
break;
case 4: /* first time */
outf(x+12,y,BK_CLR, CHR_CLR, "%-3u", tbl->first_time);
break;
case 5: /* formal_RATE */
outf(x+2, y, BK_CLR, CHR_CLR, "%6.2f", ((double)tbl->formal_rate)/100);
break;
case 6: /* formal time */
outf(x+12,y,BK_CLR, CHR_CLR, "%-3u", tbl->formal_time);
break;
case 7: /* addtional fee */
outf(x+12, y, BK_CLR, CHR_CLR, "%4.2f", ((double)tbl->add_fee)/100);
break;
}/* END SWITCH */
}/* END FOR2 */
return;
}
/* function : clear one row the rate table
* date : 1993.11.19
*/
void clr_one_row(UC row)
{
UI j;
UI xs, ys, xe, ye;
UNIT_STRUCT cur_unit;
cur_unit.unit_x = row;
for(j = 1; j < ITEMS; j++)
{
cur_unit.unit_y = j;
get_certain(&cur_unit);
xs = cur_unit.dot_sx;
ys = cur_unit.dot_sy;
xe = cur_unit.dot_ex;
ye = cur_unit.dot_ey;
setfillstyle(1, BK_CLR);
bar(xs, ys, xe, ye);
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -