Skip to content

Commit

Permalink
Added script function: utils.menufontsize
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jun 25, 2016
1 parent 58caa37 commit 94ff377
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
27 changes: 24 additions & 3 deletions scripting/lua_utils.cpp
Expand Up @@ -2074,8 +2074,8 @@ static int colourcube (lua_State *L) {
for (green = 0; green < 6; green++)
for (blue = 0; blue < 6; blue++)
xterm_256_colours [16 + (red * 36) + (green * 6) + blue] =
RGB (red * colour_increment,
green * colour_increment,
RGB (red * colour_increment,
green * colour_increment,
blue * colour_increment);

break;
Expand All @@ -2084,7 +2084,27 @@ static int colourcube (lua_State *L) {
} // end of switch

return 0; /* no return */
}
} // end of colourcube

static int menufontsize (lua_State *L)
{
double points = luaL_optnumber (L, 1, 0);

NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof (metrics);
SystemParametersInfo (SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);

int oldSize = - metrics.lfMenuFont.lfHeight;
if (points >= 5 && points <= 30)
{
metrics.lfMenuFont.lfHeight = - points;
SystemParametersInfo (SPI_SETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);
} // end of new size in reasonable range

lua_pushnumber (L, oldSize);

return 1; // return old size
} // end of menufontsize

#if 0
static int registry (lua_State *L)
Expand Down Expand Up @@ -2130,6 +2150,7 @@ static const struct luaL_Reg xmllib [] =
{"infotypes", infotypes},
{"inputbox", inputbox},
{"listbox", listbox},
{"menufontsize", menufontsize},
{"metaphone", metaphone},
{"msgbox", msgbox}, // msgbox - not Unicode
{"multilistbox", multilistbox},
Expand Down
1 change: 1 addition & 0 deletions scripting/methods/methods_miniwindows.cpp
Expand Up @@ -586,6 +586,7 @@ static bool bInWindowAddHotspot = false;
} // end of looping through views
} // end of added hotspot OK


bInWindowAddHotspot = false;

return status;
Expand Down

0 comments on commit 94ff377

Please sign in to comment.