View Raw SPL
/*****************************************************************************
* *
* SETDARKMODE.SPL Copyright (C) 2024 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: sets the application scheme to dark or light mode *
* *
* Revisions: 24 Jan 2024 RRR Creation *
* *
*****************************************************************************/
#if @HELP_SETDARKMODE
SETDARKMODE
Purpose: Sets the application color scheme to dark or light mode.
Syntax: SETDARKMODE(mode, force, redraw)
mode - Optional. An integer, the dark mode setting.
0: force light mode
1: force dark mode (default)
2: follow system
force - Optional. An integer, force the default light or dark
mode application color scheme.
0: preserve user defined application colors
1: force default application color scheme (default)
redraw - Optional. An integer, redraw the application.
0: do not redraw
1: redraw application for dark mode setting (default).
Returns: An integer, the previous dark mode setting.
Example:
setdarkmode()
Forces the application to display in dark mode. System
elements such as scroll bars and buttons display in the dark
mode color scheme. Application colors such as window and
series colors are set to the default dark mode color scheme.
Example:
setdarkmode(1, 0)
Forces the application to display in dark mode as above
except user defined application colors such as window and series
colors are preserved.
Example:
setdarkmode(2)
Sets the application to dark mode if the host system is in dark
mode, else the application displays in light mode.
Remarks:
Standard light mode displays dark text on a light background.
Dark mode displays light text on a dark background.
By default, SETDARKMODE sets the system elements (e.g.
scrollbars and buttons) and application (e.g. window and
series) colors to display in dark mode then redraws the
application.
For MODE == 2, the application is set to dark mode if the host
system is set to dark mode, otherwise the system is set to light
mode.
For FORCE == 0, user defined application colors are preserved.
otherwise the application colors are set to the default color
scheme.
SETDARKMODE has no effect if the host system does not support
dark mode
See Also:
Isdarkmode
Isdarkmodesupported
Setgcolor
#endif
/* set dark mode */
setdarkmode(mode=1, force=1, redraw=1)
{
local prev;
/* 0:force light, 1:force dark, 2:follow system */
prev = setconfig("darkmode", mode);
/* updates dark mode system setting */
initsyscolors(not(force), 1);
mode = (mode == 2) ? isdarkmode() : mode;
/* set theme colors */
if (mode > 0)
{
darkmode(force, redraw);
}
else
{
lightmode(force, redraw);
}
return(prev);
}