#include "Settings.h"
#include <shlobj.h>
#include <shlwapi.h>
#include <time.h>
#include <locale.h>
#include <gdiplus.h>
using namespace Gdiplus;
Settings::Settings()
{
Wildcard = new StyleItem;
Toolbar = new StyleItem;
ToolbarLabel = new StyleItem;
ToolbarWindowLabel = new StyleItem;
ToolbarClock = new StyleItem;
ToolbarButton = new StyleItem;
ToolbarButtonPressed = new StyleItem;
ToolbarBorder = new StyleItem;
MenuTitle = new StyleItem;
MenuFrame = new StyleItem;
MenuActive = new StyleItem;
MenuGrip = new StyleItem;
MenuFrameBullet = new StyleItem;
MenuActiveBullet = new StyleItem;
MenuIndicator = new StyleItem;
MenuSeparator = new StyleItem;
MenuFrameBorder = new StyleItem;
Dock = new StyleItem;
DockBorder = new StyleItem;
ActiveTask = new StyleItem;
InactiveTask = new StyleItem;
FlashingTask = new StyleItem;
Console = new StyleItem;
WindowTitleFocus = new StyleItem;
WindowTitleUnfocus = new StyleItem;
WindowLabelFocus = new StyleItem;
WindowLabelUnfocus = new StyleItem;
WindowButtonFocus = new StyleItem;
WindowButtonUnfocus = new StyleItem;
WindowButtonPressed = new StyleItem;
WindowGripFocus = new StyleItem;
WindowGripUnfocus = new StyleItem;
WindowHandleFocus = new StyleItem;
WindowHandleUnfocus = new StyleItem;
ExternalHardware = new StyleItem;
InitStyleItems();
borderWidth = 0;
borderColor = 0;
bevelWidth = 0;
handleHeight = 0;
frameWidth = 0;
bbrcFile[0] = 0;
xobrcFile[0] = 0;
xobrcDefaultFile[0] = 0;
styleFile[0] = 0;
menuFile[0] = 0;
hotkeysFile[0] = 0;
pluginsFile[0] = 0;
designerModeEnabled = false;
selectedElement = Toolbar;
wallpaperPerWorkspaceSemaphore = false;
currentWorkspace = lastWorkspace = 0;
ZeroMemory(&Statistics, sizeof(Statistics));
}
Settings::~Settings()
{
DestroyStyleItems();
}
void Settings::InitStyleItems()
{
InitStyleItem(Wildcard);
InitStyleItem(Toolbar);
InitStyleItem(ToolbarLabel);
InitStyleItem(ToolbarWindowLabel);
InitStyleItem(ToolbarClock);
InitStyleItem(ToolbarButton);
InitStyleItem(ToolbarButtonPressed);
InitStyleItem(ToolbarBorder);
InitStyleItem(MenuTitle);
InitStyleItem(MenuFrame);
InitStyleItem(MenuActive);
InitStyleItem(MenuGrip);
InitStyleItem(MenuFrameBullet);
InitStyleItem(MenuActiveBullet);
InitStyleItem(MenuIndicator);
InitStyleItem(MenuSeparator);
InitStyleItem(MenuFrameBorder);
InitStyleItem(Dock);
InitStyleItem(DockBorder);
InitStyleItem(ActiveTask);
InitStyleItem(InactiveTask);
InitStyleItem(FlashingTask);
InitStyleItem(Console);
InitStyleItem(WindowTitleFocus);
InitStyleItem(WindowTitleUnfocus);
InitStyleItem(WindowLabelFocus);
InitStyleItem(WindowLabelUnfocus);
InitStyleItem(WindowButtonFocus);
InitStyleItem(WindowButtonUnfocus);
InitStyleItem(WindowButtonPressed);
InitStyleItem(WindowGripFocus);
InitStyleItem(WindowGripUnfocus);
InitStyleItem(WindowHandleFocus);
InitStyleItem(WindowHandleUnfocus);
InitStyleItem(ExternalHardware);
}
void Settings::InitStyleItem(StyleItem* styleItem)
{
if (styleItem->Image.bitmap)
{
DeleteObject(styleItem->Image.bitmap);
}
ZeroMemory(styleItem, sizeof(StyleItem));
styleItem->parentRelative = false;
styleItem->type = B_SOLID;
styleItem->bevelstyle = BEVEL_FLAT;
styleItem->bevelposition = BEVEL1;
styleItem->interlaced = false;
styleItem->Color1 = styleItem->Color2 = 0x000000;
styleItem->Color3 = styleItem->Color4 = 0x000000;
styleItem->Color5 = styleItem->Color6 = styleItem->Color7 = styleItem->Color8 = 0x000000;
styleItem->TextColor = styleItem->foregroundColor = 0xffffff;
styleItem->disabledColor = 0x888888;
styleItem->ShadowColor = styleItem->OutlineColor = COLOR_UNDEFINED;
styleItem->FontOutline = styleItem->FontShadow = false;
strcpy_s(styleItem->Font, sizeofArray(styleItem->Font), "Segoe UI");
styleItem->FontHeight = 15;
styleItem->FontWeight = FW_NORMAL;
styleItem->Justify = DT_CENTER;
styleItem->marginWidth = 0;
styleItem->borderColor = 0x000000;
styleItem->borderWidth = 0;
styleItem->bordered = false;
styleItem->Image.path[0] = '\0';
styleItem->Image.mode = 0;
styleItem->Image.width = styleItem->Image.height = styleItem->Image.left = styleItem->Image.top = styleItem->Image.right = styleItem->Image.bottom = 0;
styleItem->nVersion = CORE_SHELL_STYLEITEM;
}
void Settings::DestroyStyleItems()
{
DestroyStyleItem(Wildcard);
DestroyStyleItem(Toolbar);
DestroyStyleItem(ToolbarLabel);
DestroyStyleItem(ToolbarWindowLabel);
DestroyStyleItem(ToolbarClock);
DestroyStyleItem(ToolbarButton);
DestroyStyleItem(ToolbarButtonPressed);
DestroyStyleItem(ToolbarBorder);
DestroyStyleItem(MenuTitle);
DestroyStyleItem(MenuFrame);
DestroyStyleItem(MenuActive);
DestroyStyleItem(MenuGrip);
DestroyStyleItem(MenuFrameBullet);
DestroyStyleItem(MenuActiveBullet);
DestroyStyleItem(MenuIndicator);
DestroyStyleItem(MenuSeparator);
DestroyStyleItem(MenuFrameBorder);
DestroyStyleItem(Dock);
DestroyStyleItem(DockBorder);
DestroyStyleItem(ActiveTask);
DestroyStyleItem(InactiveTask);
DestroyStyleItem(FlashingTask);
DestroyStyleItem(Console);
DestroyStyleItem(WindowTitleFocus);
DestroyStyleItem(WindowTitleUnfocus);
DestroyStyleItem(WindowLabelFocus);
DestroyStyleItem(WindowLabelUnfocus);
DestroyStyleItem(WindowButtonFocus);
DestroyStyleItem(WindowButtonUnfocus);
DestroyStyleItem(WindowButtonPressed);
DestroyStyleItem(WindowGripFocus);
DestroyStyleItem(WindowGripUnfocus);
DestroyStyleItem(WindowHandleFocus);
DestroyStyleItem(WindowHandleUnfocus);
DestroyStyleItem(ExternalHardware);
}
void Settings::DestroyStyleItem(StyleItem* styleItem)
{
if (styleItem)
{
if (styleItem->Image.bitmap) DeleteObject(styleItem->Image.bitmap);
delete styleItem;
}
}
LPSTR Settings::CreateFileCache(LPSTR path)
{
char* cachedFilePtr;
FILE* f = NULL;
fopen_s(&f, path, "r");
if (f)
{
fseek(f, 0, SEEK_END);
long nLen = ftell(f);
cachedFilePtr = (char*)malloc(nLen+2);
if (cachedFilePtr != NULL)
{
fseek (f, 0, SEEK_SET);
int readLen = fread (cachedFilePtr, 1, nLen, f);
cachedFilePtr[readLen] = '\0';
cachedFilePtr[readLen+1] = EOF;
}
fclose(f);
}
else
{
cachedFilePtr = (char*)malloc(2);
if (cachedFilePtr != NULL)
{
cachedFilePtr[0] = '\0';
cachedFilePtr[1] = EOF;
}
}
return cachedFilePtr;
}
void Settings::DestroyFileCache(LPSTR cachedFilePtr)
{
if (cachedFilePtr) free(cachedFilePtr);
cachedFilePtr = NULL;
}
void Settings::WriteDefaultRCSettings()
{
DWORD retLength=0;
char path[MAX_LINE_LENGTH], szTemp[MAX_LINE_LENGTH];
GetBlackboxPath(path, sizeofArray(path));
strcat_s(path, sizeofArray(path), "xoblite.rc");
if (FileExists(path)) return;
else
{
bool downloadSuccessful = DownloadFile("http://xoblite.net/defaults/xoblite.rc", path);
if (downloadSuccessful)
{
strcpy_s(szTemp, sizeofArray(szTemp), ReadString(path, "404 Not Found", ""));
if (strnlen_s(szTemp, sizeofArray(szTemp)) > 0) downloadSuccessful = false;
}
if (!downloadSuccessful)
{
HANDLE f = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (f)
{
strcpy_s(szTemp, sizeofArray(szTemp),
"! =========================================================================================\r\n"
"! Note: This \"fallback\" blank configuration file will be dynamically populated over time...\r\n"
"! =========================================================================================\r\n\r\n");
WriteFile(f, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
}
CloseHandle(f);
}
strcpy_s(bbrcFile, sizeofArray(bbrcFile), path);
strcpy_s(xobrcDefaultFile, sizeofArray(xobrcDefaultFile), path);
}
}
void Settings::ReadConfiguration()
{
char temp[MAX_LINE_LENGTH];
bbrcCache = CreateFileCache(bbrcFile);
strcpy_s(styleFile, sizeofArray(styleFile), GetString(NULL, bbrcCache, "session.styleFile:", ""));
strcpy_s(menuFile, sizeofArray(menuFile), GetString(NULL, bbrcCache, "session.menuFile:", "$Blackbox$\\menu.rc"));
strcpy_s(toolbarPlacementString, sizeofArray(toolbarPlacementString), GetString(NULL, bbrcCache, "session.screen0.toolbar.placement:", "BottomCenter"));
toolbarHorizontalWidth = GetInt(NULL, bbrcCache, "session.screen0.toolbar.widthPercent:", 75);
toolbarOnTop = GetBool(NULL, bbrcCache, "session.screen0.toolbar.onTop:", true);
strcpy_s(toolbarClockFormat, sizeofArray(toolbarClockFormat), GetString(NULL, bbrcCache, "session.screen0.strftimeFormat:", "%H:%M | %a %#d %b"));
strcpy_s(dockPlacementString, sizeofArray(dockPlacementString), GetString(NULL, bbrcCache, "session.screen0.slit.placement:", "Manual xC y50"));
strcpy_s(dockDirection, sizeofArray(dockDirection), GetString(NULL, bbrcCache, "session.screen0.slit.direction:", "Horizontal"));
dockOnTop = GetBool(NULL, bbrcCache, "session.screen0.slit.onTop:", false);
numberOfWorkspaces = GetInt(NULL, bbrcCache, "session.screen0.workspaces:", 4);
strcpy_s(workspaceNames, sizeofArray(workspaceNames), GetString(NULL, bbrcCache, "session.screen0.workspaceNames:", ""));
edgeSnapThreshold = GetInt(NULL, bbrcCache, "session.screen0.edgeSnapThreshold:", 10);
DestroyFileCache(bbrcCache);
xobrcCache = CreateFileCache(xobrcFile);
strcpy_s(styleFile, sizeofArray(styleFile), GetString(NULL, bbrcCache, "xoblite.styleFile:", styleFile));
if (strchr(styleFile, '\"')) StrRemoveEncap(styleFile);
if (strchr(styleFile, '$')) ReplaceShellFolders(styleFile);
if (strchr(styleFile, '%')) ReplaceEnvVars(styleFile);
menuSeparators = GetBool(NULL, xobrcCache, "xoblite.menu.separators:", true);
menuRoundedCorners = GetBool(NULL, xobrcCache, "xoblite.menu.rounded:", false);
menuTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.menu.transparency.alpha:", 255);
menuTitleTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.menu.title.transparency.alpha:", menuTransparencyAlpha);
menuFrameTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.menu.frame.transparency.alpha:", menuTransparencyAlpha);
menuActiveTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.menu.active.transparency.alpha:", menuTransparencyAlpha);
menuGripTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.menu.grip.transparency.alpha:", menuTransparencyAlpha);
toolbarHidden = GetBool(NULL, xobrcCache, "xoblite.toolbar.hidden:", false);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.toolbar.placement:", toolbarPlacementString));
ParsePlacement(temp, &ToolbarPlacement);
toolbarVertical = GetBool(NULL, xobrcCache, "xoblite.toolbar.vertical:", false);
toolbarHorizontalWidth = GetInt(NULL, xobrcCache, "xoblite.toolbar.widthPercent:", toolbarHorizontalWidth);
toolbarHorizontalWidth = GetInt(NULL, xobrcCache, "xoblite.toolbar.horizontal.width:", toolbarHorizontalWidth);
if (toolbarHorizontalWidth < 30) toolbarHorizontalWidth = 30;
toolbarVerticalWidth = GetInt(NULL, xobrcCache, "xoblite.toolbar.vertical.width:", 0);
toolbarTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.toolbar.transparency.alpha:", 255);
toolbarLabelTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.toolbar.label.transparency.alpha:", toolbarTransparencyAlpha);
toolbarWindowLabelTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.toolbar.windowlabel.transparency.alpha:", toolbarTransparencyAlpha);
toolbarClockTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.toolbar.clock.transparency.alpha:", toolbarTransparencyAlpha);
toolbarButtonTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.toolbar.button.transparency.alpha:", toolbarTransparencyAlpha);
toolbarRoundedCorners = GetBool(NULL, xobrcCache, "xoblite.toolbar.rounded:", false);
toolbarOnTop = GetBool(NULL, xobrcCache, "xoblite.toolbar.onTop:", toolbarOnTop);
toolbarSnapToEdges = GetBool(NULL, xobrcCache, "xoblite.toolbar.snapToEdges:", false);
toolbarLabelHidden = GetBool(NULL, xobrcCache, "xoblite.toolbar.label.hidden:", false);
toolbarDownUpButtonsHidden = GetBool(NULL, xobrcCache, "xoblite.toolbar.downup.buttons.hidden:", false);
toolbarLeftRightButtonsHidden = GetBool(NULL, xobrcCache, "xoblite.toolbar.leftright.buttons.hidden:", false);
toolbarClockHidden = GetBool(NULL, xobrcCache, "xoblite.toolbar.clock.hidden:", false);
toolbarAllowAsymmetry = GetBool(NULL, xobrcCache, "xoblite.toolbar.allow.asymmetry:", false);
strcpy_s(toolbarLabelDLClickOverride, sizeofArray(toolbarLabelDLClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.label.dlclick.override:", ""));
strcpy_s(toolbarLabelRClickOverride, sizeofArray(toolbarLabelRClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.label.rclick.override:", ""));
strcpy_s(toolbarLabelMClickOverride, sizeofArray(toolbarLabelMClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.label.mclick.override:", ""));
strcpy_s(toolbarLabelX1ClickOverride, sizeofArray(toolbarLabelX1ClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.label.x1click.override:", ""));
strcpy_s(toolbarLabelX2ClickOverride, sizeofArray(toolbarLabelX2ClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.label.x2click.override:", ""));
strcpy_s(toolbarClockDLClickOverride, sizeofArray(toolbarClockDLClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.clock.dlclick.override:", ""));
strcpy_s(toolbarClockRClickOverride, sizeofArray(toolbarClockRClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.clock.rclick.override:", ""));
strcpy_s(toolbarClockMClickOverride, sizeofArray(toolbarClockMClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.clock.mclick.override:", ""));
strcpy_s(toolbarClockX1ClickOverride, sizeofArray(toolbarClockX1ClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.clock.x1click.override:", ""));
strcpy_s(toolbarClockX2ClickOverride, sizeofArray(toolbarClockX2ClickOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.clock.x2click.override:", ""));
strcpy_s(toolbarDownButtonOverride, sizeofArray(toolbarDownButtonOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.downbutton.override:", ""));
strcpy_s(toolbarUpButtonOverride, sizeofArray(toolbarUpButtonOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.upbutton.override:", ""));
strcpy_s(toolbarLeftButtonOverride, sizeofArray(toolbarLeftButtonOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.leftbutton.override:", ""));
strcpy_s(toolbarRightButtonOverride, sizeofArray(toolbarRightButtonOverride), GetString(NULL, xobrcCache, "xoblite.toolbar.rightbutton.override:", ""));
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.taskbar.mode:", "Bars+Icons"));
{
if (!_stricmp(temp, "Bars")) taskbarMode = TASKBAR_MODE_BARS;
else if (!_stricmp(temp, "Bars+Icons")) taskbarMode = TASKBAR_MODE_BARSICONS;
else if (!_stricmp(temp, "Icons")) taskbarMode = TASKBAR_MODE_ICONS;
else taskbarMode = TASKBAR_MODE_HIDDEN;
}
taskbarMaxItems = GetInt(NULL, xobrcCache, "xoblite.taskbar.max.items:", 10);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.taskbar.sorting:", "FollowActive"));
{
if (!_stricmp(temp, "LastUsed")) taskbarSorting = TASKBAR_SORT_BY_LAST_USED;
else if (!_stricmp(temp, "FollowActive")) taskbarSorting = TASKBAR_SORT_FOLLOW_ACTIVE;
else taskbarSorting = TASKBAR_SORT_DISABLED;
}
taskbarShowTaskWorkspace = GetBool(NULL, xobrcCache, "xoblite.taskbar.show.task.workspace:", true);
taskbarCurrentOnly = GetBool(NULL, xobrcCache, "xoblite.taskbar.currentOnly:", false);
taskbarFlashing = GetBool(NULL, xobrcCache, "xoblite.taskbar.flashing:", true);
taskbarSaturationValue = GetInt(NULL, xobrcCache, "xoblite.taskbar.saturation:", 30);
taskbarHueIntensity = GetInt(NULL, xobrcCache, "xoblite.taskbar.hue:", 100);
taskbarActiveSatHue = GetBool(NULL, xobrcCache, "xoblite.taskbar.active.SatHue:", false);
taskbarActiveTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.taskbar.active.transparency.alpha:", toolbarTransparencyAlpha);
taskbarActiveLivePreview = false;
taskbarInactiveBackground = GetBool(NULL, xobrcCache, "xoblite.taskbar.inactive.background:", false);
taskbarPreviews = GetBool(NULL, xobrcCache, "xoblite.taskbar.previews:", true);
bool tempTooltips = GetBool(NULL, xobrcCache, "xoblite.toolbar.tooltips.disable:", false);
taskbarTooltips = GetBool(NULL, xobrcCache, "xoblite.taskbar.tooltips:", !tempTooltips);
dockHidden = GetBool(NULL, xobrcCache, "xoblite.dock.hidden:", false);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.dock.placement:", dockPlacementString));
ParsePlacement(temp, &DockPlacement);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.dock.direction:", dockDirection));
{
if (!_stricmp(temp, "Vertical")) dockVertical = true;
else dockVertical = false;
}
dockVertical = GetBool(NULL, xobrcCache, "xoblite.dock.vertical:", dockVertical);
dockSnapToEdges = GetBool(NULL, xobrcCache, "xoblite.dock.snapToEdges:", false);
dockTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.dock.transparency.alpha:", 255);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.dock.positioning:", ""));
if (!_stricmp(temp, "SideBySide")) dockPuzzlePositioning = false;
else dockPuzzlePositioning = true;
dockPuzzlePositioning = GetBool(NULL, xobrcCache, "xoblite.dock.puzzle.positioning:", dockPuzzlePositioning);
dockOnTop = GetBool(NULL, xobrcCache, "xoblite.dock.onTop:", dockOnTop);
consoleHidden = GetBool(NULL, xobrcCache, "xoblite.console.hidden:", true);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.console.placement:", "Default"));
ParsePlacement(temp, &ConsolePlacement);
consoleMaximized = GetBool(NULL, xobrcCache, "xoblite.console.maximized:", true);
consoleMaximizedWidth = GetInt(NULL, xobrcCache, "xoblite.console.maximized.width:", 0);
consoleMaximizedMessages = GetInt(NULL, xobrcCache, "xoblite.console.maximized.messages:", 10);
if (consoleMaximizedMessages < 1) consoleMaximizedMessages = 1;
consoleRestoredWidth = GetInt(NULL, xobrcCache, "xoblite.console.restored.width:", 0);
consoleRestoredMessages = GetInt(NULL, xobrcCache, "xoblite.console.restored.messages:", 1);
if (consoleRestoredMessages < 1) consoleMaximizedMessages = 1;
consoleTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.console.transparency.alpha:", 85);
consoleDesktopMode = GetBool(NULL, xobrcCache, "xoblite.console.desktop.mode:", false);
consoleRoundedCorners = GetBool(NULL, xobrcCache, "xoblite.console.rounded:", true);
consolePadding = GetInt(NULL, xobrcCache, "xoblite.console.padding:", 0);
StyleItem tempStyleItem;
ZeroMemory(&tempStyleItem, sizeof(StyleItem));
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.console.font:", ""));
ParseFontString(temp, &tempStyleItem);
if (strnlen_s(tempStyleItem.Font, sizeofArray(tempStyleItem.Font)))
{
strcpy_s(consoleFont, sizeofArray(consoleFont), tempStyleItem.Font);
consoleFontHeight = tempStyleItem.FontHeight;
consoleFontWeight = tempStyleItem.FontWeight;
consoleFontDefined = true;
}
else consoleFontDefined = false;
desktopClockHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.clock.hidden:", true);
strcpy_s(desktopClockType, sizeofArray(desktopClockType), GetString(NULL, xobrcCache, "xoblite.desktop.clock.type:", "Regular"));
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.clock.placement:", "Default"));
ParsePlacement(temp, &desktopClockPlacement);
desktopClockTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.desktop.clock.transparency.alpha:", 210);
desktopWeekdayHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.weekday.hidden:", true);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.weekday.placement:", "Manual x-50 y-100"));
ParsePlacement(temp, &desktopWeekdayPlacement);
desktopWeekdayTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.desktop.weekday.transparency.alpha:", 210);
desktopDateHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.date.hidden:", true);
strcpy_s(desktopDateFormat, sizeofArray(desktopDateFormat), GetString(NULL, xobrcCache, "xoblite.desktop.date.format:", "%B %#d %Y"));
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.date.placement:", "Manual x-50 y-50"));
ParsePlacement(temp, &desktopDatePlacement);
desktopDateTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.desktop.date.transparency.alpha:", 105);
desktopGreetingHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.greeting.hidden:", true);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.greeting.placement:", "Manual x-50 y-50"));
ParsePlacement(temp, &desktopGreetingPlacement);
desktopGreetingTransparencyAlpha = (BYTE)GetInt(NULL, xobrcCache, "xoblite.desktop.greeting.transparency.alpha:", 60);
desktopWorkspaceIndicatorHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.indicator.hidden:", false);
desktopBorderHidden = GetBool(NULL, xobrcCache, "xoblite.desktop.border.hidden:", true);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.clock.font:", ""));
ParseFontString(temp, &tempStyleItem);
if (strnlen_s(tempStyleItem.Font, sizeofArray(tempStyleItem.Font)))
{
strcpy_s(desktopClockFont, sizeofArray(desktopClockFont), tempStyleItem.Font);
desktopClockFontHeight = tempStyleItem.FontHeight;
desktopClockFontWeight = tempStyleItem.FontWeight;
desktopClockFontDefined = true;
}
else desktopClockFontDefined = false;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.weekday.font:", temp));
ParseFontString(temp, &tempStyleItem);
if (strnlen_s(tempStyleItem.Font, sizeofArray(tempStyleItem.Font)))
{
strcpy_s(desktopWeekdayFont, sizeofArray(desktopWeekdayFont), tempStyleItem.Font);
desktopWeekdayFontHeight = tempStyleItem.FontHeight;
desktopWeekdayFontWeight = tempStyleItem.FontWeight;
desktopWeekdayFontDefined = true;
}
else desktopWeekdayFontDefined = false;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.date.font:", temp));
ParseFontString(temp, &tempStyleItem);
if (strnlen_s(tempStyleItem.Font, sizeofArray(tempStyleItem.Font)))
{
strcpy_s(desktopDateFont, sizeofArray(desktopDateFont), tempStyleItem.Font);
desktopDateFontHeight = tempStyleItem.FontHeight;
desktopDateFontWeight = tempStyleItem.FontWeight;
desktopDateFontDefined = true;
}
else desktopDateFontDefined = false;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, xobrcCache, "xoblite.desktop.greeting.font:", temp));
ParseFontString(temp, &tempStyleItem);
if (strnlen_s(tempStyleItem.Font, sizeofArray(tempStyleItem.Font)))
{
strcpy_s(desktopGreetingFont, sizeofArray(desktopGreetingFont), tempStyleItem.Font);
desktopGreetingFontHeight = tempStyleItem.FontHeight;
desktopGreetingFontWeight = tempStyleItem.FontWeight;
desktopGreetingFontDefined = true;
}
else desktopGreetingFontDefined = false;
desktopWidgetColor = GetColor(NULL, xobrcCache, "xoblite.desktop.widget.color:", NULL, 0xffffff, true);
desktopClockColor = GetColor(NULL, xobrcCache, "xoblite.desktop.clock.color:", NULL, desktopWidgetColor, true);
desktopWeekdayColor = GetColor(NULL, xobrcCache, "xoblite.desktop.weekday.color:", NULL, desktopWidgetColor, true);
desktopDateColor = GetColor(NULL, xobrcCache, "xoblite.desktop.date.color:", NULL, desktopWidgetColor, true);
desktopGreetingColor = GetColor(NULL, xobrcCache, "xoblite.desktop.greeting.color:", NULL, desktopWidgetColor, true);
wcscpy_s(desktopGreetingNight, sizeofArray(desktopGreetingNight), GetStringUnicode(NULL, xobrcCache, "xoblite.desktop.greeting.night:", L"Good night"));
wcscpy_s(desktopGreetingMorning, sizeofArray(desktopGreetingMorning), GetStringUnicode(NULL, xobrcCache, "xoblite.desktop.greeting.morning:", L"Good morning"));
wcscpy_s(desktopGreetingAfternoon, sizeofArray(desktopGreetingAfternoon), GetStringUnicode(NULL, xobrcCache, "xoblite.desktop.greeting.afternoon:", L"Good afternoon"));
wcscpy_s(desktopGreetingEvening, sizeofArray(desktopGreetingEvening), GetStringUnicode(NULL, xobrcCache, "xoblite.desktop.greeting.evening:", L"Good evening"));
desktopDisableGDIplusForWidgets = GetBool(NULL, xobrcCache, "xoblite.desktop.widgets.disable.gdiplus:", true);
strcpy_s(desktopRClickOverride, sizeofArray(desktopRClickOverride), GetString(NULL, xobrcCache, "xoblite.desktop.rclick.override:", ""));
strcpy_s(desktopMClickOverride, sizeofArray(desktopMClickOverride), GetString(NULL, xobrcCache, "xoblite.desktop.mclick.override:", ""));
strcpy_s(desktopX1ClickOverride, sizeofArray(desktopX1ClickOverride), GetString(NULL, xobrcCache, "xoblite.desktop.x1click.override:", ""));
strcpy_s(desktopX2ClickOverride, sizeofArray(desktopX2ClickOverride), GetString(NULL, xobrcCache, "xoblite.desktop.x2click.override:", ""));
pluginsHidden = GetBool(NULL, xobrcCache, "xoblite.plugins.hidden:", false);
writeProtection = GetBool(NULL, xobrcCache, "xoblite.write.protection:", false);
DestroyFileCache(xobrcCache);
xobrcDefaultCache = CreateFileCache(xobrcDefaultFile);
strcpy_s(stylesFolder, sizeofArray(stylesFolder), GetString(NULL, xobrcDefaultCache, "xoblite.stylesFolder:", "$Blackbox$\\styles"));
if (strchr(stylesFolder, '\"')) StrRemoveEncap(stylesFolder);
if (strchr(stylesFolder, '$')) ReplaceShellFolders(stylesFolder);
if (strchr(stylesFolder, '%')) ReplaceEnvVars(stylesFolder);
strcpy_s(themesFolder, sizeofArray(themesFolder), GetString(NULL, xobrcDefaultCache, "xoblite.themesFolder:", "$Blackbox$\\themes"));
if (strchr(themesFolder, '\"')) StrRemoveEncap(themesFolder);
if (strchr(themesFolder, '$')) ReplaceShellFolders(themesFolder);
if (strchr(themesFolder, '%')) ReplaceEnvVars(themesFolder);
strcpy_s(wallpapersFolder, sizeofArray(wallpapersFolder), GetString(NULL, xobrcDefaultCache, "xoblite.wallpapersFolder:", "$Blackbox$\\wallpapers"));
if (strchr(wallpapersFolder, '\"')) StrRemoveEncap(wallpapersFolder);
if (strchr(wallpapersFolder, '$')) ReplaceShellFolders(wallpapersFolder);
if (strchr(wallpapersFolder, '%')) ReplaceEnvVars(wallpapersFolder);
enableSoundFX = GetBool(NULL, xobrcDefaultCache, "xoblite.sound.effects:", true);
strcpy_s(soundsFolder, sizeofArray(soundsFolder), GetString(NULL, xobrcDefaultCache, "xoblite.soundsFolder:", "$Blackbox$\\sounds"));
if (strchr(soundsFolder, '\"')) StrRemoveEncap(soundsFolder);
if (strchr(soundsFolder, '$')) ReplaceShellFolders(soundsFolder);
if (strchr(soundsFolder, '%')) ReplaceEnvVars(soundsFolder);
strcpy_s(hotkeysFile, sizeofArray(hotkeysFile), GetString(NULL, xobrcDefaultCache, "xoblite.hotkeysFile:", "$Blackbox$\\hotkeys.rc"));
if (strchr(hotkeysFile, '\"')) StrRemoveEncap(hotkeysFile);
if (strchr(hotkeysFile, '$')) ReplaceShellFolders(hotkeysFile);
if (strchr(hotkeysFile, '%')) ReplaceEnvVars(hotkeysFile);
strcpy_s(pluginsFile, sizeofArray(pluginsFile), GetString(NULL, xobrcDefaultCache, "xoblite.pluginsFile:", "$Blackbox$\\plugins.rc"));
if (strchr(pluginsFile, '\"')) StrRemoveEncap(pluginsFile);
if (strchr(pluginsFile, '$')) ReplaceShellFolders(pluginsFile);
if (strchr(pluginsFile, '%')) ReplaceEnvVars(pluginsFile);
strcpy_s(selectedTheme, sizeofArray(selectedTheme), GetString(NULL, xobrcDefaultCache, "xoblite.selected.theme:", "[Default]"));
if (!_stricmp(selectedTheme, "<Default>")) strcpy_s(selectedTheme, sizeofArray(selectedTheme), "[Default]");
strcpy_s(toolbarClockFormat, sizeofArray(toolbarClockFormat), GetString(NULL, xobrcDefaultCache, "xoblite.toolbar.strftimeFormat:", toolbarClockFormat));
strcpy_s(menuFile, sizeofArray(menuFile), GetString(NULL, xobrcDefaultCache, "xoblite.menuFile:", menuFile));
if (strchr(menuFile, '\"')) StrRemoveEncap(menuFile);
if (strchr(menuFile, '$')) ReplaceShellFolders(menuFile);
if (strchr(menuFile, '%')) ReplaceEnvVars(menuFile);
if (!FileExists(menuFile))
{
strcpy_s(menuFile, sizeofArray(menuFile), ConfigFileExists("menu.rc", NULL));
if (!_stricmp(menuFile, ""))
{
strcpy_s(menuFile, sizeofArray(menuFile), ConfigFileExists("menurc", NULL));
if (!_stricmp(menuFile, ""))
{
WriteDefaultMenu();
}
}
menuPath(menuFile);
}
submenuDelay = GetInt(NULL, xobrcDefaultCache, "xoblite.submenu.delay:", 40);
numberOfWorkspaces = GetInt(NULL, xobrcDefaultCache, "xoblite.workspaces:", numberOfWorkspaces);
strcpy_s(workspaceNames, sizeofArray(workspaceNames), GetString(NULL, xobrcDefaultCache, "xoblite.workspaces.names:", workspaceNames));
mousewheelChanging = GetBool(NULL, xobrcDefaultCache, "xoblite.workspaces.mousewheel.changing:", false);
followActive = GetBool(NULL, xobrcDefaultCache, "xoblite.workspaces.followActive:", true);
wallpaperPerWorkspace = GetBool(NULL, xobrcDefaultCache, "xoblite.workspaces.wallpapers:", true);
strcpy_s(pluginsRepository, sizeofArray(pluginsRepository), GetString(NULL, xobrcDefaultCache, "xoblite.plugins.repository:", "http://xoblite.net/plugins.txt"));
doubleScaleHiDPI = GetBool(NULL, xobrcDefaultCache, "xoblite.double.scale:", true);
int legacyScalingFactor = 1;
if (doubleScaleHiDPI) legacyScalingFactor = 2;
scalingFactorHiDPI = GetInt(NULL, xobrcDefaultCache, "xoblite.hidpi.scaling.factor:", legacyScalingFactor);
if (scalingFactorHiDPI < 1) scalingFactorHiDPI = 1;
if (scalingFactorHiDPI > 4) scalingFactorHiDPI = 4;
multimonPlacements = GetBool(NULL, xobrcDefaultCache, "xoblite.multimonitor.placements:", false);
fullscreenDetection = GetBool(NULL, xobrcDefaultCache, "xoblite.fullscreen.detection:", false);
disableRootCommands = GetBool(NULL, xobrcDefaultCache, "xoblite.disable.rootCommands:", false);
disableThemeFonts = GetBool(NULL, xobrcDefaultCache, "xoblite.disable.theme.fonts:", true);
disableScriptSupport = GetBool(NULL, xobrcDefaultCache, "xoblite.disable.script.support:", false);
disableUnicodeParsing = GetBool(NULL, xobrcDefaultCache, "xoblite.disable.unicode.parsing:", false);
explorerHidden = GetBool(NULL, xobrcDefaultCache, "xoblite.explorer.hidden:", false);
strcpy_s(timeDateLocale, sizeofArray(timeDateLocale), GetString(NULL, xobrcDefaultCache, "xoblite.toolbar.locale:", ""));
strcpy_s(timeDateLocale, sizeofArray(timeDateLocale), GetString(NULL, xobrcDefaultCache, "xoblite.timedate.locale:", timeDateLocale));
strcpy_s(preferredEditor, sizeofArray(preferredEditor), GetString(NULL, xobrcDefaultCache, "xoblite.editor:", "\"notepad.exe\""));
if (strchr(preferredEditor, '$')) ReplaceShellFolders(preferredEditor);
if (strchr(preferredEditor, '%')) ReplaceEnvVars(preferredEditor);
strcpy_s(checkedForUpdates, sizeofArray(checkedForUpdates), GetString(NULL, xobrcDefaultCache, "xoblite.checked.for.updates:", "#001 / 2006-01-01"));
edgeSnapThreshold = GetInt(NULL, xobrcDefaultCache, "xoblite.edgeSnapThreshold:", edgeSnapThreshold);
debugLogging = GetBool(NULL, xobrcDefaultCache, "xoblite.debug:", false);
DestroyFileCache(xobrcDefaultCache);
}
void Settings::WriteDefaultMenu()
{
DWORD retLength=0;
char temp[MAX_LINE_LENGTH];
HANDLE f = CreateFile(menuFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (f)
{
strcpy_s(temp, MAX_LINE_LENGTH,
"[begin] ()\r\n"
"\t[exec] (Explorer) {explorer.exe /e,%SystemDrive%}\r\n"
"\t[submenu] (Start menu)\r\n"
"\t\t[path] (Current user) {\"$StartMenu$\"}\r\n"
"\t\t[path] (All users) {\"$CommonStartMenu$\"}\r\n"
"\t[end]\r\n"
"\t[submenu] (Shutdown menu)\r\n"
"\t\t[lockworkstation] (Lock workstation)\r\n"
"\t\t[separator]\r\n"
"\t\t[standby] (Standby [sleep])\r\n"
"\t\t[hibernate] (Hibernate [suspend])\r\n"
"\t\t[separator]\r\n"
"\t\t[logoff] (Log off)\r\n"
"\t\t[reboot] (Restart [reboot])\r\n"
"\t\t[shutdown] (Shutdown)\r\n"
"\t[end]\r\n"
"\t[separator]\r\n"
"\t[configuration] (xoblite)\r\n"
"[end] ()\r\n");
WriteFile(f, temp, strnlen_s(temp, MAX_LINE_LENGTH), &retLength, NULL);
}
CloseHandle(f);
GetBlackboxPath(menuFile, sizeofArray(menuFile));
strcat_s(menuFile, sizeofArray(menuFile), "menu.rc");
}
void Settings::ReadStyle()
{
styleCache = CreateFileCache(styleFile);
if (styleCache == NULL) return;
char temp[MAX_LINE_LENGTH];
COLORREF tempColor;
bool bb4nix070syntax = false;
InitStyleItems();
borderWidth = GetInt(NULL, styleCache, "borderWidth:", 0);
borderColor = GetColor(NULL, styleCache, "borderColor:", NULL, 0x000000, true);
marginWidth = GetInt(NULL, styleCache, "marginWidth:", 0);
bevelWidth = GetInt(NULL, styleCache, "bevelWidth:", 1);
handleHeight = GetInt(NULL, styleCache, "handleWidth:", 5);
handleHeight = GetInt(NULL, styleCache, "handleHeight:", handleHeight);
handleHeight = GetInt(NULL, styleCache, "window.handleHeight:", handleHeight);
frameWidth = GetInt(NULL, styleCache, "frameWidth:", bevelWidth);
strcpy_s(rootCommand, sizeofArray(rootCommand), GetString(NULL, styleCache, "rootCommand:", ""));
if (strchr(rootCommand, '$')) ReplaceShellFolders(rootCommand);
if (strchr(rootCommand, '%')) ReplaceEnvVars(rootCommand);
strcpy_s(wildcard, sizeofArray(wildcard), "Flat Solid");
appearancePointer = wildcard;
Wildcard->TextColor = GetColor(NULL, styleCache, "*textColor:", NULL, Wildcard->TextColor, true);
strcpy_s(Wildcard->Font, sizeofArray(Wildcard->Font), GetString(NULL, styleCache, "*font:", Wildcard->Font));
CheckFontSubstitution(Wildcard->Font);
Wildcard->FontHeight = GetInt(NULL, styleCache, "*fontHeight:", Wildcard->FontHeight);
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "*alignment:", "Center"));
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "*justify:", temp));
if (IsInString(temp, "Left")) Wildcard->Justify = DT_LEFT;
else if (IsInString(temp, "Right")) Wildcard->Justify = DT_RIGHT;
else Wildcard->Justify = DT_CENTER;
Wildcard->borderWidth = GetInt(NULL, styleCache, "*borderWidth:", borderWidth);
Wildcard->borderColor = GetColor(NULL, styleCache, "*borderColor:", NULL, borderColor, true);
Wildcard->marginWidth = GetInt(NULL, styleCache, "*marginWidth:", marginWidth);
ReadStyleElement(styleCache, Wildcard, "*", true);
strcpy_s(wildcardToolbarFont, sizeofArray(wildcardToolbarFont), GetString(NULL, styleCache, "toolbar*font:", Wildcard->Font));
strcpy_s(wildcardMenuFont, sizeofArray(wildcardMenuFont), GetString(NULL, styleCache, "menu*font:", Wildcard->Font));
strcpy_s(wildcardWindowFont, sizeofArray(wildcardWindowFont), GetString(NULL, styleCache, "window*font:", Wildcard->Font));
strcpy_s(toolbar, sizeofArray(toolbar), "Flat Solid");
appearancePointer = toolbar;
CopyMemory(Toolbar, Wildcard, sizeof(StyleItem));
Toolbar->Color = 0x000000;
Toolbar->TextColor = 0xffffff;
Toolbar->FontOutline = Toolbar->FontShadow = false;
Toolbar->marginWidth = 1;
Toolbar->borderWidth = borderWidth;
strcpy_s(Toolbar->Font, sizeofArray(Toolbar->Font), wildcardToolbarFont);
ReadStyleElement(styleCache, Toolbar, "toolbar", true);
if (!consoleFontDefined)
{
strcpy_s(consoleFont, sizeofArray(consoleFont), Toolbar->Font);
consoleFontHeight = Toolbar->FontHeight;
consoleFontWeight = Toolbar->FontWeight;
}
if (Toolbar->ShadowY > Toolbar->marginWidth) Toolbar->ShadowY = Toolbar->marginWidth;
strcpy_s(toolbarLabel, sizeofArray(toolbarLabel), "ParentRelative");
appearancePointer = toolbarLabel;
CopyMemory(ToolbarLabel, Toolbar, sizeof(StyleItem));
ToolbarLabel->FontOutline = ToolbarLabel->FontShadow = false;
ToolbarLabel->borderWidth = Wildcard->borderWidth;
ReadStyleElement(styleCache, ToolbarLabel, "toolbar.label", true);
if (ToolbarLabel->ShadowY > ToolbarLabel->marginWidth) ToolbarLabel->ShadowY = ToolbarLabel->marginWidth;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "toolbar.windowLabel.appearance:", ""));
if (!strnlen_s(temp, MAX_LINE_LENGTH)) strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "toolbar.windowLabel:", ""));
if (strnlen_s(temp, MAX_LINE_LENGTH))
{
strcpy_s(toolbarWindowLabel, sizeofArray(toolbarWindowLabel), "Flat Solid");
appearancePointer = toolbarWindowLabel;
CopyMemory(ToolbarWindowLabel, Toolbar, sizeof(StyleItem));
ToolbarWindowLabel->FontOutline = ToolbarWindowLabel->FontShadow = false;
ToolbarWindowLabel->borderWidth = Wildcard->borderWidth;
ToolbarWindowLabel->marginWidth = ToolbarLabel->marginWidth;
ReadStyleElement(styleCache, ToolbarWindowLabel, "toolbar.windowLabel", true);
}
else
{
strcpy_s(toolbarWindowLabel, sizeofArray(toolbarWindowLabel), toolbarLabel);
CopyMemory(ToolbarWindowLabel, ToolbarLabel, sizeof(StyleItem));
}
if (ToolbarWindowLabel->ShadowY > ToolbarWindowLabel->marginWidth) ToolbarWindowLabel->ShadowY = ToolbarWindowLabel->marginWidth;
strcpy_s(toolbarClock, sizeofArray(toolbarClock), "ParentRelative");
appearancePointer = toolbarClock;
CopyMemory(ToolbarClock, Toolbar, sizeof(StyleItem));
ToolbarClock->FontOutline = ToolbarClock->FontShadow = false;
ToolbarClock->marginWidth = ToolbarLabel->marginWidth;
ToolbarClock->borderWidth = Wildcard->borderWidth;
ReadStyleElement(styleCache, ToolbarClock, "toolbar.clock", true);
if (ToolbarClock->ShadowY > ToolbarClock->marginWidth) ToolbarClock->ShadowY = ToolbarClock->marginWidth;
if (!strnlen_s(GetString(NULL, styleCache, "toolbar.textColor:", ""), MAX_LINE_LENGTH))
{
if (!strnlen_s(GetString(NULL, styleCache, "*textColor:", ""), MAX_LINE_LENGTH))
{
if (ToolbarWindowLabel->parentRelative) Toolbar->TextColor = ToolbarWindowLabel->TextColor;
else if (ToolbarLabel->parentRelative) Toolbar->TextColor = ToolbarLabel->TextColor;
else if (ToolbarClock->parentRelative) Toolbar->TextColor = ToolbarClock->TextColor;
else Toolbar->TextColor = ToolbarWindowLabel->TextColor;
}
else Toolbar->TextColor = GetColor(NULL, styleCache, "*textColor:", NULL, Wildcard->TextColor, true);
}
else Toolbar->TextColor = GetColor(NULL, styleCache, "toolbar.textColor:", NULL, Wildcard->TextColor, true);
strcpy_s(toolbarButton, sizeofArray(toolbarButton), "Flat Solid");
appearancePointer = toolbarButton;
ToolbarButton->Color = 0x444444;
ToolbarButton->PicColor = Toolbar->TextColor;
ToolbarButton->borderColor = Toolbar->borderColor;
ToolbarButton->borderWidth = Wildcard->borderWidth;
ToolbarButton->marginWidth = 2;
bb4nix070syntax = ReadStyleElement(styleCache, ToolbarButton, "toolbar.button", false);
strcpy_s(toolbarButtonPressed, sizeofArray(toolbarButtonPressed), "Flat Solid");
appearancePointer = toolbarButtonPressed;
CopyMemory(ToolbarButtonPressed, ToolbarButton, sizeof(StyleItem));
ToolbarButtonPressed->Color = 0x222222;
ToolbarButtonPressed->borderColor = Toolbar->borderColor;
ToolbarButtonPressed->borderWidth = Wildcard->borderWidth;
ToolbarButtonPressed->marginWidth = 2;
bb4nix070syntax = ReadStyleElement(styleCache, ToolbarButtonPressed, "toolbar.button.pressed", false);
if (strnlen_s(GetString(NULL, styleCache, "toolbar.border.", ""), MAX_LINE_LENGTH))
{
strcpy_s(toolbarBorder, sizeofArray(toolbarBorder), "");
appearancePointer = toolbarBorder;
ReadStyleElement(styleCache, ToolbarBorder, "toolbar.border", false);
}
else ToolbarBorder->parentRelative = true;
menuBorderColor = GetColor(NULL, styleCache, "menu.borderColor:", NULL, Wildcard->borderColor, true);
menuBorderWidth = GetInt(NULL, styleCache, "menu.borderWidth:", borderWidth);
strcpy_s(menuTitle, sizeofArray(menuTitle), "Flat Solid");
appearancePointer = menuTitle;
CopyMemory(MenuTitle, Wildcard, sizeof(StyleItem));
MenuTitle->Color = 0x000000;
MenuTitle->TextColor = Wildcard->TextColor;
MenuTitle->borderColor = menuBorderColor;
MenuTitle->borderWidth = menuBorderWidth;
MenuTitle->marginWidth = marginWidth;
strcpy_s(MenuTitle->Font, sizeofArray(MenuTitle->Font), wildcardMenuFont);
MenuTitle->FontOutline = MenuTitle->FontShadow = false;
ReadStyleElement(styleCache, MenuTitle, "menu.title", true);
if (MenuTitle->ShadowY > MenuTitle->marginWidth) MenuTitle->ShadowY = MenuTitle->marginWidth;
strcpy_s(menuFrame, sizeofArray(menuFrame), "Flat Solid");
appearancePointer = menuFrame;
CopyMemory(MenuFrame, MenuTitle, sizeof(StyleItem));
MenuFrame->Color = 0x000000;
MenuFrame->TextColor = Wildcard->TextColor;
MenuFrame->borderColor = menuBorderColor;
MenuFrame->borderWidth = menuBorderWidth;
MenuFrame->marginWidth = marginWidth;
strcpy_s(MenuFrame->Font, sizeofArray(MenuFrame->Font), wildcardMenuFont);
MenuFrame->FontHeight = Wildcard->FontHeight;
MenuFrame->Justify = Wildcard->Justify;
MenuFrame->FontOutline = MenuFrame->FontShadow = false;
ReadStyleElement(styleCache, MenuFrame, "menu.frame", true);
tempColor = GetColor(NULL, styleCache, "menu.frame.foregroundColor:", NULL, MenuFrame->TextColor, true);
MenuFrame->BulletColor = GetColor(NULL, styleCache, "menu.frame.bulletColor:", NULL, tempColor, true);
if (strnlen_s(GetString(NULL, styleCache, "menu.frame.border.", ""), MAX_LINE_LENGTH))
{
strcpy_s(menuFrameBorder, sizeofArray(menuFrameBorder), "");
appearancePointer = menuFrameBorder;
ReadStyleElement(styleCache, MenuFrameBorder, "menu.frame.border", false);
}
else MenuFrameBorder->parentRelative = true;
strcpy_s(menuActive, sizeofArray(menuActive), "Flat Solid");
appearancePointer = menuActive;
CopyMemory(MenuActive, MenuFrame, sizeof(StyleItem));
MenuActive->Color = MenuFrame->TextColor;
MenuActive->TextColor = MenuFrame->Color;
MenuActive->borderWidth = Wildcard->borderWidth;
MenuActive->marginWidth = marginWidth;
MenuActive->FontOutline = MenuActive->FontShadow = false;
bb4nix070syntax = ReadStyleElement(styleCache, MenuActive, "menu.hilite", true);
bb4nix070syntax = ReadStyleElement(styleCache, MenuActive, "menu.active", true);
MenuActive->BulletColor = GetColor(NULL, styleCache, "menu.hilite.bulletColor:", NULL, MenuActive->TextColor, true);
tempColor = GetColor(NULL, styleCache, "menu.active.foregroundColor:", NULL, MenuActive->BulletColor, true);
MenuActive->BulletColor = GetColor(NULL, styleCache, "menu.active.bulletColor:", NULL, tempColor, true);
if (MenuActive->parentRelative)
{
MenuActive->type = B_PARENTRELATIVE;
MenuActive->Color = MenuFrame->Color;
MenuActive->ColorTo = MenuFrame->ColorTo;
}
if (MenuActive->ShadowY > MenuActive->marginWidth) MenuActive->ShadowY = MenuActive->marginWidth;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "menu.bullet:", "Triangle"));
strcpy_s(menuFrameBulletAsString, sizeofArray(menuFrameBulletAsString), GetString(NULL, styleCache, "menu.frame.bullet:", temp));
if (strchr(menuFrameBulletAsString, '.') || strchr(menuFrameBulletAsString, '\\'))
{
menuBullet = MENU_BULLET_IMAGE;
if (strchr(menuFrameBulletAsString, '\"')) StrRemoveEncap(menuFrameBulletAsString);
if (strchr(menuFrameBulletAsString, '$')) ReplaceShellFolders(menuFrameBulletAsString);
if (strchr(menuFrameBulletAsString, '%')) ReplaceEnvVars(menuFrameBulletAsString);
if (FileExists(menuFrameBulletAsString))
{
strncpy_s(MenuFrameBullet->Image.path, sizeof(MenuFrameBullet->Image.path), menuFrameBulletAsString, _TRUNCATE);
CreateElementImage(MenuFrameBullet);
}
strcpy_s(menuActiveBulletAsString, sizeofArray(menuActiveBulletAsString), GetString(NULL, styleCache, "menu.active.bullet:", menuFrameBulletAsString));
if (strchr(menuActiveBulletAsString, '\"')) StrRemoveEncap(menuActiveBulletAsString);
if (strchr(menuActiveBulletAsString, '$')) ReplaceShellFolders(menuActiveBulletAsString);
if (strchr(menuActiveBulletAsString, '%')) ReplaceEnvVars(menuActiveBulletAsString);
if (FileExists(menuActiveBulletAsString))
{
strncpy_s(MenuActiveBullet->Image.path, sizeof(MenuActiveBullet->Image.path), menuActiveBulletAsString, _TRUNCATE);
CreateElementImage(MenuActiveBullet);
}
}
else if ((!_stricmp(menuFrameBulletAsString, "triangle")) || (!_stricmp(temp, "arrow"))) menuBullet = MENU_BULLET_TRIANGLE;
else if (!_stricmp(menuFrameBulletAsString, "square")) menuBullet = MENU_BULLET_SQUARE;
else if (!_stricmp(menuFrameBulletAsString, "diamond")) menuBullet = MENU_BULLET_DIAMOND;
else if (!_stricmp(menuFrameBulletAsString, "circle")) menuBullet = MENU_BULLET_CIRCLE;
else if (!_stricmp(menuFrameBulletAsString, "triple")) menuBullet = MENU_BULLET_TRIPLE;
else if (!_stricmp(menuFrameBulletAsString, "comment")) menuBullet = MENU_BULLET_COMMENT;
else if (!_stricmp(menuFrameBulletAsString, "grid")) menuBullet = MENU_BULLET_GRID;
else if (!_stricmp(menuFrameBulletAsString, "quad")) menuBullet = MENU_BULLET_QUAD;
else if (!_stricmp(menuFrameBulletAsString, "bitmap"))
{
menuBullet = MENU_BULLET_TRIANGLE;
}
else menuBullet = MENU_BULLET_EMPTY;
strcpy_s(menuBulletPosition, sizeofArray(menuBulletPosition), GetString(NULL, styleCache, "menu.bullet.position:", "Right"));
if (MenuActive->parentRelative)
{
CopyMemory(MenuIndicator, MenuTitle, sizeof(StyleItem));
strcpy_s(menuIndicator, sizeofArray(menuIndicator), menuTitle);
}
else
{
CopyMemory(MenuIndicator, MenuActive, sizeof(StyleItem));
strcpy_s(menuIndicator, sizeofArray(menuIndicator), menuActive);
}
appearancePointer = menuIndicator;
ReadStyleElement(styleCache, MenuIndicator, "menu.indicator", false);
strcpy_s(menuSeparator, sizeofArray(menuSeparator), "Flat Gradient MirrorHorizontal");
appearancePointer = menuSeparator;
CopyMemory(MenuSeparator, MenuFrame, sizeof(StyleItem));
MenuSeparator->type = B_MIRRORHORIZONTAL;
MenuSeparator->bevelstyle = BEVEL_FLAT;
MenuSeparator->marginWidth = 1;
if (!strnlen_s(GetString(NULL, styleCache, "menu.separator.appearance:", ""), MAX_LINE_LENGTH))
{
if (strnlen_s(GetString(NULL, styleCache, "menu.separator.shadowColor:", ""), MAX_LINE_LENGTH))
{
MenuSeparator->FontShadow = true;
MenuSeparator->Color1 = MenuFrame->Color1;
MenuSeparator->Color2 = GetColor(NULL, styleCache, "menu.separator.color:", NULL, MenuFrame->TextColor, true);
MenuSeparator->ShadowColor = GetColor(NULL, styleCache, "menu.separator.shadowColor:", NULL, MenuFrame->Color, true);
MenuSeparator->ShadowX = GetInt(NULL, styleCache, "menu.separator.shadowX:", 1);
MenuSeparator->ShadowY = GetInt(NULL, styleCache, "menu.separator.shadowY:", 1);
}
else
{
MenuSeparator->Color1 = MenuFrame->Color1;
tempColor = GetColor(NULL, styleCache, "menu.separator.foregroundColor:", NULL, MenuFrame->TextColor, true);
MenuSeparator->Color2 = GetColor(NULL, styleCache, "menu.separator.color:", NULL, tempColor, true);
}
}
else
{
MenuSeparator->Color1 = GetColor(NULL, styleCache, "menu.separator.foregroundColor:", NULL, MenuFrame->TextColor, true);
MenuSeparator->Color2 = MenuSeparator->Color3 = MenuSeparator->Color4 = MenuSeparator->Color5 = MenuSeparator->Color6 = MenuSeparator->Color7 = MenuSeparator->Color8 = MenuSeparator->Color1;
ReadStyleElement(styleCache, MenuSeparator, "menu.separator", true);
switch (MenuSeparator->type)
{
case B_SUPERHORIZONTAL:
case B_SPLITHORIZONTAL:
case B_MIRRORHORIZONTAL:
case B_HORIZONTAL:
case B_SOLID:
case B_SPLITSOLID:
{
break;
}
case B_SUPERVERTICAL: { MenuSeparator->type = B_SUPERHORIZONTAL; break; }
case B_SPLITVERTICAL: { MenuSeparator->type = B_SPLITHORIZONTAL; break; }
case B_VERTICAL: { MenuSeparator->type = B_HORIZONTAL; break; }
default: { MenuSeparator->type = B_MIRRORHORIZONTAL; break; }
}
}
if (MenuSeparator->ShadowX > 3) MenuSeparator->ShadowX = 3;
else if (MenuSeparator->ShadowX < -3) MenuSeparator->ShadowX = -3;
if (MenuSeparator->ShadowY > 3) MenuSeparator->ShadowY = 3;
else if (MenuSeparator->ShadowY < -3) MenuSeparator->ShadowY = -3;
if (strnlen_s(GetString(NULL, styleCache, "menu.grip", ""), MAX_LINE_LENGTH))
{
strcpy_s(menuGrip, sizeofArray(menuGrip), "");
appearancePointer = menuGrip;
CopyMemory(MenuGrip, MenuTitle, sizeof(StyleItem));
MenuGrip->marginWidth = MenuGrip->FontHeight = 0;
MenuGrip->FontOutline = MenuGrip->FontShadow = false;
ReadStyleElement(styleCache, MenuGrip, "menu.grip", true);
if (MenuGrip->ShadowY > MenuGrip->marginWidth) MenuGrip->ShadowY = MenuGrip->marginWidth;
}
else MenuGrip->parentRelative = true;
strcpy_s(dock, sizeofArray(dock), toolbar);
appearancePointer = dock;
CopyMemory(Dock, Toolbar, sizeof(StyleItem));
ReadStyleElement(styleCache, Dock, "slit", false);
ReadStyleElement(styleCache, Dock, "dock", false);
if (strnlen_s(GetString(NULL, styleCache, "dock.border.", ""), MAX_LINE_LENGTH))
{
strcpy_s(dockBorder, sizeofArray(dockBorder), "");
appearancePointer = dockBorder;
ReadStyleElement(styleCache, DockBorder, "dock.border", false);
}
else DockBorder->parentRelative = true;
DeriveTaskbarStyle();
strcpy_s(console, sizeofArray(console), toolbar);
appearancePointer = console;
CopyMemory(Console, Toolbar, sizeof(StyleItem));
Console->Color = 0x000000;
Console->TextColor = 0xffffff;
strcpy_s(Console->Font, sizeofArray(Console->Font), consoleFont);
CheckFontSubstitution(Console->Font);
Console->FontHeight = consoleFontHeight;
Console->FontWeight = consoleFontWeight;
Console->FontOutline = Console->FontShadow = false;
ReadStyleElement(styleCache, Console, "console", true);
Console->PicColor = GetColor(NULL, styleCache, "console.buttonColor:", NULL, Console->TextColor, true);
strcpy_s(windowTitleFocus, sizeofArray(windowTitleFocus), toolbar);
appearancePointer = windowTitleFocus;
CopyMemory(WindowTitleFocus, Toolbar, sizeof(StyleItem));
if (!ToolbarBorder->parentRelative) WindowTitleFocus->borderColor = ToolbarBorder->Color1;
ReadStyleElement(styleCache, WindowTitleFocus, "window.title.focus", false);
strcpy_s(windowTitleUnfocus, sizeofArray(windowTitleUnfocus), windowTitleFocus);
appearancePointer = windowTitleUnfocus;
CopyMemory(WindowTitleUnfocus, WindowTitleFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowTitleUnfocus, "window.title.unfocus", false);
strcpy_s(windowLabelFocus, sizeofArray(windowLabelFocus), toolbarWindowLabel);
appearancePointer = windowLabelFocus;
CopyMemory(WindowLabelFocus, ToolbarWindowLabel, sizeof(StyleItem));
strcpy_s(WindowLabelFocus->Font, wildcardWindowFont);
ReadStyleElement(styleCache, WindowLabelFocus, "window.label.focus", true);
strcpy_s(windowLabelUnfocus, sizeofArray(windowLabelUnfocus), windowLabelFocus);
appearancePointer = windowLabelUnfocus;
CopyMemory(WindowLabelUnfocus, WindowLabelFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowLabelUnfocus, "window.label.unfocus", true);
strcpy_s(windowButtonFocus, sizeofArray(windowButtonFocus), toolbarButton);
appearancePointer = windowButtonFocus;
CopyMemory(WindowButtonFocus, ToolbarButton, sizeof(StyleItem));
strcpy_s(WindowButtonFocus->Font, sizeofArray(WindowButtonFocus->Font), WindowLabelFocus->Font);
WindowButtonFocus->FontHeight = WindowLabelFocus->FontHeight;
WindowButtonFocus->FontWeight = WindowLabelFocus->FontWeight;
WindowButtonFocus->TextColor = WindowButtonFocus->PicColor;
WindowButtonFocus->FontOutline = WindowButtonFocus->FontShadow = false;
ReadStyleElement(styleCache, WindowButtonFocus, "window.button.focus", false);
strcpy_s(windowButtonUnfocus, sizeofArray(windowButtonUnfocus), windowButtonFocus);
appearancePointer = windowButtonUnfocus;
CopyMemory(WindowButtonUnfocus, WindowButtonFocus, sizeof(StyleItem));
strcpy_s(WindowButtonUnfocus->Font, sizeofArray(WindowButtonUnfocus->Font), WindowLabelUnfocus->Font);
WindowButtonUnfocus->FontHeight = WindowLabelUnfocus->FontHeight;
WindowButtonUnfocus->FontWeight = WindowLabelUnfocus->FontWeight;
WindowButtonUnfocus->TextColor = WindowButtonUnfocus->PicColor;
WindowButtonUnfocus->FontOutline = WindowButtonUnfocus->FontShadow = false;
ReadStyleElement(styleCache, WindowButtonUnfocus, "window.button.unfocus", false);
strcpy_s(windowButtonPressed, sizeofArray(windowButtonPressed), toolbarButtonPressed);
appearancePointer = windowButtonPressed;
CopyMemory(WindowButtonPressed, ToolbarButtonPressed, sizeof(StyleItem));
strcpy_s(WindowButtonPressed->Font, sizeofArray(WindowButtonPressed->Font), WindowButtonFocus->Font);
WindowButtonPressed->FontHeight = WindowButtonFocus->FontHeight;
WindowButtonPressed->FontWeight = WindowButtonFocus->FontWeight;
WindowButtonPressed->TextColor = WindowButtonPressed->PicColor;
WindowButtonPressed->FontOutline = WindowButtonPressed->FontShadow = false;
ReadStyleElement(styleCache, WindowButtonPressed, "window.button.pressed", false);
strcpy_s(windowGripFocus, sizeofArray(windowGripFocus), windowTitleFocus);
appearancePointer = windowGripFocus;
CopyMemory(WindowGripFocus, WindowTitleFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowGripFocus, "window.grip.focus", false);
strcpy_s(windowGripUnfocus, sizeofArray(windowGripUnfocus), windowGripFocus);
appearancePointer = windowGripUnfocus;
CopyMemory(WindowGripUnfocus, WindowGripFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowGripUnfocus, "window.grip.unfocus", false);
strcpy_s(windowHandleFocus, sizeofArray(windowHandleFocus), windowTitleFocus);
appearancePointer = windowHandleFocus;
CopyMemory(WindowHandleFocus, WindowTitleFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowHandleFocus, "window.handle.focus", false);
strcpy_s(windowHandleUnfocus, sizeofArray(windowHandleUnfocus), windowHandleFocus);
appearancePointer = windowHandleUnfocus;
CopyMemory(WindowHandleUnfocus, WindowHandleFocus, sizeof(StyleItem));
ReadStyleElement(styleCache, WindowHandleUnfocus, "window.handle.unfocus", false);
strcpy_s(externalHardware, sizeofArray(externalHardware), toolbarWindowLabel);
appearancePointer = externalHardware;
CopyMemory(ExternalHardware, ToolbarWindowLabel, sizeof(StyleItem));
ReadStyleElement(styleCache, ExternalHardware, "hardware", false);
if (strnlen_s(GetString(NULL, styleCache, "titleFont:", ""), MAX_LINE_LENGTH))
{
strcpy_s(MenuTitle->Font, sizeofArray(MenuTitle->Font), GetString(NULL, styleCache, "titleFont:", MenuTitle->Font));
CheckFontSubstitution(MenuTitle->Font);
}
if (strnlen_s(GetString(NULL, styleCache, "menuFont:", ""), MAX_LINE_LENGTH))
{
strcpy_s(MenuFrame->Font, sizeofArray(MenuFrame->Font), GetString(NULL, styleCache, "menuFont:", MenuFrame->Font));
CheckFontSubstitution(MenuFrame->Font);
}
if (strnlen_s(GetString(NULL, styleCache, "titleJustify:", ""), MAX_LINE_LENGTH))
{
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "titleJustify:", ""));
if (IsInString(temp, "Left")) MenuTitle->Justify = DT_LEFT;
else if (IsInString(temp, "Right")) MenuTitle->Justify = DT_RIGHT;
else if (IsInString(temp, "Center")) MenuTitle->Justify = DT_CENTER;
}
if (strnlen_s(GetString(NULL, styleCache, "menuJustify:", ""), MAX_LINE_LENGTH))
{
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, "menuJustify:", ""));
if (IsInString(temp, "Left")) MenuFrame->Justify = DT_LEFT;
else if (IsInString(temp, "Right")) MenuFrame->Justify = DT_RIGHT;
else if (IsInString(temp, "Center")) MenuFrame->Justify = DT_CENTER;
}
if (strnlen_s(GetString(NULL, styleCache, "menu.frame.highlightColor:", ""), MAX_LINE_LENGTH))
{
MenuActive->Color = GetColor(NULL, styleCache, "menu.frame.highlightColor:", "#303030", NULL, false);
MenuActive->ColorTo = MenuActive->Color;
}
if (strnlen_s(GetString(NULL, styleCache, "menu.frame.hiTextColor:", ""), MAX_LINE_LENGTH))
MenuActive->TextColor = GetColor(NULL, styleCache, "menu.frame.hiTextColor:", NULL, Wildcard->TextColor, true);
if (strnlen_s(GetString(NULL, styleCache, "menu.bulletStyle:", ""), MAX_LINE_LENGTH))
strcpy_s(menuFrameBulletAsString, sizeofArray(menuFrameBulletAsString), GetString(NULL, styleCache, "menu.bulletStyle:", menuFrameBulletAsString));
if (strnlen_s(GetString(NULL, styleCache, "menu.bulletPosition:", ""), MAX_LINE_LENGTH))
strcpy_s(menuBulletPosition, sizeofArray(menuBulletPosition), GetString(NULL, styleCache, "menu.bulletPosition:", menuBulletPosition));
if (scalingFactorHiDPI > 1)
{
borderWidth *= scalingFactorHiDPI;
menuBorderWidth *= scalingFactorHiDPI;
bevelWidth *= scalingFactorHiDPI;
marginWidth *= scalingFactorHiDPI;
handleHeight *= scalingFactorHiDPI;
frameWidth *= scalingFactorHiDPI;
if (MenuTitle->FontHeight >= 2) MenuTitle->FontHeight *= scalingFactorHiDPI;
MenuFrame->FontHeight *= scalingFactorHiDPI;
MenuActive->FontHeight *= scalingFactorHiDPI;
if (MenuGrip->FontHeight >= 2) MenuGrip->FontHeight *= scalingFactorHiDPI;
Toolbar->FontHeight *= scalingFactorHiDPI;
ToolbarLabel->FontHeight *= scalingFactorHiDPI;
ToolbarWindowLabel->FontHeight *= scalingFactorHiDPI;
ToolbarClock->FontHeight *= scalingFactorHiDPI;
Console->FontHeight *= scalingFactorHiDPI;
Dock->FontHeight *= scalingFactorHiDPI;
WindowLabelFocus->FontHeight *= scalingFactorHiDPI;
WindowLabelUnfocus->FontHeight *= scalingFactorHiDPI;
if (MenuTitle->borderWidth > 0) MenuTitle->borderWidth *= scalingFactorHiDPI;
if (MenuFrame->borderWidth > 0) MenuFrame->borderWidth *= scalingFactorHiDPI;
if (MenuActive->borderWidth > 0) MenuActive->borderWidth *= scalingFactorHiDPI;
if (MenuGrip->borderWidth > 0) MenuGrip->borderWidth *= scalingFactorHiDPI;
if (MenuSeparator->borderWidth > 0) MenuSeparator->borderWidth *= scalingFactorHiDPI;
if (Toolbar->borderWidth > 0) Toolbar->borderWidth *= scalingFactorHiDPI;
if (ToolbarLabel->borderWidth > 0) ToolbarLabel->borderWidth *= scalingFactorHiDPI;
if (ToolbarWindowLabel->borderWidth > 0) ToolbarWindowLabel->borderWidth *= scalingFactorHiDPI;
if (ToolbarClock->borderWidth > 0) ToolbarClock->borderWidth *= scalingFactorHiDPI;
if (ToolbarButton->borderWidth > 0) ToolbarButton->borderWidth *= scalingFactorHiDPI;
if (ToolbarButtonPressed->borderWidth > 0) ToolbarButtonPressed->borderWidth *= scalingFactorHiDPI;
if (Dock->borderWidth > 0) Dock->borderWidth *= scalingFactorHiDPI;
if (WindowTitleFocus->borderWidth > 0) WindowTitleFocus->borderWidth *= scalingFactorHiDPI;
if (WindowTitleUnfocus->borderWidth > 0) WindowTitleUnfocus->borderWidth *= scalingFactorHiDPI;
if (WindowLabelFocus->borderWidth > 0) WindowLabelFocus->borderWidth *= scalingFactorHiDPI;
if (WindowLabelUnfocus->borderWidth > 0) WindowLabelUnfocus->borderWidth *= scalingFactorHiDPI;
if (WindowButtonFocus->borderWidth > 0) WindowButtonFocus->borderWidth *= scalingFactorHiDPI;
if (WindowButtonUnfocus->borderWidth > 0) WindowButtonUnfocus->borderWidth *= scalingFactorHiDPI;
if (WindowButtonPressed->borderWidth > 0) WindowButtonPressed->borderWidth *= scalingFactorHiDPI;
if (WindowGripFocus->borderWidth > 0) WindowGripFocus->borderWidth *= scalingFactorHiDPI;
if (WindowGripUnfocus->borderWidth > 0) WindowGripUnfocus->borderWidth *= scalingFactorHiDPI;
if (WindowHandleFocus->borderWidth > 0) WindowHandleFocus->borderWidth *= scalingFactorHiDPI;
if (WindowHandleUnfocus->borderWidth > 0) WindowHandleUnfocus->borderWidth *= scalingFactorHiDPI;
if (MenuTitle->marginWidth > 0) MenuTitle->marginWidth *= scalingFactorHiDPI;
if (MenuFrame->marginWidth > 0) MenuFrame->marginWidth *= scalingFactorHiDPI;
if (MenuActive->marginWidth > 0) MenuActive->marginWidth *= scalingFactorHiDPI;
if (MenuGrip->marginWidth > 0) MenuGrip->marginWidth *= scalingFactorHiDPI;
if (MenuSeparator->marginWidth > 0) MenuSeparator->marginWidth *= scalingFactorHiDPI;
if (Toolbar->marginWidth > 0) Toolbar->marginWidth *= scalingFactorHiDPI;
if (ToolbarLabel->marginWidth > 0) ToolbarLabel->marginWidth *= scalingFactorHiDPI;
if (ToolbarWindowLabel->marginWidth > 0) ToolbarWindowLabel->marginWidth *= scalingFactorHiDPI;
if (ToolbarClock->marginWidth > 0) ToolbarClock->marginWidth *= scalingFactorHiDPI;
if (ToolbarButton->marginWidth > 0) ToolbarButton->marginWidth *= scalingFactorHiDPI;
if (ToolbarButtonPressed->marginWidth > 0) ToolbarButtonPressed->marginWidth *= scalingFactorHiDPI;
if (Dock->marginWidth > 0) Dock->marginWidth *= scalingFactorHiDPI;
if (WindowTitleFocus->marginWidth > 0) WindowTitleFocus->marginWidth *= scalingFactorHiDPI;
if (WindowTitleUnfocus->marginWidth > 0) WindowTitleUnfocus->marginWidth *= scalingFactorHiDPI;
if (WindowLabelFocus->marginWidth > 0) WindowLabelFocus->marginWidth *= scalingFactorHiDPI;
if (WindowLabelUnfocus->marginWidth > 0) WindowLabelUnfocus->marginWidth *= scalingFactorHiDPI;
if (WindowButtonFocus->marginWidth > 0) WindowButtonFocus->marginWidth *= scalingFactorHiDPI;
if (WindowButtonUnfocus->marginWidth > 0) WindowButtonUnfocus->marginWidth *= scalingFactorHiDPI;
if (WindowButtonPressed->marginWidth > 0) WindowButtonPressed->marginWidth *= scalingFactorHiDPI;
if (WindowGripFocus->marginWidth > 0) WindowGripFocus->marginWidth *= scalingFactorHiDPI;
if (WindowGripUnfocus->marginWidth > 0) WindowGripUnfocus->marginWidth *= scalingFactorHiDPI;
if (WindowHandleFocus->marginWidth > 0) WindowHandleFocus->marginWidth *= scalingFactorHiDPI;
if (WindowHandleUnfocus->marginWidth > 0) WindowHandleUnfocus->marginWidth *= scalingFactorHiDPI;
}
DestroyFileCache(styleCache);
}
bool Settings::ReadStyleElement(LPSTR styleCache, StyleItem* styleItem, LPSTR paramString, bool readFont)
{
char temp[MAX_LINE_LENGTH], param[MAX_LINE_LENGTH];
bool bb4nix070syntax = false;
strcpy_s(param, sizeofArray(param), paramString);
int nLen = strnlen_s(param, sizeofArray(param));
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".appearance:");
if (strnlen_s(GetString(NULL, styleCache, param, ""), MAX_LINE_LENGTH)) bb4nix070syntax = true;
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, appearancePointer));
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ":");
strcpy_s(appearancePointer, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, temp));
ParseItem(appearancePointer, styleItem);
styleItem->Image.bitmap = NULL;
if (styleItem->type == B_IMAGEFROMFILE)
{
if (strchr(appearancePointer, '\\'))
{
strncpy_s(styleItem->Image.path, sizeof(styleItem->Image.path), appearancePointer, _TRUNCATE);
}
else
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".image:");
strncpy_s(styleItem->Image.path, sizeof(styleItem->Image.path), GetString(NULL, styleCache, param, ""), _TRUNCATE);
}
styleItem->Image.path[sizeof(styleItem->Image.path)-1] = '\0';
if (strchr(styleItem->Image.path, '\"')) StrRemoveEncap((LPSTR)styleItem->Image.path);
if (strchr(styleItem->Image.path, '$')) ReplaceShellFolders((LPSTR)styleItem->Image.path);
if (strchr(styleItem->Image.path, '%')) ReplaceEnvVars((LPSTR)styleItem->Image.path);
styleItem->Image.width = styleItem->Image.height = styleItem->Image.left = styleItem->Image.top = styleItem->Image.right = styleItem->Image.bottom = 0;
if (FileExists(styleItem->Image.path))
{
CreateElementImage(styleItem);
}
else styleItem->type = B_SOLID;
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".borderColor:");
styleItem->borderColor = GetColor(NULL, styleCache, param, NULL, styleItem->borderColor, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".borderWidth:");
styleItem->borderWidth = GetInt(NULL, styleCache, param, styleItem->borderWidth);
if (bb4nix070syntax)
{
if (IsInString(appearancePointer, "border"))
{
styleItem->bordered = true;
}
else
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".borderWidth:");
if (strnlen_s(GetString(NULL, styleCache, param, ""), MAX_LINE_LENGTH))
{
styleItem->bordered = true;
}
}
}
else
{
if (styleItem->borderWidth > 0) styleItem->bordered = true;
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".marginWidth:");
styleItem->marginWidth = GetInt(NULL, styleCache, param, styleItem->marginWidth);
COLORREF tempColor;
if (!strchr(appearancePointer, '\\') && IsInString(appearancePointer, "auto"))
{
COLORREF colorAutoPicked;
int randomPixelX, randomPixelY;
RECT workArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&workArea, SPIF_SENDCHANGE);
int workAreaWidth = workArea.right - workArea.left;
int workAreaHeight = workArea.bottom - workArea.top;
HDC hdc = GetDC(GetDesktopWindow());
for (int n = 1; n <= 8; n++)
{
randomPixelX = (rand() % workAreaWidth);
randomPixelY = (rand() % workAreaHeight);
colorAutoPicked = GetPixel(hdc, workArea.left+randomPixelX, workArea.top+randomPixelY);
if (colorAutoPicked == CLR_INVALID) continue;
switch (n)
{
case 1: {styleItem->Color1 = colorAutoPicked; break; }
case 2: {styleItem->Color2 = colorAutoPicked; break; }
case 3: {styleItem->Color3 = colorAutoPicked; break; }
case 4: {styleItem->Color4 = colorAutoPicked; break; }
case 5: {styleItem->Color5 = colorAutoPicked; break; }
case 6: {styleItem->Color6 = colorAutoPicked; break; }
case 7: {styleItem->Color7 = colorAutoPicked; break; }
case 8: {styleItem->Color8 = colorAutoPicked; break; }
}
}
ReleaseDC(NULL, hdc);
DeleteDC(hdc);
}
else
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".backgroundColor:");
tempColor = GetColor(NULL, styleCache, param, NULL, styleItem->Color1, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color1:");
tempColor = GetColor(NULL, styleCache, param, NULL, tempColor, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color:");
styleItem->Color1 = GetColor(NULL, styleCache, param, NULL, tempColor, true);
if (styleItem->type == B_SOLID) styleItem->Color2 = styleItem->Color1;
else
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color2:");
tempColor = GetColor(NULL, styleCache, param, NULL, styleItem->Color2, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".colorTo:");
styleItem->Color2 = GetColor(NULL, styleCache, param, NULL, tempColor, true);
}
if ((styleItem->type >= B_SPLITHORIZONTAL) && (styleItem->type < B_MIRRORHORIZONTAL))
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color.splitTo:");
if (((styleItem->type == B_SPLITHORIZONTAL) || (styleItem->type == B_SPLITVERTICAL)) && strnlen_s(GetString(NULL, styleCache, param, ""), MAX_LINE_LENGTH))
{
styleItem->Color3 = styleItem->Color2;
styleItem->Color2 = styleItem->Color1;
int sr, sg, sb;
sr = GetRValue(styleItem->Color2);
sg = GetGValue(styleItem->Color2);
sb = GetBValue(styleItem->Color2);
sr += sr >> 2;
sg += sg >> 2;
sb += sb >> 2;
if (sr>0xff) sr = 0xff;
if (sg>0xff) sg = 0xff;
if (sb>0xff) sb = 0xff;
styleItem->Color1 = RGB(sr,sg,sb);
sr = GetRValue(styleItem->Color3);
sg = GetGValue(styleItem->Color3);
sb = GetBValue(styleItem->Color3);
sr += sr >> 4;
sg += sg >> 4;
sb += sb >> 4;
if (sr>0xff) sr = 0xff;
if (sg>0xff) sg = 0xff;
if (sb>0xff) sb = 0xff;
styleItem->Color4 = RGB(sr,sg,sb);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color.splitTo:");
styleItem->Color1 = GetColor(NULL, styleCache, param, NULL, styleItem->Color1, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".colorTo.splitTo:");
styleItem->Color4 = GetColor(NULL, styleCache, param, NULL, styleItem->Color4, true);
}
else
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color3:");
styleItem->Color3 = GetColor(NULL, styleCache, param, NULL, styleItem->Color3, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color4:");
styleItem->Color4 = GetColor(NULL, styleCache, param, NULL, styleItem->Color4, true);
if (styleItem->type >= B_SUPERHORIZONTAL)
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color5:");
styleItem->Color5 = GetColor(NULL, styleCache, param, NULL, styleItem->Color5, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color6:");
styleItem->Color6 = GetColor(NULL, styleCache, param, NULL, styleItem->Color6, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color7:");
styleItem->Color7 = GetColor(NULL, styleCache, param, NULL, styleItem->Color7, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".color8:");
styleItem->Color8 = GetColor(NULL, styleCache, param, NULL, styleItem->Color8, true);
}
}
}
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".textColor:");
styleItem->TextColor = GetColor(NULL, styleCache, param, NULL, styleItem->TextColor, true);
if (styleItem == MenuFrame)
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".disabledColor:");
styleItem->disabledColor = GetColor(NULL, styleCache, param, NULL, styleItem->TextColor, true);
}
if ((styleItem == ToolbarButton) || (styleItem == ToolbarButtonPressed) ||
(styleItem == WindowButtonFocus) || (styleItem == WindowButtonUnfocus) || (styleItem == WindowButtonPressed))
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".foregroundColor:");
tempColor = GetColor(NULL, styleCache, param, NULL, styleItem->PicColor, true);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".picColor:");
styleItem->PicColor = GetColor(NULL, styleCache, param, NULL, tempColor, true);
}
if (readFont)
{
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".font:");
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, styleItem->Font));
if (strchr(temp, '/'))
{
strcpy_s(temp, MAX_LINE_LENGTH, Tokenize(temp, styleItem->Font, "/"));
CheckFontSubstitution(styleItem->Font);
if (strnlen_s(temp, MAX_LINE_LENGTH))
{
char height[MAX_LINE_LENGTH];
strcpy_s(temp, MAX_LINE_LENGTH, Tokenize(temp, height, "/"));
if (atoi(height) > 0) styleItem->FontHeight = atoi(height);
if (strnlen_s(temp, MAX_LINE_LENGTH))
{
if (IsInString(temp, "Normal")) styleItem->FontWeight = FW_NORMAL;
if (IsInString(temp, "Bold")) styleItem->FontWeight = FW_BOLD;
if (IsInString(temp, "Outline")) styleItem->FontOutline = true;
if (IsInString(temp, "Shadow")) styleItem->FontShadow = true;
}
}
}
else
{
CheckFontSubstitution(temp);
strcpy_s(styleItem->Font, sizeofArray(styleItem->Font), temp);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".fontHeight:");
styleItem->FontHeight = GetInt(NULL, styleCache, param, styleItem->FontHeight);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".fontWeight:");
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, "Normal"));
if (IsInString(temp, "Bold")) styleItem->FontWeight = FW_BOLD;
else styleItem->FontWeight = FW_NORMAL;
if (IsInString(temp, "Outline")) styleItem->FontOutline = true;
if (IsInString(temp, "Shadow")) styleItem->FontShadow = true;
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".alignment:");
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, ""));
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".justify:");
strcpy_s(temp, MAX_LINE_LENGTH, GetString(NULL, styleCache, param, temp));
if (IsInString(temp, "Left")) styleItem->Justify = DT_LEFT;
else if (IsInString(temp, "Right")) styleItem->Justify = DT_RIGHT;
else if (IsInString(temp, "Center")) styleItem->Justify = DT_CENTER;
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".outlineColor:");
if (strnlen_s(GetString(NULL, styleCache, param, ""), MAX_LINE_LENGTH))
{
styleItem->FontOutline = true;
styleItem->OutlineColor = GetColor(NULL, styleCache, param, NULL, styleItem->OutlineColor, true);
}
else if (styleItem->FontOutline && (styleItem->OutlineColor == COLOR_UNDEFINED))
{
styleItem->OutlineColor = CreateShadowColor(styleItem, styleItem->Color1, styleItem->Color2, styleItem->TextColor);
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".shadowColor:");
if (strnlen_s(GetString(NULL, styleCache, param, ""), MAX_LINE_LENGTH))
{
styleItem->FontShadow = true;
styleItem->ShadowColor = GetColor(NULL, styleCache, param, NULL, styleItem->ShadowColor, true);
}
else if (styleItem->FontShadow && (styleItem->ShadowColor == COLOR_UNDEFINED))
{
if (styleItem->FontOutline) styleItem->ShadowColor = CreateShadowColor(styleItem, styleItem->Color1, styleItem->Color2, styleItem->OutlineColor);
else styleItem->ShadowColor = CreateShadowColor(styleItem, styleItem->Color1, styleItem->Color2, styleItem->TextColor);
}
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".shadowX:");
styleItem->ShadowX = GetInt(NULL, styleCache, param, 1);
strcpy_s(¶m[nLen], (sizeof(param)-nLen), ".shadowY:");
styleItem->ShadowY = GetInt(NULL, styleCache, param, 1);
}
return bb4nix070syntax;
}
void Settings::DeriveTaskbarStyle()
{
if (!ToolbarWindowLabel->parentRelative)
{
CopyMemory(ActiveTask, ToolbarWindowLabel, sizeof(StyleItem));
if (ActiveTask->type == B_ELLIPTIC) ActiveTask->ShadowColor = CreateShadowColor(ToolbarWindowLabel, ToolbarWindowLabel->ColorTo, ToolbarWindowLabel->Color, ToolbarWindowLabel->TextColor);
}
else if (!ToolbarLabel->parentRelative)
{
CopyMemory(ActiveTask, ToolbarLabel, sizeof(StyleItem));
if (ActiveTask->type == B_ELLIPTIC) ActiveTask->ShadowColor = CreateShadowColor(ToolbarLabel, ToolbarLabel->ColorTo, ToolbarLabel->Color, ToolbarLabel->TextColor);
}
else if (!ToolbarClock->parentRelative)
{
CopyMemory(ActiveTask, ToolbarClock, sizeof(StyleItem));
if (ActiveTask->type == B_ELLIPTIC) ActiveTask->ShadowColor = CreateShadowColor(ToolbarClock, ToolbarClock->ColorTo, ToolbarClock->Color, ToolbarClock->TextColor);
}
else
{
CopyMemory(ActiveTask, Toolbar, sizeof(StyleItem));
ActiveTask->TextColor = ToolbarWindowLabel->TextColor;
if (ActiveTask->type == B_ELLIPTIC) ActiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->ColorTo, Toolbar->Color, ToolbarWindowLabel->TextColor);
else ActiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, ToolbarWindowLabel->TextColor);
}
if (ActiveTask->borderWidth > 1) ActiveTask->borderWidth = 1;
CopyMemory(InactiveTask, Toolbar, sizeof(StyleItem));
if (ToolbarWindowLabel->parentRelative)
{
InactiveTask->TextColor = ToolbarWindowLabel->TextColor;
InactiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, ToolbarWindowLabel->TextColor);
}
else if (ToolbarLabel->parentRelative)
{
InactiveTask->TextColor = ToolbarLabel->TextColor;
InactiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, ToolbarLabel->TextColor);
}
else if (ToolbarClock->parentRelative)
{
InactiveTask->TextColor = ToolbarClock->TextColor;
InactiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, ToolbarClock->TextColor);
}
else if (ToolbarButton->parentRelative)
{
InactiveTask->TextColor = ToolbarButton->PicColor;
InactiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, ToolbarButton->PicColor);
}
else
{
InactiveTask->TextColor = Toolbar->TextColor;
InactiveTask->ShadowColor = CreateShadowColor(Toolbar, Toolbar->Color, Toolbar->ColorTo, Toolbar->TextColor);
}
if (InactiveTask->borderWidth > 1) InactiveTask->borderWidth = 1;
FlashingTask->Color = InvertColor(ActiveTask->ColorTo);
FlashingTask->ColorTo = InvertColor(ActiveTask->Color);
FlashingTask->Color3 = InvertColor(ActiveTask->Color4);
FlashingTask->Color4 = InvertColor(ActiveTask->Color3);
FlashingTask->TextColor = InvertColor(ActiveTask->TextColor);
FlashingTask->ShadowColor = InvertColor(ActiveTask->ShadowColor);
FlashingTask->OutlineColor = InvertColor(ActiveTask->OutlineColor);
FlashingTask->borderColor = InvertColor(ActiveTask->borderColor);
}
COLORREF Settings::CreateShadowColor(StyleItem* styleItem, COLORREF color, COLORREF colorTo, COLORREF textColor)
{
BYTE r = GetRValue(color);
BYTE g = GetGValue(color);
BYTE b = GetBValue(color);
BYTE rto = GetRValue(colorTo);
BYTE gto = GetGValue(colorTo);
BYTE bto = GetBValue(colorTo);
int rav, gav, bav;
if (styleItem->type != B_SOLID)
{
rav = (r+rto) / 2;
gav = (g+gto) / 2;
bav = (b+bto) / 2;
}
else
{
rav = r;
gav = g;
bav = b;
}
if (rav < 0x10) rav = 0;
else rav -= 0x10;
if (gav < 0x10) gav = 0;
else gav -= 0x10;
if (bav < 0x10) bav = 0;
else bav -= 0x10;
return RGB((BYTE)rav, (BYTE)gav, (BYTE)bav);
}
COLORREF Settings::InvertColor(COLORREF color)
{
red = 0xff - GetRValue(color);
green = 0xff - GetGValue(color);
blue = 0xff - GetBValue(color);
return RGB((BYTE)blue, (BYTE)green, (BYTE)red);
}
COLORREF Settings::MixColors(COLORREF colorA, COLORREF colorB)
{
BYTE rt = GetRValue(colorA);
BYTE gt = GetGValue(colorA);
BYTE bt = GetBValue(colorA);
BYTE rb = GetRValue(colorB);
BYTE gb = GetGValue(colorB);
BYTE bb = GetBValue(colorB);
int rav = (rt + rb) / 2;
int gav = (gt + gb) / 2;
int bav = (bt + bb) / 2;
return RGB((BYTE)rav, (BYTE)gav, (BYTE)bav);
}
void Settings::GetShellFolders()
{
GetBlackboxPath(SF_blackboxPath, MAX_PATH);
SF_blackboxPath[strnlen_s(SF_blackboxPath, sizeofArray(SF_blackboxPath))-1] = 0;
SHGetSpecialFolderPath(NULL, SF_startMenu, CSIDL_PROGRAMS, 0);
SHGetSpecialFolderPath(NULL, SF_commonStartMenu, CSIDL_COMMON_PROGRAMS, 0);
strcpy_s(SF_programFiles, "%SystemDrive%\\Program Files");
strcpy_s(SF_programFilesX86, "%SystemDrive%\\Program Files (x86)");
SHGetSpecialFolderPath(NULL, SF_desktop, CSIDL_DESKTOPDIRECTORY, 0);
SHGetSpecialFolderPath(NULL, SF_userProfile, CSIDL_PROFILE, 0);
strcpy_s(SF_userAppData, sizeofArray(SF_userAppData), SF_userProfile);
strcat_s(SF_userAppData, sizeofArray(SF_userAppData), "\\AppData");
strcpy_s(SF_currentThemePath, sizeofArray(SF_currentThemePath), SF_blackboxPath);
usingDefaultTheme = true;
bbrcPath();
extensionsrcPath();
strcpy_s(xobrcDefaultFile, sizeofArray(xobrcDefaultFile), xobrcFile);
}
bool Settings::GetBool(LPCSTR fp, LPSTR cachedFilePtr, LPCSTR szString, bool szDefault)
{
if (!cachedFilePtr && (!fp || !_stricmp(fp, ""))) return szDefault;
LPSTR buffer;
if (cachedFilePtr && !fp)
{
buffer = GetValueFromCache(cachedFilePtr, szString);
}
else
{
buffer = ReadValue(fp, szString, 0);
}
if (buffer)
{
if (!_stricmp(buffer, "true")) return true;
else if (!_stricmp(buffer, "false")) return false;
}
return szDefault;
}
int Settings::GetInt(LPCSTR fp, LPSTR cachedFilePtr, LPCSTR szString, int szDefault)
{
if (!cachedFilePtr && (!fp || !_stricmp(fp, "") || !_stricmp(fp, styleFile)))
{
if (!_strnicmp(szString, "toolbar.", 8))
{
if (szString[8] == 'l')
{
if (!_stricmp(&szString[13], ".borderWidth:")) return ToolbarLabel->borderWidth;
else if (!_stricmp(&szString[13], ".marginWidth:")) return ToolbarLabel->marginWidth;
else if (!_stricmp(&szString[13], ".fontHeight:")) return ToolbarLabel->FontHeight;
}
else if (szString[8] == 'w')
{
if (!_stricmp(&szString[19], ".borderWidth:")) return ToolbarWindowLabel->borderWidth;
else if (!_stricmp(&szString[19], ".marginWidth:")) return ToolbarWindowLabel->marginWidth;
else if (!_stricmp(&szString[19], ".fontHeight:")) return ToolbarWindowLabel->FontHeight;
}
else if (szString[8] == 'c')
{
if (!_stricmp(&szString[13], ".borderWidth:")) return ToolbarClock->borderWidth;
else if (!_stricmp(&szString[13], ".marginWidth:")) return ToolbarClock->marginWidth;
else if (!_stricmp(&szString[13], ".fontHeight:")) return ToolbarClock->FontHeight;
}
else
{
if (!_stricmp(&szString[7], ".borderWidth:")) return Toolbar->borderWidth;
else if (!_stricmp(&szString[7], ".marginWidth:")) return Toolbar->marginWidth;
else if (!_stricmp(&szString[7], ".fontHeight:")) return Toolbar->FontHeight;
}
}
else if (!_strnicmp(szString, "menu.", 5))
{
if (szString[5] == 't')
{
if (!_stricmp(&szString[10], ".borderWidth:")) return MenuTitle->borderWidth;
else if (!_stricmp(&szString[10], ".marginWidth:")) return MenuTitle->marginWidth;
else if (!_stricmp(&szString[10], ".fontHeight:")) return MenuTitle->FontHeight;
}
else if (szString[5] == 'f')
{
if (!_stricmp(&szString[10], ".borderWidth:")) return MenuFrame->borderWidth;
else if (!_stricmp(&szString[10], ".marginWidth:")) return MenuFrame->marginWidth;
else if (!_stricmp(&szString[10], ".fontHeight:")) return MenuFrame->FontHeight;
}
else if (szString[5] == 'h' || szString[5] == 'a')
{
if (!_stricmp(&szString[11], ".borderWidth:")) return MenuActive->borderWidth;
else if (!_stricmp(&szString[11], ".marginWidth:")) return MenuActive->marginWidth;
else if (!_stricmp(&szString[11], ".fontHeight:")) return MenuActive->FontHeight;
}
else if (szString[5] == 'g')
{
if (!_stricmp(&szString[9], ".borderWidth:")) return MenuGrip->borderWidth;
else if (!_stricmp(&szString[9], ".marginWidth:")) return MenuGrip->marginWidth;
else if (!_stricmp(&szString[9], ".fontHeight:")) return MenuGrip->FontHeight;
}
else if (!_stricmp(&szString[4], ".borderWidth:")) return menuBorderWidth;
}
else if (!_strnicmp(szString, "dock.", 5) || !_strnicmp(szString, "slit.", 5))
{
if (!_stricmp(&szString[5], ".borderWidth:")) return Dock->borderWidth;
else if (!_stricmp(&szString[5], ".marginWidth:")) return Dock->marginWidth;
}
else if (!_strnicmp(szString, "window.", 7))
{
if (szString[7] == 't')
{
if (szString[13] == 'f')
{
if (!_stricmp(&szString[18], ".borderWidth:")) return WindowTitleFocus->borderWidth;
else if (!_stricmp(&szString[18], ".marginWidth:")) return WindowTitleFocus->marginWidth;
}
else if (szString[13] == 'u')
{
if (!_stricmp(&szString[20], ".borderWidth:")) return WindowTitleUnfocus->borderWidth;
else if (!_stricmp(&szString[20], ".marginWidth:")) return WindowTitleUnfocus->marginWidth;
}
}
else if (szString[7] == 'l')
{
if (szString[13] == 'f')
{
if (!_stricmp(&szString[18], ".borderWidth:")) return WindowLabelFocus->borderWidth;
else if (!_stricmp(&szString[18], ".marginWidth:")) return WindowLabelFocus->marginWidth;
else if (!_stricmp(&szString[18], ".fontHeight:")) return WindowLabelFocus->FontHeight;
}
else if (szString[13] == 'u')
{
if (!_stricmp(&szString[20], ".borderWidth:")) return WindowLabelUnfocus->borderWidth;
else if (!_stricmp(&szString[20], ".marginWidth:")) return WindowLabelUnfocus->marginWidth;
else if (!_stricmp(&szString[20], ".fontHeight:")) return WindowLabelUnfocus->FontHeight;
}
}
else if (szString[7] == 'b')
{
if (szString[14] == 'f')
{
if (!_stricmp(&szString[19], ".borderWidth:")) return WindowButtonFocus->borderWidth;
else if (!_stricmp(&szString[19], ".marginWidth:")) return WindowButtonFocus->marginWidth;
}
else if (szString[14] == 'u')
{
if (!_stricmp(&szString[21], ".borderWidth:")) return WindowButtonUnfocus->borderWidth;
else if (!_stricmp(&szString[21], ".marginWidth:")) return WindowButtonUnfocus->marginWidth;
}
else if (szString[14] == 'p')
{
if (!_stricmp(&szString[21], ".borderWidth:")) return WindowButtonPressed->borderWidth;
else if (!_stricmp(&szString[21], ".marginWidth:")) return WindowButtonPressed->marginWidth;
}
}
else if (szString[7] == 'g')
{
if (szString[12] == 'f')
{
if (!_stricmp(&szString[17], ".borderWidth:")) return WindowGripFocus->borderWidth;
else if (!_stricmp(&szString[17], ".marginWidth:")) return WindowGripFocus->marginWidth;
}
else if (szString[12] == 'u')
{
if (!_stricmp(&szString[19], ".borderWidth:")) return WindowGripUnfocus->borderWidth;
else if (!_stricmp(&szString[19], ".marginWidth:")) return WindowGripUnfocus->marginWidth;
}
}
else if (szString[7] == 'h')
{
if (!_stricmp(&szString[6], ".handleHeight:")) return handleHeight;
else if (szString[14] == 'f')
{
if (!_stricmp(&szString[19], ".borderWidth:")) return WindowHandleFocus->borderWidth;
else if (!_stricmp(&szString[19], ".marginWidth:")) return WindowHandleFocus->marginWidth;
}
else if (szString[14] == 'u')
{
if (!_stricmp(&szString[21], ".borderWidth:")) return WindowHandleUnfocus->borderWidth;
else if (!_stricmp(&szString[21], ".marginWidth:")) return WindowHandleUnfocus->marginWidth;
}
}
}
else if (!_stricmp(szString, "borderWidth:")) return borderWidth;
else if (!_stricmp(szString, "bevelWidth:")) return bevelWidth;
else if (!_stricmp(szString, "handleHeight:") || !_stricmp(szString, "handleWidth:")) return handleHeight;
else if (!_stricmp(szString, "frameWidth:")) return frameWidth;
else if (!_stricmp(szString, "dpi.scaling.factor:") || !_stricmp(szString, "hidpi.scaling.factor:")) return scalingFactorHiDPI;
}
LPSTR buffer;
if (cachedFilePtr && !fp)
{
buffer = GetValueFromCache(cachedFilePtr, szString);
}
else
{
buffer = ReadValue(fp, szString, 0);
}
if (buffer)
{
int value = 0;
value = atoi(buffer);
return value;
}
return szDefault;
}
LPSTR Settings::GetString(LPCSTR fp, LPSTR cachedFilePtr, LPCSTR szString, LPSTR szDefault)
{
if (!cachedFilePtr && (!fp || !_stricmp(fp, "") || !_stricmp(fp, styleFile)))
{
if (strchr(szString, '*'))
{
if (!_stricmp(szString, "*font:")) return Wildcard->Font;
else if (!_stricmp(szString, "toolbar*font:")) return wildcardToolbarFont;
else if (!_stricmp(szString, "menu*font:")) return wildcardMenuFont;
else if (!_stricmp(szString, "window*font:")) return wildcardWindowFont;
else if (!_stricmp(szString, "*justify:") || !_stricmp(szString, "*alignment:")) return GetAlignmentAsString(Wildcard);
else if (!_stricmp(szString, "*.font:")) return Wildcard->Font;
else if (!_stricmp(szString, "*.justify:") || !_stricmp(szString, "*.alignment:")) return GetAlignmentAsString(Wildcard);
}
else if (!_strnicmp(szString, "toolbar", 7))
{
if (IsInString(szString, ".appearance:"))
{
if (!_stricmp(&szString[7], ".appearance:")) return toolbar;
else if (!_stricmp(&szString[7], ".label.appearance:")) return toolbarLabel;
else if (!_stricmp(&szString[7], ".windowLabel.appearance:")) return toolbarWindowLabel;
else if (!_stricmp(&szString[7], ".clock.appearance:")) return toolbarClock;
else if (!_stricmp(&szString[7], ".button.appearance:")) return toolbarButton;
else if (!_stricmp(&szString[7], ".button.pressed.appearance:")) return toolbarButtonPressed;
}
else
{
if (!_stricmp(&szString[7], ":")) return toolbar;
else if (!_stricmp(&szString[7], ".label:")) return toolbarLabel;
else if (!_stricmp(&szString[7], ".windowLabel:")) return toolbarWindowLabel;
else if (!_stricmp(&szString[7], ".clock:")) return toolbarClock;
else if (!_stricmp(&szString[7], ".button:")) return toolbarButton;
else if (!_stricmp(&szString[7], ".button.pressed:")) return toolbarButtonPressed;
else if (!_stricmp(&szString[7], ".font:")) return Toolbar->Font;
else if (!_stricmp(&szString[7], ".label.font:")) return ToolbarLabel->Font;
else if (!_stricmp(&szString[7], ".windowLabel.font:")) return ToolbarWindowLabel->Font;
else if (!_stricmp(&szString[7], ".clock.font:")) return ToolbarClock->Font;
else if (!_stricmp(&szString[7], ".alignment:") || !_stricmp(&szString[7], ".justify:")) return GetAlignmentAsString(Toolbar);
else if (!_stricmp(&szString[7], ".label.alignment:") || !_stricmp(&szString[7], ".label.justify:")) return GetAlignmentAsString(ToolbarLabel);
else if (!_stricmp(&szString[7], ".windowLabel.alignment:") || !_stricmp(&szString[7], ".windowLabel.justify:")) return GetAlignmentAsString(ToolbarWindowLabel);
else if (!_stricmp(&szString[7], ".clock.alignment:") || !_stricmp(&szString[7], ".clock.justify:")) return GetAlignmentAsString(ToolbarClock);
}
}
else if (!_strnicmp(szString, "menu.", 5))
{
if (szString[5] == 't')
{
if (!_stricmp(&szString[10], ":") || !_stricmp(&szString[10], ".appearance:")) return menuTitle;
else if (!_stricmp(&szString[10], ".font:")) return MenuTitle->Font;
else if (!_stricmp(&szString[10], ".alignment:") || !_stricmp(&szString[10], ".justify:")) return GetAlignmentAsString(MenuTitle);
}
else if (szString[5] == 'f')
{
if (!_stricmp(&szString[10], ":") || !_stricmp(&szString[10], ".appearance:")) return menuFrame;
else if (!_stricmp(&szString[10], ".font:")) return MenuFrame->Font;
else if (!_stricmp(&szString[10], ".alignment:") || !_stricmp(&szString[10], ".justify:")) return GetAlignmentAsString(MenuFrame);
}
else if (szString[5] == 'b')
{
if (!_stricmp(&szString[11], ":") || !_stricmp(&szString[11], ".appearance:")) return menuFrameBulletAsString;
else if (!_stricmp(&szString[11], ".position:")) return menuBulletPosition;
}
else if (!_stricmp(&szString[4], ".active.appearance:") || !_stricmp(&szString[4], ".hilite:") || !_stricmp(&szString[4], ".active:")) return menuActive;
else if (!_stricmp(&szString[4], ".grip.appearance:") || !_stricmp(&szString[4], ".grip:")) return menuGrip;
else if (!_stricmp(&szString[4], ".indicator.appearance:") || !_stricmp(&szString[4], ".indicator:")) return menuIndicator;
}
else if (!_strnicmp(szString, "dock", 4) || !_strnicmp(szString, "slit", 4))
{
if (!_stricmp(&szString[4], ":") || !_stricmp(&szString[4], ".appearance:")) return dock;
}
else if (!_strnicmp(szString, "window.", 7))
{
if (szString[7] == 't')
{
if (szString[13] == 'f')
{
if (!_stricmp(&szString[18], ":") || !_stricmp(&szString[18], ".appearance:")) return windowTitleFocus;
}
else if (szString[13] == 'u')
{
if (!_stricmp(&szString[20], ":") || !_stricmp(&szString[20], ".appearance:")) return windowTitleUnfocus;
}
}
else if (szString[7] == 'l')
{
if (szString[13] == 'f')
{
if (!_stricmp(&szString[18], ":") || !_stricmp(&szString[18], ".appearance:")) return windowLabelFocus;
else if (!_stricmp(&szString[18], ".font:")) return WindowLabelFocus->Font;
else if (!_stricmp(&szString[18], ".alignment:") || !_stricmp(&szString[18], ".justify:")) return GetAlignmentAsString(WindowLabelFocus);
}
else if (szString[13] == 'u')
{
if (!_stricmp(&szString[20], ":") || !_stricmp(&szString[20], ".appearance:")) return windowLabelUnfocus;
else if (!_stricmp(&szString[20], ".font:")) return WindowLabelUnfocus->Font;
else if (!_stricmp(&szString[20], ".alignment:") || !_stricmp(&szString[20], ".justify:")) return GetAlignmentAsString(WindowLabelUnfocus);
}
}
else if (szString[7] == 'b')
{
if (szString[14] == 'f')
{
if (!_stricmp(&szString[19], ":") || !_stricmp(&szString[19], ".appearance:")) return windowButtonFocus;
}
else if (szString[14] == 'u')
{
if (!_stricmp(&szString[21], ":") || !_stricmp(&szString[21], ".appearance:")) return windowButtonUnfocus;
}
else if (szString[14] == 'p')
{
if (!_stricmp(&szString[21], ":") || !_stricmp(&szString[21], ".appearance:")) return windowButtonPressed;
}
}
else if (szString[7] == 'g')
{
if (szString[12] == 'f')
{
if (!_stricmp(&szString[17], ":") || !_stricmp(&szString[17], ".appearance:")) return windowGripFocus;
}
else if (szString[12] == 'u')
{
if (!_stricmp(&szString[19], ":") || !_stricmp(&szString[19], ".appearance:")) return windowGripUnfocus;
}
}
else if (szString[7] == 'h')
{
if (szString[14] == 'f')
{
if (!_stricmp(&szString[19], ":") || !_stricmp(&szString[19], ".appearance:")) return windowHandleFocus;
}
else if (szString[14] == 'u')
{
if (!_stricmp(&szString[21], ":") || !_stricmp(&szString[21], ".appearance:")) return windowHandleUnfocus;
}
}
}
else if (!_strnicmp(szString, "hardware", 8))
{
if (!_stricmp(&szString[8], ":") || !_stricmp(&szString[8], ".appearance:")) return externalHardware;
}
}
LPSTR buffer;
if (cachedFilePtr && !fp)
{
buffer = GetValueFromCache(cachedFilePtr, szString);
}
else
{
buffer = ReadValue(fp, szString, 0);
}
if (buffer) return buffer;
return szDefault;
}
static wchar_t GetStringUnicodeBuffer[MAX_LINE_LENGTH];
LPWSTR Settings::GetStringUnicode(LPCSTR fp, LPSTR cachedFilePtr, LPCSTR szString, LPWSTR szDefault)
{
char stringANSI[MAX_LINE_LENGTH];
strcpy_s(stringANSI, sizeofArray(stringANSI), GetString(fp, cachedFilePtr, szString, ""));
stringANSI[sizeofArray(stringANSI)-1] = '\0';
if (strnlen_s(stringANSI, sizeofArray(stringANSI)) > 0)
{
MultiByteToWideChar(CP_UTF8, 0, stringANSI, strnlen_s(stringANSI, sizeofArray(stringANSI))+1, GetStringUnicodeBuffer, MAX_LINE_LENGTH);
return GetStringUnicodeBuffer;
}
return szDefault;
}
COLORREF Settings::GetColor(LPCSTR fp, LPSTR cachedFilePtr, LPCSTR szString, LPCSTR szDefault, COLORREF szDefaultRef, bool useDefaultRef)
{
if (!cachedFilePtr)
{
if (!fp || !_stricmp(fp, "") || !_stricmp(fp, styleFile))
{
char* ptr = NULL;
StyleItem* si = NULL;
if (strchr(szString, '*'))
{
if (!_stricmp(szString, "*.textColor:") || !_stricmp(szString, "*textColor:")) return Wildcard->TextColor;
}
else if (!_strnicmp(szString, "toolbar", 7))
{
if (!_strnicmp(&szString[7], ".clock", 6))
{
ptr = (char*)&szString[13];
si = ToolbarClock;
}
else if (!_strnicmp(&szString[7], ".label", 6))
{
ptr = (char*)&szString[13];
si = ToolbarLabel;
}
else if (!_strnicmp(&szString[7], ".windowLabel", 12))
{
ptr = (char*)&szString[19];
si = ToolbarWindowLabel;
}
else if (!_strnicmp(&szString[7], ".button.pressed", 15))
{
ptr = (char*)&szString[22];
si = ToolbarButtonPressed;
}
else if (!_strnicmp(&szString[7], ".button", 7))
{
ptr = (char*)&szString[14];
si = ToolbarButton;
}
else
{
ptr = (char*)&szString[7];
si = Toolbar;
}
}
else if (!_strnicmp(szString, "menu", 4))
{
if (!_strnicmp(&szString[4], ".title", 6))
{
ptr = (char*)&szString[10];
si = MenuTitle;
}
else if (!_strnicmp(&szString[4], ".frame", 6))
{
if (!_stricmp(&szString[10], ".bulletColor:")) return MenuFrame->BulletColor;
else if (!_stricmp(&szString[10], ".disableColor:")) return MenuFrame->disabledColor;
ptr = (char*)&szString[10];
si = MenuFrame;
}
else if (!_strnicmp(&szString[4], ".hilite", 7) || !_strnicmp(&szString[4], ".active", 7))
{
if (!_stricmp(&szString[11], ".bulletColor:")) return MenuActive->BulletColor;
ptr = (char*)&szString[11];
si = MenuActive;
}
else if (!_strnicmp(&szString[4], ".indicator", 10))
{
ptr = (char*)&szString[14];
si = MenuIndicator;
}
else if (!_stricmp(&szString[4], ".separator.color:")) return MenuSeparator->Color;
else if (!_stricmp(&szString[4], ".borderColor:")) return menuBorderColor;
}
else if (!_strnicmp(szString, "dock", 4) || !_strnicmp(szString, "slit", 4))
{
ptr = (char*)&szString[4];
si = Dock;
}
else if (!_strnicmp(szString, "window", 6))
{
if (!_strnicmp(&szString[6], ".title", 6))
{
if (!_strnicmp(&szString[12], ".focus", 6))
{
ptr = (char*)&szString[18];
si = WindowTitleFocus;
}
else if (!_strnicmp(&szString[12], ".unfocus", 8))
{
ptr = (char*)&szString[20];
si = WindowTitleUnfocus;
}
}
else if (!_strnicmp(&szString[6], ".label", 6))
{
if (!_strnicmp(&szString[12], ".focus", 6))
{
ptr = (char*)&szString[18];
si = WindowLabelFocus;
}
else if (!_strnicmp(&szString[12], ".unfocus", 8))
{
ptr = (char*)&szString[20];
si = WindowLabelUnfocus;
}
}
else if (!_strnicmp(&szString[6], ".button", 7))
{
if (!_strnicmp(&szString[13], ".focus", 6))
{
ptr = (char*)&szString[19];
si = WindowButtonFocus;
}
else if (!_strnicmp(&szString[13], ".unfocus", 8))
{
ptr = (char*)&szString[21];
si = WindowButtonUnfocus;
}
else if (!_strnicmp(&szString[13], ".pressed", 8))
{
ptr = (char*)&szString[21];
si = WindowButtonPressed;
}
}
else if (!_strnicmp(&szString[6], ".grip", 5))
{
if (!_strnicmp(&szString[11], ".focus", 6))
{
ptr = (char*)&szString[17];
si = WindowGripFocus;
}
else if (!_strnicmp(&szString[11], ".unfocus", 8))
{
ptr = (char*)&szString[19];
si = WindowGripUnfocus;
}
}
else if (!_strnicmp(&szString[6], ".handle", 7))
{
if (!_strnicmp(&szString[13], ".focus", 6))
{
ptr = (char*)&szString[19];
si = WindowHandleFocus;
}
else if (!_strnicmp(&szString[13], ".unfocus", 8))
{
ptr = (char*)&szString[21];
si = WindowHandleUnfocus;
}
}
}
else if (!_strnicmp(szString, "hardware", 8))
{
ptr = (char*)&szString[8];
si = ExternalHardware;
}
if (ptr != NULL)
{
if (!_stricmp(ptr, ".color:") || !_stricmp(ptr, ".color1:") || !_stricmp(ptr, ".backgroundColor:")) return si->Color;
else if (!_stricmp(ptr, ".colorTo:") || !_stricmp(ptr, ".color2:")) return si->ColorTo;
else if (!_stricmp(ptr, ".color3:")) return si->Color3;
else if (!_stricmp(ptr, ".color4:")) return si->Color4;
else if (!_stricmp(ptr, ".color5:")) return si->Color5;
else if (!_stricmp(ptr, ".color6:")) return si->Color6;
else if (!_stricmp(ptr, ".color7:")) return si->Color7;
else if (!_stricmp(ptr, ".color8:")) return si->Color8;
else if (!_stricmp(ptr, ".textColor:")) return si->TextColor;
else if (!_stricmp(ptr, ".borderColor:")) return si->borderColor;
else if (!_stricmp(ptr, ".picColor:") || !_stricmp(ptr, ".bulletColor:") || !_stricmp(ptr, ".foregroundColor:")) return si->foregroundColor;
}
else if (!_stricmp(szString, "borderColor:")) return borderColor;
}
}
COLORREF value;
char colorString[MAX_LINE_LENGTH];
char tempString[MAX_LINE_LENGTH];
char cr[4], cg[4], cb[4];
LPSTR buffer;
if (cachedFilePtr && !fp)
{
buffer = GetValueFromCache(cachedFilePtr, szString);
}
else
{
if (!fp || !_stricmp(fp, "")) buffer = ReadValue(styleFile, szString, 0);
else buffer = ReadValue(fp, szString, 0);
}
if (buffer) strcpy_s(colorString, sizeofArray(colorString), buffer);
else
{
if (useDefaultRef) return szDefaultRef;
else strcpy_s(colorString, sizeofArray(colorString), szDefault);
}
if (*colorString == '#') memmove(colorString, colorString+1, strnlen_s(colorString, sizeofArray(colorString)));
else if (colorString[3]== ':')
{
strcpy_s(tempString, sizeofArray(tempString), Tokenize(colorString, colorString, ":"));
strcpy_s(tempString, sizeofArray(tempString), Tokenize(tempString, cr, "/"));
strcpy_s(tempString, sizeofArray(tempString), Tokenize(tempString, cg, "/"));
strcpy_s(cb, sizeofArray(cb), tempString);
strcpy_s(colorString, sizeofArray(colorString), cr);
if (strnlen_s(cr, sizeofArray(cr))==1) strcat_s(colorString, sizeofArray(colorString), cr);
strcat_s(colorString, sizeofArray(colorString), cg);
if (strnlen_s(cg, sizeofArray(cg))==1) strcat_s(colorString, sizeofArray(colorString), cg);
strcat_s(colorString, sizeofArray(colorString), cb);
if (strnlen_s(cb, sizeofArray(cb))==1) strcat_s(colorString, sizeofArray(colorString), cb);
}
else if (isalpha(*colorString))
{
value = ParseLiteralColor(colorString);
if (value) return value;
}
value = strtol(colorString, NULL, 16);
value = RGB(GetBValue(value), GetGValue(value), GetRValue(value));
return value;
}
static char valueFromCache[MAX_LINE_LENGTH+1];
LPSTR Settings::GetValueFromCache(LPSTR cachedFilePtr, LPCSTR szString)
{
char* ptr = cachedFilePtr;
char* ptr2 = cachedFilePtr;
for (;;)
{
ptr = StrStrI(ptr2, szString);
if (ptr == NULL) return NULL;
else if (!CheckForComment(cachedFilePtr, ptr)) break;
ptr2 = ptr+1;
}
ptr += strlen(szString);
ptr += strspn(ptr, " \t");
ptr2 = ptr;
for (int i=0; i<MAX_LINE_LENGTH; i++)
{
if ((ptr2[0] == '\n') || (ptr2[0] == EOF) || (ptr2[0] == 26))
{
valueFromCache[i] = '\0';
break;
}
else
{
valueFromCache[i] = ptr2[0];
ptr2++;
}
}
valueFromCache[MAX_LINE_LENGTH-1] = '\0';
int nLen = strnlen_s(valueFromCache, sizeofArray(valueFromCache));
if (nLen == 0) return NULL;
while (nLen >0 && valueFromCache[nLen-1] == ' ') nLen--;
valueFromCache[nLen] = '\0';
return valueFromCache;
}
bool Settings::CheckForComment(LPSTR cachedFilePtr, LPSTR ptr)
{
LPSTR ptr2 = ptr - 1;
if (ptr2[0] == '.') return true;
for (;;)
{
if ((ptr2[0] == '\n') || (ptr2[0] == EOF) || (ptr2[0] == 26)) return false;
else if ((ptr2[0] == '!') || (ptr2[0] == '#')) return true;
else if (ptr2 == cachedFilePtr) return false;
else ptr2--;
}
}
void Settings::UpdateAppearanceString(StyleItem* styleItem)
{
if (styleItem->type == B_IMAGEFROMFILE) return;
if (styleItem == Toolbar) appearancePointer = toolbar;
else if (styleItem == ToolbarLabel) appearancePointer = toolbarLabel;
else if (styleItem == ToolbarWindowLabel) appearancePointer = toolbarWindowLabel;
else if (styleItem == ToolbarClock) appearancePointer = toolbarClock;
else if (styleItem == ToolbarButton) appearancePointer = toolbarButton;
else if (styleItem == ToolbarButtonPressed) appearancePointer = toolbarButtonPressed;
else if (styleItem == MenuTitle) appearancePointer = menuTitle;
else if (styleItem == MenuFrame) appearancePointer = menuFrame;
else if (styleItem == MenuActive) appearancePointer = menuActive;
else if (styleItem == MenuGrip) appearancePointer = menuGrip;
else if (styleItem == MenuIndicator) appearancePointer = menuIndicator;
else if (styleItem == Dock) appearancePointer = dock;
else if (styleItem == Console) appearancePointer = console;
else if (styleItem == WindowTitleFocus) appearancePointer = windowTitleFocus;
else if (styleItem == WindowTitleUnfocus) appearancePointer = windowTitleUnfocus;
else if (styleItem == WindowLabelFocus) appearancePointer = windowLabelFocus;
else if (styleItem == WindowLabelUnfocus) appearancePointer = windowLabelUnfocus;
else if (styleItem == WindowButtonFocus) appearancePointer = windowButtonFocus;
else if (styleItem == WindowButtonUnfocus) appearancePointer = windowButtonUnfocus;
else if (styleItem == WindowButtonPressed) appearancePointer = windowButtonPressed;
else if (styleItem == WindowGripFocus) appearancePointer = windowGripFocus;
else if (styleItem == WindowGripUnfocus) appearancePointer = windowGripUnfocus;
else if (styleItem == WindowHandleFocus) appearancePointer = windowHandleFocus;
else if (styleItem == WindowHandleUnfocus) appearancePointer = windowHandleUnfocus;
else if (styleItem == ExternalHardware) appearancePointer = externalHardware;
else return;
appearancePointer[0] = '\0';
if (styleItem->type == B_PARENTRELATIVE || styleItem->parentRelative) strcat_s(appearancePointer, MAX_LINE_LENGTH, "ParentRelative");
else
{
if (styleItem->bevelstyle == BEVEL_RAISED) strcat_s(appearancePointer, MAX_LINE_LENGTH, "Raised");
else if (styleItem->bevelstyle == BEVEL_SUNKEN) strcat_s(appearancePointer, MAX_LINE_LENGTH, "Sunken");
else strcat_s(appearancePointer, MAX_LINE_LENGTH, "Flat");
if (styleItem->type == B_SOLID) strcat_s(appearancePointer, MAX_LINE_LENGTH, " Solid");
else
{
strcat_s(appearancePointer, MAX_LINE_LENGTH, " Gradient");
switch (styleItem->type)
{
case B_HORIZONTAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Horizontal"); break; }
case B_VERTICAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Vertical"); break; }
case B_DIAGONAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Diagonal"); break; }
case B_CROSSDIAGONAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " CrossDiagonal"); break; }
case B_PIPECROSS: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Pipecross"); break; }
case B_ELLIPTIC: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Elliptic"); break; }
case B_RECTANGLE: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Rectangle"); break; }
case B_PYRAMID: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " Pyramid"); break; }
case B_MIRRORHORIZONTAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " MirrorHorizontal"); break; }
case B_MIRRORVERTICAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " MirrorVertical"); break; }
case B_SPLITSOLID: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " SplitSolid"); break; }
case B_SPLITHORIZONTAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " SplitHorizontal"); break; }
case B_SPLITVERTICAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " SplitVertical"); break; }
case B_SUPERHORIZONTAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " SuperHorizontal"); break; }
case B_SUPERVERTICAL: { strcat_s(appearancePointer, MAX_LINE_LENGTH, " SuperVertical"); break; }
default: break;
}
}
if (styleItem->bevelstyle != BEVEL_FLAT)
{
if (styleItem->bevelposition == BEVEL2) strcat_s(appearancePointer, MAX_LINE_LENGTH, " Bevel2");
else strcat_s(appearancePointer, MAX_LINE_LENGTH, " Bevel1");
}
if (styleItem->interlaced) strcat_s(appearancePointer, MAX_LINE_LENGTH, " Interlaced");
}
}
char justifyLeft[5] = "Left", justifyCenter[7] = "Center", justifyRight[6] = "Right";
LPSTR Settings::GetAlignmentAsString(StyleItem* styleItem)
{
if (styleItem->Justify == DT_LEFT) return justifyLeft;
else if (styleItem->Justify == DT_RIGHT) return justifyRight;
else return justifyCenter;
}
void Settings::ParsePlacement(LPSTR inputString, Placement* outputPlacement)
{
strncpy_s(outputPlacement->rcString, sizeof(outputPlacement->rcString), inputString, _TRUNCATE);
outputPlacement->rcString[sizeof(outputPlacement->rcString)-1] = '\0';
if (inputString[0] == 'M' || inputString[0] == 'm')
{
char tempPlacement[MAX_LINE_LENGTH];
strcpy_s(tempPlacement, sizeofArray(tempPlacement), inputString);
char token1[MAX_LINE_LENGTH], token2[MAX_LINE_LENGTH], token3[MAX_LINE_LENGTH];
LPSTR tokens[2];
tokens[0] = token1;
tokens[1] = token2;
token1[0] = token2[0] = token3[0] = '\0';
BBTokenize (tempPlacement, tokens, 2, token3);
outputPlacement->placement = PLACEMENT_MANUAL;
if (token2[1] == 'C')
{
outputPlacement->centeredx = true;
if (strnlen_s(token2, sizeofArray(token2)) > 2) outputPlacement->rcx = atoi(&token2[2]);
else outputPlacement->rcx = 0;
}
else
{
outputPlacement->centeredx = false;
outputPlacement->rcx = atoi(&token2[1]);
}
if (token3[1] == 'C')
{
outputPlacement->centeredy = true;
if (strnlen_s(token3, sizeofArray(token3)) > 2) outputPlacement->rcy = atoi(&token3[2]);
else outputPlacement->rcy = 0;
}
else
{
outputPlacement->centeredy = false;
outputPlacement->rcy = atoi(&token3[1]);
}
return;
}
if (inputString[0] == 'T' || inputString[0] == 't')
{
if (inputString[3] == 'L') outputPlacement->placement = PLACEMENT_TOP_LEFT;
else if (inputString[3] == 'C') outputPlacement->placement = PLACEMENT_TOP_CENTER;
else if (inputString[3] == 'R') outputPlacement->placement = PLACEMENT_TOP_RIGHT;
}
else if (inputString[0] == 'C' || inputString[0] == 'c')
{
if (inputString[6] == 'L') outputPlacement->placement = PLACEMENT_CENTER_LEFT;
if (inputString[6] == 'C') outputPlacement->placement = PLACEMENT_CENTER_CENTER;
else if (inputString[6] == 'R') outputPlacement->placement = PLACEMENT_CENTER_RIGHT;
}
else if (inputString[0] == 'B' || inputString[0] == 'b')
{
if (inputString[6] == 'L') outputPlacement->placement = PLACEMENT_BOTTOM_LEFT;
else if (inputString[6] == 'C') outputPlacement->placement = PLACEMENT_BOTTOM_CENTER;
else if (inputString[6] == 'R') outputPlacement->placement = PLACEMENT_BOTTOM_RIGHT;
}
else if (inputString[0] == 'D' || inputString[0] == 'd')
{
outputPlacement->placement = PLACEMENT_DEFAULT;
}
else if (inputString[0] == 'O' || inputString[0] == 'o')
{
outputPlacement->placement = PLACEMENT_OPPOSITE_TOOLBAR;
}
else if (inputString[0] == 'N' || inputString[0] == 'n')
{
if (outputPlacement->placement >= PLACEMENT_TOP_LEFT && outputPlacement->placement < PLACEMENT_BOTTOM_RIGHT) outputPlacement->placement++;
else outputPlacement->placement = PLACEMENT_TOP_LEFT;
}
else if (inputString[0] == 'P' || inputString[0] == 'p')
{
if (outputPlacement->placement <= PLACEMENT_BOTTOM_RIGHT && outputPlacement->placement > PLACEMENT_TOP_LEFT) outputPlacement->placement--;
else outputPlacement->placement = PLACEMENT_BOTTOM_RIGHT;
}
else if (outputPlacement->placement < PLACEMENT_MANUAL || outputPlacement->placement > PLACEMENT_OPPOSITE_TOOLBAR)
{
outputPlacement->placement = PLACEMENT_BOTTOM_CENTER;
}
}
void Settings::PositionFromPlacement(Placement* inputPlacement)
{
if (!multimonPlacements || (GetSystemMetrics(SM_CMONITORS) == 1))
{
if (explorerHidden)
{
ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
ScreenX = 0;
ScreenY = 0;
}
else
{
RECT workArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&workArea, SPIF_SENDCHANGE);
ScreenWidth = workArea.right - workArea.left;
ScreenHeight = workArea.bottom - workArea.top;
ScreenX = workArea.left;
ScreenY = workArea.top;
}
}
else
{
ScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
ScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
ScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN);
ScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN);
}
int tempPlacement = inputPlacement->placement;
if (tempPlacement == PLACEMENT_OPPOSITE_TOOLBAR)
{
switch (ToolbarPlacement.placement)
{
case PLACEMENT_TOP_LEFT:
tempPlacement = PLACEMENT_BOTTOM_LEFT;
break;
case PLACEMENT_TOP_CENTER:
tempPlacement = PLACEMENT_BOTTOM_CENTER;
break;
case PLACEMENT_TOP_RIGHT:
tempPlacement = PLACEMENT_BOTTOM_RIGHT;
break;
case PLACEMENT_CENTER_LEFT:
tempPlacement = PLACEMENT_CENTER_RIGHT;
break;
case PLACEMENT_CENTER_RIGHT:
tempPlacement = PLACEMENT_CENTER_LEFT;
break;
case PLACEMENT_BOTTOM_LEFT:
tempPlacement = PLACEMENT_TOP_LEFT;
break;
case PLACEMENT_BOTTOM_CENTER:
tempPlacement = PLACEMENT_TOP_CENTER;
break;
case PLACEMENT_BOTTOM_RIGHT:
tempPlacement = PLACEMENT_TOP_RIGHT;
break;
default:
tempPlacement = PLACEMENT_CENTER_RIGHT;
}
}
switch (tempPlacement)
{
case PLACEMENT_MANUAL:
{
if (inputPlacement->centeredx) inputPlacement->x = inputPlacement->rcx + (ScreenWidth - inputPlacement->width) / 2;
else inputPlacement->x = inputPlacement->rcx;
if (inputPlacement->centeredy) inputPlacement->y = inputPlacement->rcy + (ScreenHeight - inputPlacement->height) / 2;
else inputPlacement->y = inputPlacement->rcy;
if (inputPlacement->x < 0) inputPlacement->x = ScreenWidth + inputPlacement->x - inputPlacement->width;
if (inputPlacement->y < 0) inputPlacement->y = ScreenHeight + inputPlacement->y - inputPlacement->height;
int xmax = ScreenWidth - inputPlacement->width;
int ymax = ScreenHeight - inputPlacement->height;
if (inputPlacement->x < 0) inputPlacement->x = 0;
if (inputPlacement->y < 0) inputPlacement->y = 0;
if (inputPlacement->x > xmax) inputPlacement->x = xmax;
if (inputPlacement->y > ymax) inputPlacement->y = ymax;
}
break;
case PLACEMENT_TOP_LEFT:
{
inputPlacement->x = 0;
inputPlacement->y = 0;
}
break;
case PLACEMENT_TOP_CENTER:
{
inputPlacement->x = (ScreenWidth - inputPlacement->width) / 2;
inputPlacement->y = 0;
}
break;
case PLACEMENT_TOP_RIGHT:
{
inputPlacement->x = ScreenWidth - inputPlacement->width;
inputPlacement->y = 0;
}
break;
case PLACEMENT_BOTTOM_LEFT:
{
inputPlacement->x = 0;
inputPlacement->y = ScreenHeight - inputPlacement->height;
}
break;
case PLACEMENT_BOTTOM_CENTER:
{
inputPlacement->x = (ScreenWidth - inputPlacement->width) / 2;
inputPlacement->y = ScreenHeight - inputPlacement->height;
}
break;
case PLACEMENT_BOTTOM_RIGHT:
{
inputPlacement->x = ScreenWidth - inputPlacement->width;
inputPlacement->y = ScreenHeight - inputPlacement->height;
}
break;
case PLACEMENT_CENTER_LEFT:
{
inputPlacement->x = 0;
inputPlacement->y = (ScreenHeight - inputPlacement->height) / 2;
}
break;
case PLACEMENT_CENTER_CENTER:
{
inputPlacement->x = (ScreenWidth - inputPlacement->width) / 2;
inputPlacement->y = (ScreenHeight - inputPlacement->height) / 2;
}
break;
case PLACEMENT_DEFAULT:
{
inputPlacement->x = (ScreenWidth - inputPlacement->width) / 2;
inputPlacement->y = ScreenHeight - inputPlacement->height - inputPlacement->x;
}
break;
default:
{
inputPlacement->x = ScreenWidth - inputPlacement->width;
inputPlacement->y = (ScreenHeight - inputPlacement->height) / 2;
}
}
inputPlacement->x += ScreenX;
inputPlacement->y += ScreenY;
}
void Settings::WritePlacement(Placement* inputPlacement)
{
char outputString[255], outputX[5], outputY[5];
switch (inputPlacement->placement)
{
case PLACEMENT_MANUAL:
{
if (inputPlacement->centeredx)
{
if (inputPlacement->rcx != 0) sprintf_s(outputX, sizeofArray(outputX), "xC%d", inputPlacement->rcx);
else strcpy_s(outputX, sizeofArray(outputX), "xC");
}
else sprintf_s(outputX, sizeofArray(outputX), "x%d", inputPlacement->rcx);
if (inputPlacement->centeredy)
{
if (inputPlacement->rcy != 0) sprintf_s(outputY, sizeofArray(outputY), "yC%d", inputPlacement->rcy);
else strcpy_s(outputY, sizeofArray(outputY), "yC");
}
else sprintf_s(outputY, sizeofArray(outputY), "y%d", inputPlacement->rcy);
sprintf_s(outputString, sizeofArray(outputString), "Manual %s %s", outputX, outputY);
break;
}
case PLACEMENT_TOP_LEFT: { strcpy_s(outputString, sizeofArray(outputString), "TopLeft"); break; }
case PLACEMENT_TOP_CENTER: { strcpy_s(outputString, sizeofArray(outputString), "TopCenter"); break; }
case PLACEMENT_TOP_RIGHT: { strcpy_s(outputString, sizeofArray(outputString), "TopRight"); break; }
case PLACEMENT_CENTER_LEFT: { strcpy_s(outputString, sizeofArray(outputString), "CenterLeft"); break; }
case PLACEMENT_CENTER_CENTER: { strcpy_s(outputString, sizeofArray(outputString), "CenterCenter"); break; }
case PLACEMENT_CENTER_RIGHT: { strcpy_s(outputString, sizeofArray(outputString), "CenterRight"); break; }
case PLACEMENT_BOTTOM_LEFT: { strcpy_s(outputString, sizeofArray(outputString), "BottomLeft"); break; }
case PLACEMENT_BOTTOM_CENTER: { strcpy_s(outputString, sizeofArray(outputString), "BottomCenter"); break; }
case PLACEMENT_BOTTOM_RIGHT: { strcpy_s(outputString, sizeofArray(outputString), "BottomRight"); break; }
case PLACEMENT_OPPOSITE_TOOLBAR: { strcpy_s(outputString, sizeofArray(outputString), "OppositeToolbar"); break; }
case PLACEMENT_DEFAULT: { strcpy_s(outputString, sizeofArray(outputString), "Default"); break; }
default:
return;
}
strncpy_s(inputPlacement->rcString, sizeof(inputPlacement->rcString), outputString, _TRUNCATE);
if (inputPlacement == &ToolbarPlacement) WriteString(xobrcFile, "xoblite.toolbar.placement:", outputString);
else if (inputPlacement == &DockPlacement) WriteString(xobrcFile, "xoblite.dock.placement:", outputString);
else if (inputPlacement == &ConsolePlacement) WriteString(xobrcFile, "xoblite.console.placement:", outputString);
else if (inputPlacement == &desktopClockPlacement) WriteString(xobrcFile, "xoblite.desktop.clock.placement:", outputString);
else if (inputPlacement == &desktopWeekdayPlacement) WriteString(xobrcFile, "xoblite.desktop.weekday.placement:", outputString);
else if (inputPlacement == &desktopDatePlacement) WriteString(xobrcFile, "xoblite.desktop.date.placement:", outputString);
else if (inputPlacement == &desktopGreetingPlacement) WriteString(xobrcFile, "xoblite.desktop.greeting.placement:", outputString);
}
void Settings::WriteStyle()
{
time_t systemTime;
struct tm localTime;
time(&systemTime);
localtime_s(&localTime, &systemTime);
char filename[MAX_PATH], path[MAX_PATH];
_locale_t timestampLocale = _create_locale(LC_TIME, "en-US");
_strftime_l(filename, MAX_PATH, "\\xDesigner_%Y_%m_%d_%H%M%S.style", &localTime, timestampLocale);
_free_locale(timestampLocale);
strcpy_s(path, sizeofArray(path), stylesFolder);
strcat_s(path, sizeofArray(path), filename);
if (FileExists(path)) return;
else
{
HANDLE file = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file)
{
char szTemp[MAX_LINE_LENGTH];
DWORD retLength = 0;
strcpy_s(szTemp, sizeofArray(szTemp), "! --------------------------------------------------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "style.name: <Auto-generated>\r\nstyle.author: <xoblite Designer mode>\r\nstyle.date: \r\nstyle.credits: \r\nstyle.comments: \r\nstyle.wallpaper: \r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "! ----------------------------- wallpaper ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
sprintf_s(szTemp, sizeofArray(szTemp), "rootCommand: %s\r\n\r\n", rootCommand);
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "! ------------------------------- toolbar ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
WriteStyleElement(file, Toolbar);
if (!ToolbarBorder->parentRelative) WriteStyleElement(file, ToolbarBorder);
WriteStyleElement(file, ToolbarLabel);
WriteStyleElement(file, ToolbarWindowLabel);
WriteStyleElement(file, ToolbarClock);
WriteStyleElement(file, ToolbarButton);
WriteStyleElement(file, ToolbarButtonPressed);
strcpy_s(szTemp, sizeofArray(szTemp), "! ---------------------------------- menu ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
WriteStyleElement(file, MenuTitle);
WriteStyleElement(file, MenuFrame);
if (!MenuFrameBorder->parentRelative) WriteStyleElement(file, MenuFrameBorder);
WriteStyleElement(file, MenuActive);
WriteStyleElement(file, MenuGrip);
WriteStyleElement(file, MenuIndicator);
WriteStyleElement(file, MenuSeparator);
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "menu.bullet: ");
switch (menuBullet)
{
case MENU_BULLET_TRIANGLE: { strcat_s(szTemp, sizeofArray(szTemp), "Triangle\r\n"); break; }
case MENU_BULLET_SQUARE: { strcat_s(szTemp, sizeofArray(szTemp), "Square\r\n"); break; }
case MENU_BULLET_DIAMOND: { strcat_s(szTemp, sizeofArray(szTemp), "Diamond\r\n"); break; }
case MENU_BULLET_CIRCLE: { strcat_s(szTemp, sizeofArray(szTemp), "Circle\r\n"); break; }
case MENU_BULLET_TRIPLE: { strcat_s(szTemp, sizeofArray(szTemp), "Triple\r\n"); break; }
case MENU_BULLET_COMMENT: { strcat_s(szTemp, sizeofArray(szTemp), "Comment\r\n"); break; }
case MENU_BULLET_GRID: { strcat_s(szTemp, sizeofArray(szTemp), "Grid\r\n"); break; }
case MENU_BULLET_QUAD: { strcat_s(szTemp, sizeofArray(szTemp), "Quad\r\n"); break; }
default: { strcat_s(szTemp, sizeofArray(szTemp), "Empty\r\n"); break; }
}
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
if (!_stricmp(menuBulletPosition, "right")) strcpy_s(szTemp, sizeofArray(szTemp), "menu.bullet.position: Right\r\n\r\n");
else strcpy_s(szTemp, sizeofArray(szTemp), "menu.bullet.position: Left\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "! ---------------------------------- dock ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
WriteStyleElement(file, Dock);
if (!DockBorder->parentRelative) WriteStyleElement(file, DockBorder);
strcpy_s(szTemp, sizeofArray(szTemp), "! ------------------------------- console ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
sprintf_s(szTemp, sizeofArray(szTemp), "console.color: #%02x%02x%02x\r\n", GetRValue(Console->Color), GetGValue(Console->Color), GetBValue(Console->Color));
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
sprintf_s(szTemp, sizeofArray(szTemp), "console.textColor: #%02x%02x%02x\r\n", GetRValue(Console->TextColor), GetGValue(Console->TextColor), GetBValue(Console->TextColor));
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
sprintf_s(szTemp, sizeofArray(szTemp), "console.buttonColor: #%02x%02x%02x\r\n", GetRValue(Console->PicColor), GetGValue(Console->PicColor), GetBValue(Console->PicColor));
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
if ((scalingFactorHiDPI > 1) && (Console->FontHeight > 0)) sprintf_s(szTemp, sizeofArray(szTemp), "console.font: %s/%d/", Console->Font, (Console->FontHeight / scalingFactorHiDPI));
else sprintf_s(szTemp, sizeofArray(szTemp), "console.font: %s/%d/", Console->Font, Console->FontHeight);
if (Console->FontWeight == FW_BOLD) strcat_s(szTemp, sizeofArray(szTemp), "Bold\r\n\r\n");
else strcat_s(szTemp, sizeofArray(szTemp), "Normal\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
strcpy_s(szTemp, sizeofArray(szTemp), "! -------------------------------- window ----------\r\n\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
WriteStyleElement(file, WindowTitleFocus);
WriteStyleElement(file, WindowTitleUnfocus);
WriteStyleElement(file, WindowLabelFocus);
WriteStyleElement(file, WindowLabelUnfocus);
WriteStyleElement(file, WindowButtonFocus);
WriteStyleElement(file, WindowButtonUnfocus);
WriteStyleElement(file, WindowButtonPressed);
WriteStyleElement(file, WindowGripFocus);
WriteStyleElement(file, WindowGripUnfocus);
WriteStyleElement(file, WindowHandleFocus);
WriteStyleElement(file, WindowHandleUnfocus);
strcpy_s(szTemp, sizeofArray(szTemp), "! --------------------------------------------------\r\n");
WriteFile(file, szTemp, strnlen_s(szTemp, sizeofArray(szTemp)), &retLength, NULL);
}
CloseHandle(file);
}
char msg[MAX_LINE_LENGTH];
sprintf_s(msg, sizeofArray(msg), "... style settings saved to %s .", path);
SendMessage(GetBBWnd(), BB_CONSOLEMESSAGE, (WPARAM)CONSOLE_REGULAR_MESSAGE, (LPARAM)msg);
}
void Settings::WriteStyleElement(HANDLE file, StyleItem* styleItem)
{
char styleElement[32], writeBuffer[MAX_LINE_LENGTH];
DWORD retLength = 0;
if (styleItem == Toolbar) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar");
else if (styleItem == ToolbarBorder) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.border");
else if (styleItem == ToolbarLabel) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.label");
else if (styleItem == ToolbarWindowLabel) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.windowLabel");
else if (styleItem == ToolbarClock) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.clock");
else if (styleItem == ToolbarButton) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.button");
else if (styleItem == ToolbarButtonPressed) strcpy_s(styleElement, sizeofArray(styleElement), "toolbar.button.pressed");
else if (styleItem == MenuTitle) strcpy_s(styleElement, sizeofArray(styleElement), "menu.title");
else if (styleItem == MenuFrame) strcpy_s(styleElement, sizeofArray(styleElement), "menu.frame");
else if (styleItem == MenuFrameBorder) strcpy_s(styleElement, sizeofArray(styleElement), "menu.frame.border");
else if (styleItem == MenuActive) strcpy_s(styleElement, sizeofArray(styleElement), "menu.active");
else if (styleItem == MenuGrip) strcpy_s(styleElement, sizeofArray(styleElement), "menu.grip");
else if (styleItem == MenuIndicator) strcpy_s(styleElement, sizeofArray(styleElement), "menu.indicator");
else if (styleItem == MenuSeparator) strcpy_s(styleElement, sizeofArray(styleElement), "menu.separator");
else if (styleItem == Dock) strcpy_s(styleElement, sizeofArray(styleElement), "dock");
else if (styleItem == DockBorder) strcpy_s(styleElement, sizeofArray(styleElement), "dock.border");
else if (styleItem == WindowTitleFocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.title.focus");
else if (styleItem == WindowTitleUnfocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.title.unfocus");
else if (styleItem == WindowLabelFocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.label.focus");
else if (styleItem == WindowLabelUnfocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.label.unfocus");
else if (styleItem == WindowButtonFocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.button.focus");
else if (styleItem == WindowButtonUnfocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.button.unfocus");
else if (styleItem == WindowButtonPressed) strcpy_s(styleElement, sizeofArray(styleElement), "window.button.pressed");
else if (styleItem == WindowGripFocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.grip.focus");
else if (styleItem == WindowGripUnfocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.grip.unfocus");
else if (styleItem == WindowHandleFocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.handle.focus");
else if (styleItem == WindowHandleUnfocus) strcpy_s(styleElement, sizeofArray(styleElement), "window.handle.unfocus");
else if (styleItem == ExternalHardware) strcpy_s(styleElement, sizeofArray(styleElement), "hardware");
else return;
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".appearance:");
if (styleItem->type == B_PARENTRELATIVE || styleItem->parentRelative) strcat_s(writeBuffer, sizeofArray(writeBuffer), " ParentRelative");
else
{
if ((styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) && (styleItem != ExternalHardware))
{
if (styleItem->bevelstyle == BEVEL_RAISED) strcat_s(writeBuffer, sizeofArray(writeBuffer), " Raised");
else if (styleItem->bevelstyle == BEVEL_SUNKEN) strcat_s(writeBuffer, sizeofArray(writeBuffer), " Sunken");
else strcat_s(writeBuffer, sizeofArray(writeBuffer), " Flat");
}
if (styleItem->type == B_SOLID) strcat_s(writeBuffer, sizeofArray(writeBuffer), " Solid");
else
{
if ((styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) && (styleItem != ExternalHardware))
{
strcat_s(writeBuffer, sizeofArray(writeBuffer), " Gradient");
}
switch (styleItem->type)
{
case B_HORIZONTAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Horizontal"); break; }
case B_VERTICAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Vertical"); break; }
case B_DIAGONAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Diagonal"); break; }
case B_CROSSDIAGONAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " CrossDiagonal"); break; }
case B_PIPECROSS: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Pipecross"); break; }
case B_ELLIPTIC: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Elliptic"); break; }
case B_RECTANGLE: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Rectangle"); break; }
case B_PYRAMID: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " Pyramid"); break; }
case B_MIRRORHORIZONTAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " MirrorHorizontal"); break; }
case B_MIRRORVERTICAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " MirrorVertical"); break; }
case B_SPLITSOLID: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " SplitSolid"); break; }
case B_SPLITHORIZONTAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " SplitHorizontal"); break; }
case B_SPLITVERTICAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " SplitVertical"); break; }
case B_SUPERHORIZONTAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " SuperHorizontal"); break; }
case B_SUPERVERTICAL: { strcat_s(writeBuffer, sizeofArray(writeBuffer), " SuperVertical"); break; }
default: break;
}
}
if ((styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) && (styleItem != ExternalHardware))
{
if (styleItem->bevelstyle != BEVEL_FLAT)
{
if (styleItem->bevelposition == BEVEL2) strcat_s(writeBuffer, sizeofArray(writeBuffer), " Bevel2");
else strcat_s(writeBuffer, sizeofArray(writeBuffer), " Bevel1");
}
if (styleItem->interlaced) strcat_s(writeBuffer, sizeofArray(writeBuffer), " Interlaced");
}
}
strcat_s(writeBuffer, sizeofArray(writeBuffer), "\r\n");
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
char colorString[10];
if (styleItem->type != B_PARENTRELATIVE && !styleItem->parentRelative)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
if (styleItem->type == B_SOLID) strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color:");
else strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color1:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color1), GetGValue(styleItem->Color1), GetBValue(styleItem->Color1));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->type != B_SOLID)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color2:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color2), GetGValue(styleItem->Color2), GetBValue(styleItem->Color2));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->type == B_SPLITHORIZONTAL || styleItem->type == B_SPLITVERTICAL || styleItem->type == B_SUPERHORIZONTAL || styleItem->type == B_SUPERVERTICAL)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color3:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color3), GetGValue(styleItem->Color3), GetBValue(styleItem->Color3));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color4:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color4), GetGValue(styleItem->Color4), GetBValue(styleItem->Color4));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->type == B_SUPERHORIZONTAL || styleItem->type == B_SUPERVERTICAL)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color5:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color5), GetGValue(styleItem->Color5), GetBValue(styleItem->Color5));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color6:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color6), GetGValue(styleItem->Color6), GetBValue(styleItem->Color6));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color7:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color7), GetGValue(styleItem->Color7), GetBValue(styleItem->Color7));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".color8:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->Color8), GetGValue(styleItem->Color8), GetBValue(styleItem->Color8));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
}
}
}
if ((styleItem != ToolbarButton) && (styleItem != ToolbarButtonPressed) && (styleItem != MenuActive) && (styleItem != MenuIndicator) && (styleItem != MenuSeparator) && (styleItem != Dock) &&
(styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) &&
(styleItem != WindowTitleFocus) && (styleItem != WindowButtonFocus) && (styleItem != WindowGripFocus) && (styleItem != WindowHandleFocus) && (styleItem != WindowButtonPressed) &&
(styleItem != WindowTitleUnfocus) && (styleItem != WindowButtonUnfocus) && (styleItem != WindowGripUnfocus) && (styleItem != WindowHandleUnfocus) &&
(styleItem != ExternalHardware))
{
if ((scalingFactorHiDPI > 1) && (styleItem->FontHeight > 0)) sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.font: %s/%d/", styleElement, styleItem->Font, (styleItem->FontHeight / scalingFactorHiDPI));
else sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.font: %s/%d/", styleElement, styleItem->Font, styleItem->FontHeight);
if (styleItem->FontWeight == FW_BOLD) strcat_s(writeBuffer, sizeofArray(writeBuffer), "Bold\r\n");
else strcat_s(writeBuffer, sizeofArray(writeBuffer), "Normal\r\n");
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".alignment: ");
if (styleItem->Justify == DT_LEFT) strcat_s(writeBuffer, sizeofArray(writeBuffer), "Left\r\n");
else if (styleItem->Justify == DT_RIGHT) strcat_s(writeBuffer, sizeofArray(writeBuffer), "Right\r\n");
else strcat_s(writeBuffer, sizeofArray(writeBuffer), "Center\r\n");
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
if ((styleItem != ToolbarButton) && (styleItem != ToolbarButtonPressed) && (styleItem != MenuIndicator) && (styleItem != MenuSeparator) && (styleItem != Dock) &&
(styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) &&
(styleItem != WindowTitleFocus) && (styleItem != WindowButtonFocus) && (styleItem != WindowGripFocus) && (styleItem != WindowHandleFocus) && (styleItem != WindowButtonPressed) &&
(styleItem != WindowTitleUnfocus) && (styleItem != WindowButtonUnfocus) && (styleItem != WindowGripUnfocus) && (styleItem != WindowHandleUnfocus) &&
(styleItem != ExternalHardware))
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".textColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->TextColor), GetGValue(styleItem->TextColor), GetBValue(styleItem->TextColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->FontOutline)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".outlineColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->OutlineColor), GetGValue(styleItem->OutlineColor), GetBValue(styleItem->OutlineColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
if (styleItem->FontShadow)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".shadowColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->ShadowColor), GetGValue(styleItem->ShadowColor), GetBValue(styleItem->ShadowColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
}
if (styleItem == MenuFrame)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".disabledColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->disabledColor), GetGValue(styleItem->disabledColor), GetBValue(styleItem->disabledColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
if ((styleItem == ToolbarButton) || (styleItem == ToolbarButtonPressed) || (styleItem == WindowButtonFocus) || (styleItem == WindowButtonUnfocus) || (styleItem == WindowButtonPressed))
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".picColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->PicColor), GetGValue(styleItem->PicColor), GetBValue(styleItem->PicColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
if ((styleItem == MenuFrame) || (styleItem == MenuActive))
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".bulletColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->BulletColor), GetGValue(styleItem->BulletColor), GetBValue(styleItem->BulletColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
if ((styleItem != MenuSeparator) && (styleItem != ToolbarBorder) && (styleItem != MenuFrameBorder) && (styleItem != DockBorder) && (styleItem != ExternalHardware))
{
if ((scalingFactorHiDPI > 1) && (styleItem->marginWidth > 0)) sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.marginWidth: %d\r\n", styleElement, (styleItem->marginWidth / scalingFactorHiDPI));
else sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.marginWidth: %d\r\n", styleElement, styleItem->marginWidth);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->type != B_PARENTRELATIVE && !styleItem->parentRelative)
{
if ((scalingFactorHiDPI > 1) && (styleItem->borderWidth > 0)) sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.borderWidth: %d\r\n", styleElement, (styleItem->borderWidth / scalingFactorHiDPI));
else sprintf_s(writeBuffer, sizeofArray(writeBuffer), "%s.borderWidth: %d\r\n", styleElement, styleItem->borderWidth);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
if (styleItem->borderWidth > 0)
{
strcpy_s(writeBuffer, sizeofArray(writeBuffer), styleElement);
strcat_s(writeBuffer, sizeofArray(writeBuffer), ".borderColor:");
sprintf_s(colorString, sizeofArray(colorString), " #%02x%02x%02x\r\n", GetRValue(styleItem->borderColor), GetGValue(styleItem->borderColor), GetBValue(styleItem->borderColor));
strcat_s(writeBuffer, sizeofArray(writeBuffer), colorString);
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}
}
}
strcpy_s(writeBuffer, sizeofArray(writeBuffer), "\r\n");
WriteFile(file, writeBuffer, strnlen_s(writeBuffer, sizeofArray(writeBuffer)), &retLength, NULL);
}