From 787948ff2d35c64dcc2520e36b38bd286cf447f9 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sat, 20 Feb 2021 13:52:07 -0500 Subject: [PATCH] Modifed some files to make the scrollbar widths scale with the font sizes and icons, depending on screen resolution. --- events.c | 34 ++++++++++++++++++++++++++-------- filelist.c | 15 ++++++++++++--- help.c | 28 +++++++++++++++++++++++----- lib/tcl/wrapper.tcl | 18 ++++++++++-------- 4 files changed, 71 insertions(+), 24 deletions(-) diff --git a/events.c b/events.c index 4723482..281885f 100644 --- a/events.c +++ b/events.c @@ -522,11 +522,20 @@ void drawhbar(xcWidget bar, caddr_t clientdata, caddr_t calldata) Window bwin; float frac; long rleft, rright, rmid; + int sbarsize; + char *scale; UNUSED(clientdata); UNUSED(calldata); if (!xcIsRealized(bar)) return; if (xobjs.suspend >= 0) return; +#ifdef TCL_WRAPPER + scale = Tcl_GetVar2(xcinterp, "XCOps", "scale", TCL_GLOBAL_ONLY); + sbarsize = SBARSIZE * atoi(scale); +#else + sbarsize = SBARSIZE; +#endif + bwin = xcWindow(bar); if (topobject->bbox.width > 0) { @@ -547,13 +556,13 @@ void drawhbar(xcWidget bar, caddr_t clientdata, caddr_t calldata) XSetFunction(dpy, areawin->gc, GXcopy); XSetForeground(dpy, areawin->gc, colorlist[BARCOLOR].color.pixel); if (rmid > 0 && rleft > 0) - XClearArea(dpy, bwin, 0, 0, (int)rleft, SBARSIZE, FALSE); + XClearArea(dpy, bwin, 0, 0, (int)rleft, sbarsize, FALSE); XFillRectangle(dpy, bwin, areawin->gc, (int)rleft + 1, 1, - (int)(rright - rleft), SBARSIZE - 1); + (int)(rright - rleft), sbarsize - 1); if (rright > rmid) XClearArea(dpy, bwin, (int)rright + 1, 0, areawin->width - - (int)rright, SBARSIZE, FALSE); - XClearArea(dpy, bwin, (int)rmid - 1, 1, 3, SBARSIZE, FALSE); + - (int)rright, sbarsize, FALSE); + XClearArea(dpy, bwin, (int)rmid - 1, 1, 3, sbarsize, FALSE); XSetForeground(dpy, areawin->gc, colorlist[areawin->gccolor].color.pixel); } @@ -566,9 +575,18 @@ void drawvbar(xcWidget bar, caddr_t clientdata, caddr_t calldata) { Window bwin = xcWindow(bar); float frac; + char *scale; + int sbarsize; long rtop, rbot, rmid; UNUSED(clientdata); UNUSED(calldata); +#ifdef TCL_WRAPPER + scale = Tcl_GetVar2(xcinterp, "XCOps", "scale", TCL_GLOBAL_ONLY); + sbarsize = SBARSIZE * atoi(scale); +#else + sbarsize = SBARSIZE; +#endif + if (!xcIsRealized(bar)) return; if (xobjs.suspend >= 0) return; @@ -590,13 +608,13 @@ void drawvbar(xcWidget bar, caddr_t clientdata, caddr_t calldata) XSetFunction(dpy, areawin->gc, GXcopy); XSetForeground(dpy, areawin->gc, colorlist[BARCOLOR].color.pixel); if (rmid > 0 && rtop > 0) - XClearArea(dpy, bwin, 0, 0, SBARSIZE, (int)rtop, FALSE); - XFillRectangle(dpy, bwin, areawin->gc, 0, (int)rtop + 2, SBARSIZE, + XClearArea(dpy, bwin, 0, 0, sbarsize, (int)rtop, FALSE); + XFillRectangle(dpy, bwin, areawin->gc, 0, (int)rtop + 2, sbarsize, (int)(rbot - rtop)); if (rbot > rmid) - XClearArea(dpy, bwin, 0, (int)rbot + 1, SBARSIZE, areawin->height + XClearArea(dpy, bwin, 0, (int)rbot + 1, sbarsize, areawin->height - (int)rbot, FALSE); - XClearArea(dpy, bwin, 0, (int)rmid - 1, SBARSIZE, 3, FALSE); + XClearArea(dpy, bwin, 0, (int)rmid - 1, sbarsize, 3, FALSE); XSetForeground(dpy, areawin->gc, colorlist[areawin->gccolor].color.pixel); } diff --git a/filelist.c b/filelist.c index f84130a..5f7a132 100644 --- a/filelist.c +++ b/filelist.c @@ -814,10 +814,19 @@ void genfilelist(xcWidget parent, popupstruct *okaystruct, Dimension width) xcWidget listarea, lscroll, entertext, dofilter; short n = 0; int wwidth; + int sbarsize; + +#ifdef TCL_WRAPPER + char *scale; + scale = Tcl_GetVar2(xcinterp, "XCOps", "scale", TCL_GLOBAL_ONLY); + sbarsize = SBARSIZE * atoi(scale); +#else + sbarsize = SBARSIZE; +#endif XtnSetArg(XtNx, 20); XtnSetArg(XtNy, FILECHARHEIGHT - 10); - XtnSetArg(XtNwidth, width - SBARSIZE - 40); + XtnSetArg(XtNwidth, width - sbarsize - 40); XtnSetArg(XtNheight, LISTHEIGHT - FILECHARHEIGHT); XtnSetArg(XtNfont, appdata.filefont); @@ -836,9 +845,9 @@ void genfilelist(xcWidget parent, popupstruct *okaystruct, Dimension width) flstart = 0; okaystruct->filew = listarea; - XtnSetArg(XtNx, width - SBARSIZE - 20); + XtnSetArg(XtNx, width - sbarsize - 20); XtnSetArg(XtNy, FILECHARHEIGHT - 10); - XtnSetArg(XtNwidth, SBARSIZE); + XtnSetArg(XtNwidth, sbarsize); XtnSetArg(XtNheight, LISTHEIGHT - FILECHARHEIGHT); XtnSetArg(XtNfont, appdata.xcfont); diff --git a/help.c b/help.c index 64f6449..bc1d027 100644 --- a/help.c +++ b/help.c @@ -311,9 +311,18 @@ void starthelp(xcWidget button, caddr_t clientdata, caddr_t calldata) Dimension areawidth, bwidth, pheight; Position xpos, ypos; u_int xmax, ymax; + char *scale; + int sbarsize; if (help_up) return; /* no multiple help windows */ +#ifdef TCL_WRAPPER + scale = Tcl_GetVar2(xcinterp, "XCOps", "scale", TCL_GLOBAL_ONLY); + sbarsize = SBARSIZE * atoi(scale); +#else + sbarsize = SBARSIZE; +#endif + /* for positioning the help window outside of the xcircuit */ /* window, get information about the display width and height */ /* and the xcircuit window. */ @@ -338,7 +347,7 @@ void starthelp(xcWidget button, caddr_t clientdata, caddr_t calldata) /* Use the pixmap size to size the help window */ - if (xpos + helpwidth + SBARSIZE > xmax) xpos = xmax - helpwidth - SBARSIZE - 4; + if (xpos + helpwidth + sbarsize > xmax) xpos = xmax - helpwidth - sbarsize - 4; if (ypos + helpheight > ymax) ypos = ymax - helpheight - 4; if (ypos < 4) ypos = 4; @@ -371,7 +380,7 @@ void starthelp(xcWidget button, caddr_t clientdata, caddr_t calldata) help2, wargs, n); n = 0; /* Create scrollbar */ - XtnSetArg(XtNwidth, SBARSIZE); + XtnSetArg(XtNwidth, sbarsize); XtnSetArg(XtNxRefWidget, hspace); XtnSetArg(XtNxAddWidth, True); XtnSetArg(XtNyRefWidget, cancelbutton); @@ -443,6 +452,15 @@ void showhsb(xcWidget hsb, caddr_t clientdata, caddr_t calldata) Dimension sheight; int pstart, pheight; short n = 0; + int sbarsize; + +#ifdef TCL_WRAPPER + char *scale; + scale = Tcl_GetVar2(xcinterp, "XCOps", "scale", TCL_GLOBAL_ONLY); + sbarsize = SBARSIZE * atoi(scale); +#else + sbarsize = SBARSIZE; +#endif if (helppix == (Pixmap)NULL) printhelppix(); if (helpheight == 0) helpheight = 1; @@ -452,12 +470,12 @@ void showhsb(xcWidget hsb, caddr_t clientdata, caddr_t calldata) if (pheight < 3) pheight = 3; - XClearArea(dpy, hwin, 0, 0, SBARSIZE, pstart, False); - XClearArea(dpy, hwin, 0, pstart + pheight, SBARSIZE, + XClearArea(dpy, hwin, 0, 0, sbarsize, pstart, False); + XClearArea(dpy, hwin, 0, pstart + pheight, sbarsize, hheight - (pstart + pheight), False); XSetForeground(dpy, hgc, colorlist[BARCOLOR].color.pixel); - XFillRectangle(dpy, hwin, hgc, 0, pstart, SBARSIZE, pheight); + XFillRectangle(dpy, hwin, hgc, 0, pstart, sbarsize, pheight); } /*----------------------------------------------*/ diff --git a/lib/tcl/wrapper.tcl b/lib/tcl/wrapper.tcl index 21e146e..9005e92 100644 --- a/lib/tcl/wrapper.tcl +++ b/lib/tcl/wrapper.tcl @@ -48,9 +48,13 @@ proc xcircuit::new_window { name } { set drawing ${name}.mainframe.mainarea.drawing simple $drawing -bg white -commandproc "focus $drawing ; set XCOps(focus) $name" - simple ${name}.mainframe.mainarea.sbleft -width 13 - simple ${name}.mainframe.mainarea.sbbottom -height 13 - simple ${name}.mainframe.mainarea.corner -width 13 -height 13 + if [catch {set XCOps(scale)}] { + set XCOps(scale) [expr {int([font measure TkDefaultFont M] / 10)}] + } + set sbsize [expr {2 + 13 * $XCOps(scale)}] + simple ${name}.mainframe.mainarea.sbleft -width $sbsize + simple ${name}.mainframe.mainarea.sbbottom -height $sbsize + simple ${name}.mainframe.mainarea.corner -width $sbsize -height $sbsize # The drawing area and its scrollbars @@ -2234,9 +2238,6 @@ proc xcircuit::maketoolimages {} { set XCOps(tools) [list pn w b a s t mv cp e d2 cw ccw fx fy r pu2 po2 mk pz \ uj co bd fi pm pa li yp pl z4 z5 i] - if [catch {set XCOps(scale)}] { - set XCOps(scale) [expr {int([font measure TkDefaultFont M] / 10)}] - } puts stdout "XCOps(scale) set to $XCOps(scale)" set gsize [expr {int($XCOps(scale) * 20)}] set gscale [expr {int($XCOps(scale))}] @@ -3280,6 +3281,7 @@ proc scrollboth { lists args } { #----------------------------------------------------------------- proc xcircuit::makehelpwindow {} { + global XCOps toplevel .help -bg beige wm group .help . wm withdraw .help @@ -3296,9 +3298,9 @@ proc xcircuit::makehelpwindow {} { pack .help.title.dbut -side right -ipadx 10 listbox .help.listwin.func -yscrollcommand ".help.listwin.sb set" \ - -setgrid 1 -height 20 + -setgrid 1 -height [expr {20 * $XCOps(scale)}] listbox .help.listwin.keys -yscrollcommand ".help.listwin.sb set" \ - -setgrid 1 -height 20 + -setgrid 1 -height [expr {20 * $XCOps(scale)}] scrollbar .help.listwin.sb -orient vertical -command \ [list scrollboth [list .help.listwin.func .help.listwin.keys]] message .help.listwin.win -width 200 -justify left -anchor n \ -- 2.11.4.GIT