Пример #1
0
static bool ParseCompound(const char* s, size_t len, bool (*parseFunc)(const char* s, size_t len, T& t), StyleCategories cat, Style& style) {
	T val;
	if (parseFunc(s, len, val)) {
		style.Set(cat, val);
		return true;
	} else {
		ParseFail("Parse failed, unknown value: '%.*s'\n", (int) len, s);
		return false;
	}
}
Пример #2
0
void SetMainWndBgCol(EbookControls *ctrls)
{
    COLORREF bgColor = gGlobalPrefs->ebookUI.backgroundColor;
    if (gGlobalPrefs->useSysColors)
        bgColor = GetSysColor(COLOR_WINDOW);

    Style *styleMainWnd = StyleByName("styleMainWnd");
    CrashIf(!styleMainWnd);
    styleMainWnd->Set(Prop::AllocColorSolid(PropBgColor, GetRValueSafe(bgColor), GetGValueSafe(bgColor), GetBValueSafe(bgColor)));
    ctrls->mainWnd->SetStyle(styleMainWnd);

    Style *styleStatus = StyleByName("styleStatus");
    styleStatus->Set(Prop::AllocColorSolid(PropBgColor, GetRValueSafe(bgColor), GetGValueSafe(bgColor), GetBValueSafe(bgColor)));
    ctrls->status->SetStyle(styleStatus);

    // TODO: should also allow to change text color
    // TODO: also match the colors of progress bar to be based on background color

    // note: callers are expected to update the background of tree control and 
    // other colors that are supposed to match background color
}
Пример #3
0
// This was added when font-family was stored as a string, but it is now stored as a FontID
static void ParseString(const char* s, size_t len, StyleCategories cat, Doc* doc, Style& style) {
	char        stat[64];
	StyleAttrib attrib;
	if (len < sizeof(stat)) {
		memcpy(stat, s, len);
		stat[len] = 0;
		attrib.Set(cat, stat, doc);
	} else {
		String copy;
		copy.Set(s, len);
		attrib.Set(cat, copy.Z, doc);
	}
	style.Set(attrib);
}
Пример #4
0
static bool ParseBool(const char* s, size_t len, StyleCategories cat, Style& style) {
	bool val;
	if (len == 4 && s[0] == 't')
		val = true;
	else if (len == 5 && s[0] == 'f')
		val = false;
	else {
		ParseFail("Parse failed, illegal boolean value: '%.*s'. Valid values are 'true' and 'false'.\n", (int) len, s);
		return false;
	}
	StyleAttrib attrib;
	attrib.SetBool(cat, val);
	style.Set(attrib);
	return true;
}