mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
bazaar: Styler refactoring
git-svn-id: svn://ultimatepp.org/upp/trunk@5469 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
976f6c81f1
commit
412d1594e3
7 changed files with 337 additions and 318 deletions
|
|
@ -25,7 +25,7 @@ public:
|
|||
DEEP = 0x80,
|
||||
|
||||
DEF = VISIBLE | INVISIBLE | ENABLED | DISABLED | VIEW | FRAME | DEEP,
|
||||
};
|
||||
} FLAGS;
|
||||
|
||||
CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)), multi(true) { WantFocus(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _Gen_Misc_h_
|
||||
#define _Gen_Misc_h_
|
||||
|
||||
#include <Core/Core.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
//some usefull interfaces
|
||||
|
|
@ -38,8 +40,8 @@ public:
|
|||
virtual ~GetSetData() {} //might be used as base interface
|
||||
virtual T GetData() const = 0;
|
||||
virtual void SetData(const T& _v) = 0;
|
||||
virtual T& GetRef() = 0;
|
||||
virtual const T& GetRef() const = 0;
|
||||
// virtual T& GetRef() { NEVER(); Value v; return v; }
|
||||
// virtual const T& GetRef() const { NEVER(); Value v; return v; }
|
||||
T operator~() const { return GetData(); }
|
||||
const T& operator<<=(const T& v) { SetData(v); return v; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
#define IMAGEFILE <Styler/StylerCtrls.iml>
|
||||
#include <Draw/iml_source.h>
|
||||
|
||||
Color Invert(const Color& c)
|
||||
{
|
||||
return Color(255-c.GetR(), 255-c.GetG(),255-c.GetB());
|
||||
}
|
||||
|
||||
void ColorizeIml(Iml& target, Iml& source, const Color& c, int alpha)
|
||||
{
|
||||
for(int i = 0; i < target.GetCount(); i++) {
|
||||
|
|
@ -33,18 +38,18 @@ void ChStylerSkin(const Color& c, int blnd, const Color& fg, const Color& bg)
|
|||
ColorizeIml(CtrlsImg::Iml(), StylerCtrlsImg::Iml(), c, 255);
|
||||
|
||||
|
||||
SColorFace_Write(Blend(c, fg, blnd)); //controls face color
|
||||
SColorShadow_Write(Blend(c, bg, blnd));
|
||||
SColorLtFace_Write(Blend(c, fg, blnd+20));
|
||||
SColorDkShadow_Write(Blend(c, bg, blnd+20));
|
||||
SColorFace_Write(Blend(c, fg, min(255, blnd))); //controls face color
|
||||
SColorShadow_Write(Blend(c, bg, min(255, blnd)));
|
||||
SColorLtFace_Write(Blend(c, fg, min(255, blnd+20)));
|
||||
SColorDkShadow_Write(Blend(c, bg, min(255, blnd+20)));
|
||||
|
||||
SColorHighlight_Write(Blend(fg, c, blnd+20));
|
||||
SColorDisabled_Write(Blend(bg, c, blnd+20));
|
||||
SColorHighlight_Write(Blend(fg, c, min(255, blnd+20)));
|
||||
SColorDisabled_Write(Blend(bg, c, min(255, blnd+20)));
|
||||
|
||||
SColorPaper_Write(Blend(c, fg, blnd+40)); //for lists, edits etc..
|
||||
SColorText_Write(Blend(c, bg, blnd+40));
|
||||
SColorPaper_Write(Blend(c, fg, min(255, blnd+40))); //for lists, edits etc..
|
||||
SColorText_Write(Blend(c, bg, min(255, blnd+40)));
|
||||
|
||||
SColorHighlightText_Write(Blend(c, fg, blnd+60));
|
||||
SColorHighlightText_Write(Blend(c, fg, min(255, blnd+60)));
|
||||
|
||||
SColorLight_Write(SColorHighlight());
|
||||
|
||||
|
|
@ -59,229 +64,7 @@ void ChStylerSkin(const Color& c, int blnd, const Color& fg, const Color& bg)
|
|||
LabelBoxColor_Write(SColorHighlight());
|
||||
}
|
||||
|
||||
void StylerCtrl::ColorizedSkin()
|
||||
{
|
||||
Color c = ~mcl;
|
||||
int blnd = ~bl;
|
||||
Color fg = ~fgcl;
|
||||
Color bg = ~bgcl;
|
||||
|
||||
if(Grayscale(fg)<Grayscale(bg))
|
||||
{
|
||||
dk <<= true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dk <<= false;
|
||||
}
|
||||
|
||||
ChStylerSkin(c, blnd, fg, bg);
|
||||
}
|
||||
|
||||
void StylerCtrl::SkinAction()
|
||||
{
|
||||
if((int)stsw.GetData() != 2)
|
||||
{
|
||||
mcl.Disable();
|
||||
fgcl.Disable();
|
||||
bgcl.Disable();
|
||||
bl.Disable();
|
||||
inv.Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
mcl.Enable();
|
||||
fgcl.Enable();
|
||||
bgcl.Enable();
|
||||
bl.Enable();
|
||||
inv.Enable();
|
||||
}
|
||||
|
||||
//reset
|
||||
switch((int)stsw.GetData())
|
||||
{
|
||||
case 1: ChStdSkin(); break;
|
||||
case 2: ColorizedSkin(); break;
|
||||
default:
|
||||
case 0: ChClassicSkin(); break;
|
||||
}
|
||||
|
||||
RefreshGlobalStyles();
|
||||
RefreshLayoutDeepAll();
|
||||
UpdateAction();
|
||||
}
|
||||
|
||||
Color Invert(const Color& c)
|
||||
{
|
||||
return Color(255-c.GetR(), 255-c.GetG(),255-c.GetB());
|
||||
}
|
||||
|
||||
void StylerCtrl::InvertAction()
|
||||
{
|
||||
Color c = ~mcl;
|
||||
Color fg = ~fgcl;
|
||||
Color bg = ~bgcl;
|
||||
|
||||
fg = Invert(fg);
|
||||
bg = Invert(bg);
|
||||
c = Invert(c);
|
||||
|
||||
fgcl <<= fg;
|
||||
bgcl <<= bg;
|
||||
mcl <<= c;
|
||||
|
||||
SkinAction();
|
||||
}
|
||||
|
||||
void StylerCtrl::Updated()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
StylerCtrl::StylerCtrl()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
|
||||
dk.SetReadOnly();
|
||||
|
||||
stsw <<= 2;
|
||||
stsw <<= THISBACK(SkinAction);
|
||||
|
||||
mcl <<= Gray();
|
||||
mcl <<= THISBACK(SkinAction);
|
||||
|
||||
fgcl <<= White();
|
||||
fgcl <<= THISBACK(SkinAction);
|
||||
|
||||
bgcl <<= Black();
|
||||
bgcl <<= THISBACK(SkinAction);
|
||||
|
||||
|
||||
bl.MinMax(0,255);
|
||||
bl <<= 192;
|
||||
bl <<= THISBACK(SkinAction);
|
||||
|
||||
inv <<= THISBACK(InvertAction);
|
||||
|
||||
SkinAction();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void ChamStyleCtrl::Updated()
|
||||
{
|
||||
clface <<= SColorFace();
|
||||
clshadow <<= SColorShadow();
|
||||
clltface <<= SColorLtFace();
|
||||
cldkshadow <<= SColorDkShadow();
|
||||
clhighlight <<= SColorHighlight();
|
||||
cldisabled <<= SColorDisabled();
|
||||
clpaper <<= SColorPaper();
|
||||
cltext <<= SColorText();
|
||||
clhighlighttext <<= SColorHighlightText();
|
||||
cllight <<= SColorLight();
|
||||
|
||||
clmenu <<= SColorMenu();
|
||||
clmenutext <<= SColorMenuText();
|
||||
clmenumark <<= SColorMenuMark();
|
||||
clinfo <<= SColorInfo();
|
||||
clinfotext <<= SColorInfoText();
|
||||
clmark <<= SColorMark();
|
||||
cllabel <<= SColorLabel();
|
||||
cllbtext <<= LabelBoxTextColor();
|
||||
cllb <<= LabelBoxColor();
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::ColorAction()
|
||||
{
|
||||
ChReset();
|
||||
|
||||
SColorFace_Write(~clface);
|
||||
SColorShadow_Write(~clshadow);
|
||||
SColorLtFace_Write(~clltface);
|
||||
SColorDkShadow_Write(~cldkshadow);
|
||||
SColorHighlight_Write(~clhighlight);
|
||||
SColorDisabled_Write(~cldisabled);
|
||||
SColorPaper_Write(~clpaper);
|
||||
SColorText_Write(~cltext);
|
||||
SColorHighlightText_Write(~clhighlighttext);
|
||||
SColorLight_Write(~cllight);
|
||||
|
||||
SColorMenu_Write(~clmenu);
|
||||
SColorMenuText_Write(~clmenutext);
|
||||
SColorMenuMark_Write(~clmenumark);
|
||||
SColorInfo_Write(~clinfo);
|
||||
SColorInfoText_Write(~clinfotext);
|
||||
SColorMark_Write(~clmark);
|
||||
SColorLabel_Write(~cllabel);
|
||||
LabelBoxTextColor_Write(~cllbtext);
|
||||
LabelBoxColor_Write(~cllb);
|
||||
|
||||
RefreshGlobalStyles();
|
||||
RefreshLayoutDeepAll();
|
||||
Action();
|
||||
}
|
||||
|
||||
ChamStyleCtrl::ChamStyleCtrl()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
load <<= THISBACK(LoadCB);
|
||||
save <<= THISBACK(SaveCB);
|
||||
|
||||
clface <<= THISBACK(ColorAction);
|
||||
clshadow <<= THISBACK(ColorAction);
|
||||
clltface <<= THISBACK(ColorAction);
|
||||
cldkshadow <<= THISBACK(ColorAction);
|
||||
clhighlight <<= THISBACK(ColorAction);
|
||||
cldisabled <<= THISBACK(ColorAction);
|
||||
clpaper <<= THISBACK(ColorAction);
|
||||
cltext <<= THISBACK(ColorAction);
|
||||
clhighlighttext <<= THISBACK(ColorAction);
|
||||
cllight <<= THISBACK(ColorAction);
|
||||
|
||||
clmenu <<= THISBACK(ColorAction);
|
||||
clmenutext <<= THISBACK(ColorAction);
|
||||
clmenumark <<= THISBACK(ColorAction);
|
||||
clinfo <<= THISBACK(ColorAction);
|
||||
clinfotext <<= THISBACK(ColorAction);
|
||||
clmark <<= THISBACK(ColorAction);
|
||||
cllabel <<= THISBACK(ColorAction);
|
||||
cllbtext <<= THISBACK(ColorAction);
|
||||
cllb <<= THISBACK(ColorAction);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::SaveCB()
|
||||
{
|
||||
FileSel fs;
|
||||
if(!fs.ExecuteSaveAs("Save global colors")) return;
|
||||
|
||||
PerChStyle d;
|
||||
StoreAsXMLFile(d, "style", fs.Get());
|
||||
|
||||
//StoreToFile(d, fs.Get());
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::LoadCB()
|
||||
{
|
||||
FileSel fs;
|
||||
if(!fs.ExecuteOpen("Save global colors")) return;
|
||||
|
||||
ChReset();
|
||||
|
||||
PerChStyle d;
|
||||
LoadFromXMLFile(d, fs.Get());
|
||||
//LoadFromFile(d, fs.Get());
|
||||
|
||||
Update();
|
||||
RefreshGlobalStyles();
|
||||
RefreshLayoutDeepAll();
|
||||
Action();
|
||||
}
|
||||
|
||||
//
|
||||
void XmlizeCol(XmlIO xml, const String& tag, Color& c)
|
||||
void XmlizeCol(XmlIO& xml, const String& tag, Color& c)
|
||||
{
|
||||
if(xml.IsStoring())
|
||||
{
|
||||
|
|
@ -290,21 +73,10 @@ void XmlizeCol(XmlIO xml, const String& tag, Color& c)
|
|||
if(xml.IsLoading())
|
||||
{
|
||||
int i = xml->FindTag(tag);
|
||||
if(i>=0) { ::Xmlize(xml.At(i), c); }
|
||||
if(i>=0) { XmlIO _ = xml.At(i); ::Xmlize(_, c); }
|
||||
}
|
||||
}
|
||||
|
||||
#define XMLIZECOL(TAG, SCOL) \
|
||||
if(xml.IsStoring()) \
|
||||
XmlizeCol(xml, TAG, c = SCOL()); \
|
||||
if(xml.IsLoading()) \
|
||||
{ \
|
||||
c = Null; \
|
||||
XmlizeCol(xml, TAG, c); if(!c.IsNullInstance()) COMBINE(SCOL, _Write)(c); \
|
||||
} \
|
||||
\
|
||||
|
||||
|
||||
NAMESPACE_UPP
|
||||
template<> Stream& operator%(Stream& s, PerChStyle& o)
|
||||
{
|
||||
|
|
@ -363,7 +135,17 @@ template<> Stream& operator%(Stream& s, PerChStyle& o)
|
|||
return s;
|
||||
}
|
||||
|
||||
template<> void Xmlize(XmlIO xml, PerChStyle& o)
|
||||
#define XMLIZECOL(TAG, SCOL) \
|
||||
if(xml.IsStoring()) \
|
||||
XmlizeCol(xml, TAG, c = SCOL()); \
|
||||
if(xml.IsLoading()) \
|
||||
{ \
|
||||
c = Null; \
|
||||
XmlizeCol(xml, TAG, c); if(!c.IsNullInstance()) COMBINE(SCOL, _Write)(c); \
|
||||
} \
|
||||
|
||||
|
||||
template<> void Xmlize(XmlIO& xml, PerChStyle& o)
|
||||
{
|
||||
Color c;
|
||||
|
||||
|
|
@ -389,3 +171,228 @@ template<> void Xmlize(XmlIO xml, PerChStyle& o)
|
|||
XMLIZECOL("labelbox", LabelBoxColor)
|
||||
}
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
bool SaveGlobalStyle(const String& filename)
|
||||
{
|
||||
PerChStyle d;
|
||||
return StoreAsXMLFile(d, "style", filename);
|
||||
//return StoreToFile(d, fs.Get());
|
||||
}
|
||||
|
||||
bool LoadGlobalStyle(const String& filename)
|
||||
{
|
||||
ChReset();
|
||||
|
||||
PerChStyle d;
|
||||
bool b = LoadFromXMLFile(d, filename);
|
||||
//b = LoadFromFile(d, filename);
|
||||
|
||||
if(!b) return b;
|
||||
|
||||
RefreshGlobalStyles();
|
||||
RefreshLayoutDeepAll();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
//ChamStyleCtrl
|
||||
|
||||
void ChamStyleCtrl::Updated()
|
||||
{
|
||||
clface <<= SColorFace();
|
||||
clshadow <<= SColorShadow();
|
||||
clltface <<= SColorLtFace();
|
||||
cldkshadow <<= SColorDkShadow();
|
||||
clhighlight <<= SColorHighlight();
|
||||
cldisabled <<= SColorDisabled();
|
||||
clpaper <<= SColorPaper();
|
||||
cltext <<= SColorText();
|
||||
clhighlighttext <<= SColorHighlightText();
|
||||
cllight <<= SColorLight();
|
||||
|
||||
clmenu <<= SColorMenu();
|
||||
clmenutext <<= SColorMenuText();
|
||||
clmenumark <<= SColorMenuMark();
|
||||
clinfo <<= SColorInfo();
|
||||
clinfotext <<= SColorInfoText();
|
||||
clmark <<= SColorMark();
|
||||
cllabel <<= SColorLabel();
|
||||
cllbtext <<= LabelBoxTextColor();
|
||||
cllb <<= LabelBoxColor();
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::OnColorAction()
|
||||
{
|
||||
ChReset();
|
||||
|
||||
SColorFace_Write(~clface);
|
||||
SColorShadow_Write(~clshadow);
|
||||
SColorLtFace_Write(~clltface);
|
||||
SColorDkShadow_Write(~cldkshadow);
|
||||
SColorHighlight_Write(~clhighlight);
|
||||
SColorDisabled_Write(~cldisabled);
|
||||
SColorPaper_Write(~clpaper);
|
||||
SColorText_Write(~cltext);
|
||||
SColorHighlightText_Write(~clhighlighttext);
|
||||
SColorLight_Write(~cllight);
|
||||
|
||||
SColorMenu_Write(~clmenu);
|
||||
SColorMenuText_Write(~clmenutext);
|
||||
SColorMenuMark_Write(~clmenumark);
|
||||
SColorInfo_Write(~clinfo);
|
||||
SColorInfoText_Write(~clinfotext);
|
||||
SColorMark_Write(~clmark);
|
||||
SColorLabel_Write(~cllabel);
|
||||
LabelBoxTextColor_Write(~cllbtext);
|
||||
LabelBoxColor_Write(~cllb);
|
||||
|
||||
RefreshGlobalStyles();
|
||||
WhenSColorsChange(); //let outside apply own changes after recalculation, before we apply them
|
||||
RefreshLayoutDeepAll();
|
||||
|
||||
Action();
|
||||
}
|
||||
|
||||
ChamStyleCtrl::ChamStyleCtrl()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
|
||||
clface <<= THISBACK(OnColorAction);
|
||||
clshadow <<= THISBACK(OnColorAction);
|
||||
clltface <<= THISBACK(OnColorAction);
|
||||
cldkshadow <<= THISBACK(OnColorAction);
|
||||
clhighlight <<= THISBACK(OnColorAction);
|
||||
cldisabled <<= THISBACK(OnColorAction);
|
||||
clpaper <<= THISBACK(OnColorAction);
|
||||
cltext <<= THISBACK(OnColorAction);
|
||||
clhighlighttext <<= THISBACK(OnColorAction);
|
||||
cllight <<= THISBACK(OnColorAction);
|
||||
|
||||
clmenu <<= THISBACK(OnColorAction);
|
||||
clmenutext <<= THISBACK(OnColorAction);
|
||||
clmenumark <<= THISBACK(OnColorAction);
|
||||
clinfo <<= THISBACK(OnColorAction);
|
||||
clinfotext <<= THISBACK(OnColorAction);
|
||||
clmark <<= THISBACK(OnColorAction);
|
||||
cllabel <<= THISBACK(OnColorAction);
|
||||
cllbtext <<= THISBACK(OnColorAction);
|
||||
cllb <<= THISBACK(OnColorAction);
|
||||
|
||||
load <<= THISBACK(DoLoad);
|
||||
save <<= THISBACK(DoSave);
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::DoSave()
|
||||
{
|
||||
FileSel fs;
|
||||
if(!fs.ExecuteSaveAs("Save global colors")) return;
|
||||
SaveGlobalStyle(fs.Get());
|
||||
}
|
||||
|
||||
void ChamStyleCtrl::DoLoad()
|
||||
{
|
||||
FileSel fs;
|
||||
if(!fs.ExecuteOpen("Save global colors")) return;
|
||||
LoadGlobalStyle(fs.Get());
|
||||
Update();
|
||||
}
|
||||
|
||||
//StylerCtrl
|
||||
|
||||
void StylerCtrl::SetColorizedSkin()
|
||||
{
|
||||
Color c = ~mcl;
|
||||
int blnd = ~bl;
|
||||
Color fg = ~fgcl;
|
||||
Color bg = ~bgcl;
|
||||
|
||||
ChStylerSkin(c, blnd, fg, bg);
|
||||
}
|
||||
|
||||
void StylerCtrl::OnSkinAction()
|
||||
{
|
||||
if((int)stsw.GetData() != 2)
|
||||
{
|
||||
mcl.Disable();
|
||||
fgcl.Disable();
|
||||
bgcl.Disable();
|
||||
bl.Disable();
|
||||
inv.Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
mcl.Enable();
|
||||
fgcl.Enable();
|
||||
bgcl.Enable();
|
||||
bl.Enable();
|
||||
inv.Enable();
|
||||
}
|
||||
|
||||
//reset
|
||||
switch((int)stsw.GetData())
|
||||
{
|
||||
case 1: ChStdSkin(); break;
|
||||
case 2: SetColorizedSkin(); break;
|
||||
default:
|
||||
case 0: ChClassicSkin(); break;
|
||||
}
|
||||
|
||||
RefreshGlobalStyles();
|
||||
WhenSkinChange(); //let outside apply own changes after recalculation, before we apply them
|
||||
RefreshLayoutDeepAll();
|
||||
|
||||
UpdateAction();
|
||||
}
|
||||
|
||||
void StylerCtrl::OnInvertAction()
|
||||
{
|
||||
Color c = ~mcl;
|
||||
Color fg = ~fgcl;
|
||||
Color bg = ~bgcl;
|
||||
|
||||
fg = Invert(fg);
|
||||
bg = Invert(bg);
|
||||
c = Invert(c);
|
||||
|
||||
fgcl <<= fg;
|
||||
bgcl <<= bg;
|
||||
mcl <<= c;
|
||||
|
||||
OnSkinAction();
|
||||
}
|
||||
|
||||
void StylerCtrl::Updated()
|
||||
{
|
||||
Color fg = ~fgcl;
|
||||
Color bg = ~bgcl;
|
||||
|
||||
dk <<= bool(Grayscale(fg)<Grayscale(bg));
|
||||
}
|
||||
|
||||
StylerCtrl::StylerCtrl()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
|
||||
dk.SetReadOnly();
|
||||
|
||||
stsw <<= 2; //ColorizedSkin
|
||||
stsw <<= THISBACK(OnSkinAction);
|
||||
|
||||
mcl <<= Gray();
|
||||
mcl <<= THISBACK(OnSkinAction);
|
||||
|
||||
fgcl <<= White();
|
||||
fgcl <<= THISBACK(OnSkinAction);
|
||||
|
||||
bgcl <<= Black();
|
||||
bgcl <<= THISBACK(OnSkinAction);
|
||||
|
||||
|
||||
bl.MinMax(0,255);
|
||||
bl <<= 192;
|
||||
bl <<= THISBACK(OnSkinAction);
|
||||
|
||||
inv <<= THISBACK(OnInvertAction);
|
||||
|
||||
//SkinAction(); //try our setup
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,42 +2,82 @@
|
|||
#define _Styler_Styler_h
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct PerChStyle : ChStyle<PerChStyle>
|
||||
{
|
||||
//dummy for saving the current status
|
||||
};
|
||||
|
||||
NAMESPACE_UPP
|
||||
template<> Stream& operator%(Stream& s, PerChStyle& o);
|
||||
template<> void Xmlize(XmlIO xml, PerChStyle& o);
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#define IMAGECLASS StylerCtrlsImg
|
||||
#define IMAGEFILE <Styler/StylerCtrls.iml>
|
||||
#include <Draw/iml_header.h>
|
||||
|
||||
#define LAYOUTFILE <Styler/Styler.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
Color Invert(const Color& c);
|
||||
|
||||
void ColorizeIml(Iml& target, Iml& source, const Color& c, int alpha = 100);
|
||||
void RefreshGlobalStyles();
|
||||
void RefreshLayoutDeepAll();
|
||||
|
||||
#define LAYOUTFILE <Styler/Styler.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
void ChStylerSkin(const Color& c, int blnd, const Color& fg, const Color& bg);
|
||||
|
||||
void XmlizeCol(XmlIO& xml, const String& tag, Color& c);
|
||||
|
||||
//dummy for saving the global status
|
||||
struct PerChStyle : ChStyle<PerChStyle> {};
|
||||
|
||||
NAMESPACE_UPP
|
||||
template<> Stream& operator%(Stream& s, PerChStyle& o);
|
||||
template<> void Xmlize(XmlIO& xml, PerChStyle& o);
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
bool SaveGlobalStyle(const String& filename);
|
||||
bool LoadGlobalStyle(const String& filename);
|
||||
|
||||
//for manipulating the SColors
|
||||
class ChamStyleCtrl : public WithChamStyleLay<ParentCtrl> {
|
||||
public:
|
||||
typedef ChamStyleCtrl CLASSNAME;
|
||||
ChamStyleCtrl();
|
||||
|
||||
virtual void Updated();
|
||||
|
||||
void DoLoad();
|
||||
void DoSave();
|
||||
|
||||
void OnColorAction();
|
||||
|
||||
Callback WhenSColorsChange;
|
||||
};
|
||||
|
||||
class StylerCtrl : public WithStylerLay<ParentCtrl> {
|
||||
public:
|
||||
typedef StylerCtrl CLASSNAME;
|
||||
StylerCtrl();
|
||||
|
||||
virtual void Updated();
|
||||
|
||||
void OnSkinAction();
|
||||
void OnInvertAction();
|
||||
|
||||
Callback WhenSkinChange;
|
||||
|
||||
protected:
|
||||
void SetColorizedSkin();
|
||||
};
|
||||
|
||||
|
||||
//overriding CH_STYLE definitions for a class:: StyleFunction by own definitions, which are not bound to the namespace
|
||||
#define CH_LOCSTYLE(klass, type, style) \
|
||||
struct COMBINE5(klass, __, type, __, style) : klass::type { \
|
||||
void Init(); \
|
||||
static void InitIt(); \
|
||||
}; \
|
||||
\
|
||||
const klass::Style& style(); \
|
||||
const klass::type& style(); \
|
||||
void COMBINE5(klass, __, type, __, style)::InitIt() { \
|
||||
style(); \
|
||||
} \
|
||||
\
|
||||
const klass::Style& style() \
|
||||
const klass::type& style() \
|
||||
{ \
|
||||
static COMBINE5(klass, __, type, __, style) b, standard; \
|
||||
if(b.status == 0) { \
|
||||
|
|
@ -52,39 +92,5 @@ const klass::Style& style() \
|
|||
\
|
||||
void COMBINE5(klass, __, type, __, style)::Init()
|
||||
|
||||
void XmlizeCol(XmlIO xml, const String& tag, Color& c);
|
||||
|
||||
void RefreshGlobalStyles();
|
||||
void RefreshLayoutDeepAll();
|
||||
|
||||
void ChStylerSkin(const Color& c, int blnd, const Color& fg, const Color& bg);
|
||||
|
||||
class StylerCtrl : public WithStylerLay<ParentCtrl> {
|
||||
public:
|
||||
typedef StylerCtrl CLASSNAME;
|
||||
StylerCtrl();
|
||||
|
||||
virtual void Updated();
|
||||
|
||||
void SkinAction();
|
||||
void InvertAction();
|
||||
|
||||
protected:
|
||||
void ColorizedSkin();
|
||||
};
|
||||
|
||||
class ChamStyleCtrl : public WithChamStyleLay<ParentCtrl> {
|
||||
public:
|
||||
typedef ChamStyleCtrl CLASSNAME;
|
||||
ChamStyleCtrl();
|
||||
|
||||
virtual void Updated();
|
||||
|
||||
void LoadCB();
|
||||
void SaveCB();
|
||||
|
||||
void ColorAction();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ LAYOUT(StylerLay, 160, 116)
|
|||
ITEM(ColorPusher, fgcl, LeftPosZ(48, 28).TopPosZ(24, 20))
|
||||
ITEM(ColorPusher, bgcl, LeftPosZ(48, 28).TopPosZ(44, 20))
|
||||
ITEM(Switch, stsw, SetLabel(t_("ClassicSkin\nStdSkin\nStylerSkin")).RightPosZ(4, 76).TopPosZ(4, 60))
|
||||
ITEM(Option, inv, SetLabel(t_("inverted")).RightPosZ(4, 76).VSizePosZ(68, 32))
|
||||
ITEM(Button, inv, SetLabel(t_("Invert")).RightPosZ(4, 76).VSizePosZ(68, 32))
|
||||
ITEM(SliderCtrl, bl, HSizePosZ(4, 4).BottomPosZ(4, 24))
|
||||
ITEM(StaticText, dv___6, SetText(t_("main:")).LeftPosZ(4, 40).TopPosZ(4, 19))
|
||||
ITEM(StaticText, dv___7, SetText(t_("fg:")).LeftPosZ(4, 40).TopPosZ(24, 19))
|
||||
|
|
|
|||
|
|
@ -45,5 +45,6 @@ LAYOUT(StylerTestLayout, 768, 640)
|
|||
ITEM(StatusBar, stbar, LeftPosZ(0, 768).TopPosZ(616, 23))
|
||||
ITEM(MenuBar, mbar, LeftPosZ(0, 768).TopPosZ(592, 23))
|
||||
ITEM(ToolBar, tool, LeftPosZ(0, 768).TopPosZ(568, 23))
|
||||
ITEM(Option, overdef, SetLabel(t_("Override StyleDefaults with own")).LeftPosZ(544, 216).TopPosZ(168, 16))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static Color SColorSpinButtonMonoColord = LtYellow;
|
|||
|
||||
CH_LOCSTYLE(EditField, Style, EditFieldStyleDFM)
|
||||
{
|
||||
paper = SColorEditPaper;
|
||||
paper = Blend(SColorPaper(), SColorEditPaper);
|
||||
disabled = SColorFace();
|
||||
focus = paper;
|
||||
invalid = Blend(paper, Color(255, 0, 0), 32);
|
||||
|
|
@ -35,7 +35,7 @@ CH_LOCSTYLE(EditField, Style, EditFieldStyleDFM)
|
|||
|
||||
CH_LOCSTYLE(Button, Style, ButtonStyleDFM)
|
||||
{
|
||||
look[0] = SColorButtonFace;
|
||||
look[0] = Blend(SColorFace(), SColorButtonFace);
|
||||
look[1] = SColorFace();
|
||||
look[2] = LtBlue();
|
||||
look[3] = LtYellow();
|
||||
|
|
@ -84,23 +84,22 @@ void StylerTest::Menu(Bar& bar)
|
|||
|
||||
void StylerTest::ApplyOwnStyle()
|
||||
{
|
||||
return;
|
||||
//recalculate own colors
|
||||
ChFinish();
|
||||
|
||||
EditField::Style& stef = EditField::StyleDefault().Write();
|
||||
stef = EditFieldStyleDFM();
|
||||
if(!overdef.Get()) return;
|
||||
|
||||
//override default style settings, without changing ref in each ctrl
|
||||
{
|
||||
Button::Style& stbt = Button::StyleNormal().Write();
|
||||
stbt = ButtonStyleDFM();
|
||||
EditField::Style& s = EditField::StyleDefault().Write();
|
||||
s = EditFieldStyleDFM();
|
||||
}
|
||||
{
|
||||
Button::Style& s = Button::StyleNormal().Write();
|
||||
s = ButtonStyleDFM();
|
||||
}
|
||||
|
||||
SpinButtons::Style& stspbt = SpinButtons::StyleDefault().Write();
|
||||
stspbt = SpinButtonStyleDFM();
|
||||
|
||||
RefreshGlobalStyles();
|
||||
RefreshLayoutDeepAll();
|
||||
{
|
||||
SpinButtons::Style& s = SpinButtons::StyleDefault().Write();
|
||||
s = SpinButtonStyleDFM();
|
||||
}
|
||||
}
|
||||
|
||||
StylerTest::StylerTest()
|
||||
|
|
@ -108,16 +107,20 @@ StylerTest::StylerTest()
|
|||
CtrlLayout(*this, "Window title");
|
||||
Sizeable().Zoomable();
|
||||
|
||||
sc <<= THISBACK(ReloadChamCB);
|
||||
sc.WhenSkinChange = THISBACK(ReloadChamCB);
|
||||
Add(sc.LeftPos(0,200).BottomPos(0,200));
|
||||
|
||||
chc <<= THISBACK(ApplyOwnStyle);
|
||||
chc.WhenSColorsChange = THISBACK(ApplyOwnStyle);
|
||||
Add(chc.RightPos(0,400).BottomPos(0,200));
|
||||
|
||||
InitDummys();
|
||||
b.SetStyle(ButtonStyleDFM());
|
||||
overdef <<= callback(&sc, &StylerCtrl::OnSkinAction); //emulate a skin change
|
||||
|
||||
ApplyOwnStyle();
|
||||
InitDummys();
|
||||
b.SetStyle(ButtonStyleDFM()); //to see statically without change
|
||||
|
||||
overdef.Set(0); //dont override default by default
|
||||
|
||||
sc.OnSkinAction();
|
||||
}
|
||||
|
||||
void StylerTest::InitDummys()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue