Patch level : 10.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@16763 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-06-16 09:01:21 +00:00
parent ada374ec6a
commit bc2ef579d7
2 changed files with 104 additions and 30 deletions

View File

@ -316,6 +316,8 @@ protected:
const char* cid2name(short cid) const; const char* cid2name(short cid) const;
COLOR cid2color(short cid) const; COLOR cid2color(short cid) const;
COLOR cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const; COLOR cid2syscolor(short cid, const XVT_COLOR_COMPONENT* cc) const;
void load_themes();
bool apply_theme();
public: public:
void save_colors(); void save_colors();
@ -404,15 +406,74 @@ TColor_mask::TPreview_icons::TPreview_icons(short x, short y, short dx, short dy
: _owner(owner) : _owner(owner)
{ create(x, y, dx, dy, "", 0, W_PLAIN, owner->page_win(1)); } { create(x, y, dx, dy, "", 0, W_PLAIN, owner->page_win(1)); }
bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) void TColor_mask::load_themes()
{ {
const short id = f.dlg(); TList_field& fl = lfield(211);
bool ok = true; TToken_string codes = fl.get_codes();
int k = codes.items();
switch (id) if (k <= 2)
{ {
case 211: TConfig themes("themes.ini");
if (e == fe_button) TString_array pl; themes.list_paragraphs(pl);
if (!pl.empty())
{
TToken_string values = fl.get_values();
FOR_EACH_ARRAY_ROW(pl, i, row)
{
codes.add(k++);
values.add(*row);
}
fl.replace_items(codes, values);
}
}
}
bool TColor_mask::apply_theme()
{
bool applied = false;
const int theme = get_int(211);
if (theme > 1)
{
TList_field& fl = lfield(211);
TToken_string codes = fl.get_codes();
TToken_string values = fl.get_values();
const int pos = codes.get_pos(theme);
TConfig themes("themes.ini", values.get(pos));
TAssoc_array& colors = themes.list_variables();
if (!colors.empty())
{
TToken_string rgb(15, ',');
FOR_EACH_ASSOC_STRING(colors, obj, key, value)
{
rgb = value;
const byte r = (byte)rgb.get_int(0);
const byte g = (byte)rgb.get_int();
const byte b = (byte)rgb.get_int();
set_color_entry(key, XVT_MAKE_COLOR(r,g,b));
}
applied = true;
}
}
if (!applied)
{
switch (theme)
{
case 1: // System colors
{
XVT_COLOR_COMPONENT* cc = (XVT_COLOR_COMPONENT*)xvt_vobj_get_attr(NULL_WIN, ATTR_APP_CTL_COLORS);
for (short bid = 101; bid <= 113; bid++)
{
const char* name = cid2name(bid);
const COLOR color = cid2syscolor(bid, cc);
set_color_entry(name, color);
}
xvt_mem_free((DATA_PTR)cc);
applied = true;
}
break;
default: // Default colors
{ {
for (short bid = 101; bid <= 113; bid++) for (short bid = 101; bid <= 113; bid++)
{ {
@ -423,22 +484,32 @@ bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
TConfig font(CONFIG_GUI, "Font"); TConfig font(CONFIG_GUI, "Font");
font.set("FontDesc", ""); // Azzera font e lo ricarica alla prossima font.set("FontDesc", ""); // Azzera font e lo ricarica alla prossima
xvt_load_default_font(); xvt_load_default_font();
update(); applied = true;
} }
break; break;
}
}
if (applied)
_preview->force_update();
return applied;
}
bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
const short id = f.dlg();
bool ok = true;
switch (id)
{
case 211:
if (e == fe_init)
load_themes();
break;
case 212: case 212:
if (e == fe_button) if (e == fe_button)
{ apply_theme();
XVT_COLOR_COMPONENT* cc = (XVT_COLOR_COMPONENT*)xvt_vobj_get_attr(NULL_WIN, ATTR_APP_CTL_COLORS);
for (short bid = 101; bid <= 113; bid++)
{
const char* name = cid2name(bid);
const COLOR color = cid2syscolor(bid, cc);
set_color_entry(name, color);
}
xvt_mem_free((DATA_PTR)cc);
update();
}
break; break;
case 217: case 217:
if (e == fe_init || e == fe_modify) if (e == fe_init || e == fe_modify)
@ -490,7 +561,7 @@ TColor_mask::TColor_mask()
set(215, ADVANCED_GRAPHICS ? "X" : ""); set(215, ADVANCED_GRAPHICS ? "X" : "");
set(216, color.get_int("TreeView")); set(216, color.get_int("TreeView"));
_preview = new TPreview_panel(1, 5, 33, 8, this); _preview = new TPreview_panel(1, 8, 33, 8, this);
_icons = new TPreview_icons(1, 10, -2, -2, this); _icons = new TPreview_icons(1, 10, -2, -2, this);
const int sz = color.get_int("ToolSize"); const int sz = color.get_int("ToolSize");
@ -513,6 +584,7 @@ void TColor_mask::save_colors()
TConfig colors(CONFIG_GUI, "Colors"); TConfig colors(CONFIG_GUI, "Colors");
FOR_EACH_ASSOC_STRING(_color, obj, key, str) FOR_EACH_ASSOC_STRING(_color, obj, key, str)
colors.set(key, str); colors.set(key, str);
colors.set("Campi3D", get_bool(213) ? "X" : ""); colors.set("Campi3D", get_bool(213) ? "X" : "");
colors.set("NativeControls", get_bool(214) ? "X" : ""); colors.set("NativeControls", get_bool(214) ? "X" : "");
colors.set("AdvancedGraphics", get_bool(215) ? "X" : ""); colors.set("AdvancedGraphics", get_bool(215) ? "X" : "");

View File

@ -92,17 +92,19 @@ END
GROUPBOX DLG_NULL 32 3 GROUPBOX DLG_NULL 32 3
BEGIN BEGIN
PROMPT 1 14 "@bTemi predefiniti" PROMPT 1 5 "@bTemi predefiniti"
END END
BUTTON 211 12 LISTBOX 211 1 12
BEGIN BEGIN
PROMPT 2 15 "Campo" PROMPT 2 6 "Tema "
ITEM "0|Campo"
ITEM "1|Sistema"
END END
BUTTON 212 12 BUTTON 212 8 1
BEGIN BEGIN
PROMPT 18 15 "Sistema" PROMPT 22 6 "Applica"
END END
BUTTON DLG_USER 12 2 BUTTON DLG_USER 12 2