Commit 129847a6 authored by deuce's avatar deuce
Browse files

Put all drawing characters into a redefinable structure to allow overriding

(for example, when other fonts are used).
parent 748d3e9a
......@@ -277,6 +277,60 @@ typedef struct {
uchar* buf;
} win_t;
typedef struct {
char background;
char help_char;
char close_char;
char up_arrow;
char down_arrow;
char button_left;
char button_right;
char list_top_left;
char list_top;
char list_top_right;
char list_separator_left;
char list_separator_right;
char list_horizontal_separator;
char list_left;
char list_right;
char list_bottom_left;
char list_bottom_right;
char list_bottom;
char list_scrollbar_separator;
char input_top_left;
char input_top;
char input_top_right;
char input_left;
char input_right;
char input_bottom_left;
char input_bottom_right;
char input_bottom;
char popup_top_left;
char popup_top;
char popup_top_right;
char popup_left;
char popup_right;
char popup_bottom_left;
char popup_bottom_right;
char popup_bottom;
char help_top_left;
char help_top;
char help_top_right;
char help_left;
char help_right;
char help_bottom_left;
char help_bottom_right;
char help_bottom;
char help_titlebreak_left;
char help_titlebreak_right;
char help_hitanykey_left;
char help_hitanykey_right;
} uifc_graphics_t;
typedef struct {
/****************************************************************************/
/* Size of the structure (for version compatibility verification). */
......@@ -342,6 +396,11 @@ typedef struct {
/****************************************************************************/
BOOL initialized;
/****************************************************************************/
/* Custom drawing characters */
/****************************************************************************/
uifc_graphics_t *chars;
/****************************************************************************/
/* Exit/uninitialize function. */
/****************************************************************************/
......
......@@ -103,6 +103,60 @@ static void reset_dynamic(void) {
save_menu_opts=-1;
}
static uifc_graphics_t default_chars = {
.background=0xb0,
.help_char='?',
.close_char=0xfe,
.up_arrow=30,
.down_arrow=31,
.button_left='[',
.button_right=']',
.list_top_left=0xc9,
.list_top=0xcd,
.list_top_right=0xbb,
.list_separator_left=0xcc,
.list_separator_right=0xb9,
.list_horizontal_separator=0xcd,
.list_left=0xba,
.list_right=0xba,
.list_bottom_left=0xc8,
.list_bottom_right=0xbc,
.list_bottom=0xcd,
.list_scrollbar_separator=0xb3,
.input_top_left=0xc9,
.input_top=0xcd,
.input_top_right=0xbb,
.input_left=0xba,
.input_right=0xba,
.input_bottom_left=0xc8,
.input_bottom_right=0xbc,
.input_bottom=0xcd,
.popup_top_left=0xda,
.popup_top=0xc4,
.popup_top_right=0xbf,
.popup_left=0xb3,
.popup_right=0xb3,
.popup_bottom_left=0xc0,
.popup_bottom_right=0xd9,
.popup_bottom=0xc4,
.help_top_left=0xda,
.help_top=0xc4,
.help_top_right=0xbf,
.help_left=0xb3,
.help_right=0xb3,
.help_bottom_left=0xc0,
.help_bottom_right=0xd9,
.help_bottom=0xc4,
.help_titlebreak_left=0xb4,
.help_titlebreak_right=0xc3,
.help_hitanykey_left=0xb4,
.help_hitanykey_right=0xc3,
};
/****************************************************************************/
/* Initialization function, see uifc.h for details. */
/* Returns 0 on success. */
......@@ -155,6 +209,8 @@ int UIFCCALL uifcini32(uifcapi_t* uifcapi)
return(-1);
api=uifcapi;
if (api->chars == NULL)
api->chars = &default_chars;
/* install function handlers */
api->bail=uifcbail;
......@@ -270,7 +326,7 @@ int UIFCCALL uifcini32(uifcapi_t* uifcapi)
return(-1);
}
for(i=0;i<blk_scrn_len;i+=2) {
blk_scrn[i]='';
blk_scrn[i]=api->chars->background;
blk_scrn[i+1]=api->cclr|(api->bclr<<4);
}
......@@ -725,24 +781,24 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
ptr=tmp_buffer;
if(!(mode&WIN_NOBRDR)) {
*(ptr++)='';
*(ptr++)=api->chars->list_top_left;
*(ptr++)=hclr|(bclr<<4);
if(api->mode&UIFC_MOUSE) {
*(ptr++)='[';
*(ptr++)=api->chars->button_left;
*(ptr++)=hclr|(bclr<<4);
/* *(ptr++)=''; */
*(ptr++)=0xfe;
*(ptr++)=api->chars->close_char;
*(ptr++)=lclr|(bclr<<4);
*(ptr++)=']';
*(ptr++)=api->chars->button_right;
*(ptr++)=hclr|(bclr<<4);
i=3;
if(bline&BL_HELP) {
*(ptr++)='[';
*(ptr++)=api->chars->button_left;
*(ptr++)=hclr|(bclr<<4);
*(ptr++)='?';
*(ptr++)=api->chars->help_char;
*(ptr++)=lclr|(bclr<<4);
*(ptr++)=']';
*(ptr++)=api->chars->button_right;
*(ptr++)=hclr|(bclr<<4);
i+=3;
}
......@@ -756,12 +812,12 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
i=0;
for(;i<width-2;i++) {
*(ptr++)='';
*(ptr++)=api->chars->list_top;
*(ptr++)=hclr|(bclr<<4);
}
*(ptr++)='';
*(ptr++)=api->chars->list_top_right;
*(ptr++)=hclr|(bclr<<4);
*(ptr++)='';
*(ptr++)=api->chars->list_left;
*(ptr++)=hclr|(bclr<<4);
a=title_len;
b=(width-a-1)/2;
......@@ -777,15 +833,15 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
*(ptr++)=' ';
*(ptr++)=hclr|(bclr<<4);
}
*(ptr++)='';
*(ptr++)=api->chars->list_right;
*(ptr++)=hclr|(bclr<<4);
*(ptr++)='';
*(ptr++)=api->chars->list_separator_left;
*(ptr++)=hclr|(bclr<<4);
for(i=0;i<width-2;i++) {
*(ptr++)='';
*(ptr++)=api->chars->list_horizontal_separator;
*(ptr++)=hclr|(bclr<<4);
}
*(ptr++)='';
*(ptr++)=api->chars->list_separator_right;
*(ptr++)=hclr|(bclr<<4);
}
......@@ -828,12 +884,12 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
longopt=0;
while(j<height-vbrdrsize) {
if(!(mode&WIN_NOBRDR)) {
*(ptr++)='';
*(ptr++)=api->chars->list_left;
*(ptr++)=hclr|(bclr<<4);
}
*(ptr++)=' ';
*(ptr++)=hclr|(bclr<<4);
*(ptr++)='';
*(ptr++)=api->chars->list_scrollbar_separator;
*(ptr++)=lclr|(bclr<<4);
if(i==(*cur))
a=lbclr;
......@@ -858,20 +914,20 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
c++;
}
if(!(mode&WIN_NOBRDR)) {
*(ptr++)='';
*(ptr++)=api->chars->list_right;
*(ptr++)=hclr|(bclr<<4);
}
i++;
j++;
}
if(!(mode&WIN_NOBRDR)) {
*(ptr++)='';
*(ptr++)=api->chars->list_bottom_left;
*(ptr++)=hclr|(bclr<<4);
for(i=0;i<width-2;i++) {
*(ptr++)='';
*(ptr++)=api->chars->list_bottom;
*(ptr++)=hclr|(bclr<<4);
}
*(ptr++)='';
*(ptr++)=api->chars->list_bottom_right;
*(ptr)=hclr|(bclr<<4); /* Not incremented to shut ot BCC */
}
puttext(s_left+left,s_top+top,s_left+left+width-1
......@@ -884,14 +940,14 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
|| (bar && ((*cur)-(*bar))+(height-vbrdrsize)<opts))) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
textattr(lclr|(bclr<<4));
putch(31); /* put down arrow */
putch(api->chars->down_arrow); /* put down arrow */
textattr(hclr|(bclr<<4));
}
if(bar && (*bar)!=(*cur)) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
textattr(hclr|(bclr<<4));
}
......@@ -1126,7 +1182,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
textattr(lclr|(bclr<<4));
putch(' '); /* Delete the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(31); /* put the down arrow */
putch(api->chars->down_arrow); /* put the down arrow */
uprintf(s_left+left+lbrdrwidth+2,s_top+top+tbrdrwidth
,lbclr
,"%-*.*s",width-hbrdrsize-2,width-hbrdrsize-2,option[0]);
......@@ -1163,7 +1219,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if(!(*cur) && opts+vbrdrsize>optheight) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth); /* like end */
textattr(lclr|(bclr<<4));
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(' '); /* delete the down arrow */
for(i=(opts+vbrdrsize)-optheight,j=0;i<opts;i++,j++)
......@@ -1204,7 +1260,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if((*cur)+optheight-vbrdrsize==opts-1) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
textattr(lclr|(bclr<<4));
putch(31); /* put the dn arrow */
putch(api->chars->down_arrow); /* put the dn arrow */
}
y++;
scroll_text(s_left+left+lbrdrwidth+1,s_top+top+tbrdrwidth
......@@ -1234,12 +1290,12 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
if(*cur) /* Scroll mode */
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
else
putch(' '); /* delete the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
if(opts >= height-tbrdrwidth && *cur + height - vbrdrsize < opts)
putch(31); /* put the down arrow */
putch(api->chars->down_arrow); /* put the down arrow */
else
putch(' '); /* delete the down arrow */
for(i=*cur,j=0;i<=*cur-vbrdrsize-1+optheight;i++,j++)
......@@ -1260,12 +1316,12 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
if(*cur>height-vbrdrsize-1) /* Scroll mode */
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
else
putch(' '); /* delete the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
if(*cur < opts-1)
putch(31); /* put the down arrow */
putch(api->chars->down_arrow); /* put the down arrow */
else
putch(' '); /* delete the down arrow */
for(i=*cur+vbrdrsize+1-optheight,j=0;i<=*cur;i++,j++)
......@@ -1280,7 +1336,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if(opts+vbrdrsize>height) { /* Scroll mode */
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(' '); /* delete the down arrow */
for(i=(opts+vbrdrsize)-height,j=0;i<opts;i++,j++)
......@@ -1319,7 +1375,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
textattr(lclr|(bclr<<4));
putch(' '); /* Delete the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(31); /* put the down arrow */
putch(api->chars->down_arrow); /* put the down arrow */
uprintf(s_left+left+lbrdrwidth+2,s_top+top+tbrdrwidth
,lbclr
,"%-*.*s",width-hbrdrsize-2,width-hbrdrsize-2,option[0]);
......@@ -1364,7 +1420,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if((*cur)+vbrdrsize==height) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
}
y--;
/* gotoxy(1,1); cprintf("\rdebug: %4d ",__LINE__); */
......@@ -1518,7 +1574,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
(*cur)=j;
gotoxy(s_left+left+lbrdrwidth,s_top+top+tbrdrwidth);
textattr(lclr|(bclr<<4));
putch(30); /* put the up arrow */
putch(api->chars->up_arrow); /* put the up arrow */
if((*cur)==opts-1) {
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(' '); /* delete the down arrow */
......@@ -1540,7 +1596,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if(!(*cur))
putch(' '); /* Delete the up arrow */
gotoxy(s_left+left+lbrdrwidth,s_top+top+height-bbrdrwidth-1);
putch(31); /* put the down arrow */
putch(api->chars->down_arrow); /* put the down arrow */
uprintf(s_left+left+lbrdrwidth+2,s_top+top+tbrdrwidth
,lbclr
,"%-*.*s",width-hbrdrsize-2,width-hbrdrsize-2,option[(*cur)]);
......@@ -1727,28 +1783,28 @@ int uinput(int mode, int left, int top, char *inprompt, char *str,
i=0;
if(!(mode&WIN_NOBRDR)) {
in_win[i++]='';
in_win[i++]=api->chars->input_top_left;
in_win[i++]=api->hclr|(api->bclr<<4);
for(j=1;j<width-1;j++) {
in_win[i++]='';
in_win[i++]=api->chars->input_top;
in_win[i++]=api->hclr|(api->bclr<<4);
}
if(api->mode&UIFC_MOUSE && width>6) {
j=2;
in_win[j++]='[';
in_win[j++]=api->chars->button_left;
in_win[j++]=api->hclr|(api->bclr<<4);
/* in_win[4]=''; */
in_win[j++]=0xfe;
in_win[j++]=api->chars->close_char;
in_win[j++]=api->lclr|(api->bclr<<4);
in_win[j++]=']';
in_win[j++]=api->chars->button_right;
in_win[j++]=api->hclr|(api->bclr<<4);
l=3;
if(api->helpbuf!=NULL || api->helpixbfile[0]!=0) {
in_win[j++]='[';
in_win[j++]=api->chars->button_left;
in_win[j++]=api->hclr|(api->bclr<<4);
in_win[j++]='?';
in_win[j++]=api->chars->help_char;
in_win[j++]=api->lclr|(api->bclr<<4);
in_win[j++]=']';
in_win[j++]=api->chars->button_right;
in_win[j++]=api->hclr|(api->bclr<<4);
l+=3;
}
......@@ -1759,9 +1815,9 @@ int uinput(int mode, int left, int top, char *inprompt, char *str,
api->helpend=s_left+left+l;
}
in_win[i++]='';
in_win[i++]=api->chars->input_top_right;
in_win[i++]=api->hclr|(api->bclr<<4);
in_win[i++]='';
in_win[i++]=api->chars->input_right;
in_win[i++]=api->hclr|(api->bclr<<4);
}
......@@ -1786,15 +1842,15 @@ int uinput(int mode, int left, int top, char *inprompt, char *str,
}
if(!(mode&WIN_NOBRDR)) {
in_win[i++]='';
in_win[i++]=api->chars->input_right;
in_win[i++]=api->hclr|(api->bclr<<4);
in_win[i++]='';
in_win[i++]=api->chars->input_bottom_left;
in_win[i++]=api->hclr|(api->bclr<<4);
for(j=1;j<width-1;j++) {
in_win[i++]='';
in_win[i++]=api->chars->input_bottom;
in_win[i++]=api->hclr|(api->bclr<<4);
}
in_win[i++]='';
in_win[i++]=api->chars->input_bottom_right;
in_win[i]=api->hclr|(api->bclr<<4); /* I is not incremented to shut up BCC */
}
puttext(s_left+left,s_top+top,s_left+left+width-1
......@@ -2376,11 +2432,11 @@ void upop(char *str)
memset(buf,' ',25*3*2);
for(i=1;i<26*3*2;i+=2)
buf[i]=(api->hclr|(api->bclr<<4));
buf[0]='';
buf[0]=api->chars->popup_top_left;
for(i=2;i<25*2;i+=2)
buf[i]='';
buf[i]=''; i+=2;
buf[i]=''; i+=2;
buf[i]=api->chars->popup_top;
buf[i]=api->chars->popup_top_right; i+=2;
buf[i]=api->chars->popup_left; i+=2;
i+=2;
k=strlen(str);
i+=(((23-k)/2)*2);
......@@ -2389,11 +2445,11 @@ void upop(char *str)
buf[i+1]|=BLINK;
}
i=((25*2)+1)*2;
buf[i]=''; i+=2;
buf[i]=''; i+=2;
buf[i]=api->chars->popup_right; i+=2;
buf[i]=api->chars->popup_bottom_left; i+=2;
for(;i<((26*3)-1)*2;i+=2)
buf[i]='';
buf[i]='';
buf[i]=api->chars->popup_bottom;
buf[i]=api->chars->popup_bottom_right;
/* puttext(28,12,53,14,buf); */
puttext((api->scrn_width-26+1)/2+1,(api->scrn_len-3+1)/2+1
......@@ -2473,46 +2529,46 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
memset(tmp_buffer2,' ',width*height*2);
for(i=1;i<width*height*2;i+=2)
tmp_buffer2[i]=(api->hclr|(api->bclr<<4));
tmp_buffer2[0]='';
tmp_buffer2[0]=api->chars->help_top_left;
j=title_len;
if(j>width-6) {
*(title+width-6)=0;
j=width-6;
}
for(i=2;i<(width-j);i+=2)
tmp_buffer2[i]='';
tmp_buffer2[i]=api->chars->help_top;
if((api->mode&UIFC_MOUSE) && (!(mode&WIN_DYN))) {
tmp_buffer2[2]='[';
tmp_buffer2[2]=api->chars->button_left;
tmp_buffer2[3]=api->hclr|(api->bclr<<4);
/* tmp_buffer2[4]=''; */
tmp_buffer2[4]=0xfe;
tmp_buffer2[4]=api->chars->close_char;
tmp_buffer2[5]=api->lclr|(api->bclr<<4);
tmp_buffer2[6]=']';
tmp_buffer2[6]=api->chars->button_right;
tmp_buffer2[7]=api->hclr|(api->bclr<<4);
/* Buttons are ignored - leave it this way to not confuse stuff from help() */
}
tmp_buffer2[i]=''; i+=4;
tmp_buffer2[i]=api->chars->help_titlebreak_left; i+=4;
for(p=title;*p;p++) {
tmp_buffer2[i]=*p;
i+=2;
}
i+=2;
tmp_buffer2[i]=''; i+=2;
tmp_buffer2[i]=api->chars->help_titlebreak_right; i+=2;
for(j=i;j<((width-1)*2);j+=2)
tmp_buffer2[j]='';
tmp_buffer2[j]=api->chars->help_top;
i=j;
tmp_buffer2[i]=''; i+=2;
tmp_buffer2[i]=api->chars->help_top_right; i+=2;
j=i; /* leave i alone */
for(k=0;k<(height-2);k++) { /* the sides of the box */
tmp_buffer2[j]=''; j+=2;
tmp_buffer2[j]=api->chars->help_left; j+=2;
j+=((width-2)*2);
tmp_buffer2[j]=''; j+=2;
tmp_buffer2[j]=api->chars->help_right; j+=2;
}
tmp_buffer2[j]=''; j+=2;
tmp_buffer2[j]=api->chars->help_bottom_left; j+=2;
if(!(mode&WIN_DYN) && (width>31)) {
for(k=j;k<j+(((width-4)/2-13)*2);k+=2)
tmp_buffer2[k]='';
tmp_buffer2[k]=''; k+=4;
tmp_buffer2[k]=api->chars->help_bottom;
tmp_buffer2[k]=api->chars->help_hitanykey_left; k+=4;
tmp_buffer2[k]='H'; k+=2;
tmp_buffer2[k]='i'; k+=2;
tmp_buffer2[k]='t'; k+=4;
......@@ -2532,16 +2588,16 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
tmp_buffer2[k]='n'; k+=2;
tmp_buffer2[k]='u'; k+=2;
tmp_buffer2[k]='e'; k+=4;
tmp_buffer2[k]=''; k+=2;
tmp_buffer2[k]=api->chars->help_hitanykey_right; k+=2;
for(j=k;j<k+(((width-4)/2-12)*2);j+=2)
tmp_buffer2[j]='';
tmp_buffer2[j]=api->chars->help_bottom;
}
else {
for(k=j;k<j+((width-2)*2);k+=2)
tmp_buffer2[k]='';
tmp_buffer2[k]=api->chars->help_bottom;
j=k;
}
tmp_buffer2[j]='';
tmp_buffer2[j]=api->chars->help_bottom_right;
puttext(left,top+1,left+width-1,top+height,tmp_buffer2);
}
len=strlen(hbuf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment