From ccf287001a3df40d4a3f88167c759337edd2211d Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 17 Apr 2017 07:43:42 +0000 Subject: [PATCH] CtrlLib: Option: SetColor git-svn-id: svn://ultimatepp.org/upp/trunk@11016 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/Button.cpp | 3 +- uppsrc/CtrlLib/PushCtrl.h | 2 + uppsrc/CtrlLib/src.tpp/Option$en-us.tpp | 49 +++++++++++++++++-------- uppsrc/TextDiffCtrl/DirDiff.cpp | 17 +++++---- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/uppsrc/CtrlLib/Button.cpp b/uppsrc/CtrlLib/Button.cpp index 2c1c47012..8f97727c6 100644 --- a/uppsrc/CtrlLib/Button.cpp +++ b/uppsrc/CtrlLib/Button.cpp @@ -581,7 +581,7 @@ void Option::Paint(Draw& w) { if(showlabel) { bool ds = !IsShowEnabled(); DrawSmartText(w, isz.cx + 4, ty, tsz.cx, label, font, - ds || IsReadOnly() ? SColorDisabled : GetLabelTextColor(this), + ds || IsReadOnly() ? SColorDisabled : Nvl(color, GetLabelTextColor(this)), VisibleAccessKeys() ? accesskey : 0); if(HasFocus()) DrawFocus(w, RectC(isz.cx + 2, ty - 1, tsz.cx + 3, tsz.cy + 2) & sz); @@ -628,6 +628,7 @@ Option::Option() { showlabel = true; Transparent(); font = StdFont(); + color = Null; } Option::~Option() {} diff --git a/uppsrc/CtrlLib/PushCtrl.h b/uppsrc/CtrlLib/PushCtrl.h index 15289e111..6339c9f85 100644 --- a/uppsrc/CtrlLib/PushCtrl.h +++ b/uppsrc/CtrlLib/PushCtrl.h @@ -182,6 +182,7 @@ protected: bool notnull; bool blackedge; bool showlabel; + Color color; public: Option& Set(int b); @@ -201,6 +202,7 @@ public: Option& NotNull(bool nn = true) { notnull = nn; Refresh(); return *this; } Option& NoNotNull() { return NotNull(false); } bool IsNotNull() const { return notnull; } + Option& SetColor(Color c) { color = c; Refresh(); return *this; } Option(); virtual ~Option(); diff --git a/uppsrc/CtrlLib/src.tpp/Option$en-us.tpp b/uppsrc/CtrlLib/src.tpp/Option$en-us.tpp index 6e369c312..7c72959f3 100644 --- a/uppsrc/CtrlLib/src.tpp/Option$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/Option$en-us.tpp @@ -17,12 +17,7 @@ er]&] [s0; &] [s2;%% @@image:712&131 -򀕀튃Ӯâҟ؍ػ侹䞓𼯄 -ѿǁނﴦڶ۰ԁ̣ǻ惱ާ٥ -ҠƩʖȗ‡ǧȐ涭º仺崩̝慪ѥ۩ -䠼ڼ꿫ХԤߴܵݜѥӨ奊µҕ΋ߨʵ -݋䡩Իδխ՞ȭʖҪɭᨃ٪ -ղƯܮע +(A3IAFQAAAOv/AAAAAHic7ZhtioNADIa9U++059hTLsMigiwiYhFZytKfDQkVm8xk4li7FBJeZD7UZB6T/PA8hLPL5XK5DtDp9GHRv8f5XgJiX2ghhG+0pmnatv252zAMTvWJVIEnTKNUq0c7Ljx6+fr6AklHW10DsYAGAOu6Xidq9VmlqJb52nmWl1Hdf1IgRilKSJfCB6REdRxHp1pAFXgCPWDIkIIgUed5tlNlPUGOoyvyZrbCOoDSeeQ7ZbQpv8ydJWaFKqQoUSWwa6RbqbIt5XT6iuSgPBidWrykgrQ/q1ClDrDAJEHhA89ftIJctVBN3ZylKlMo5SWKLhukQjXlWlKVhT+iAc8LmpGqJQ2iMSvfKEo1dRYjVd2LTlUhKal2Xdf3PdQ7Q/qHdjTVrblqD8AyLqOazdUejbroUviE9Iq2vwPIrfVKllKqiqMhyS05ZWEog2zMWaqAdJomO9Uy2evofXXcfwCWtMav7HK5XC7XohsrJCxc) &] [s0;%% &] [s9;%% Widget providing the selection of 2 or alternatively 3 states @@ -79,27 +74,36 @@ representation suitable for placing it on dialog (SColorFace).&] [s7;%% [*/ Return value]-|`*this for chaining.&] [s3;%% &] [s4; &] +[s5;:Upp`:`:Option`:`:IsBlackEdge`(`)const: [@(0.0.255) bool]_[* IsBlackEdge]()_[@(0.0.255) c +onst]&] +[s2;%% Returns true if BlackEdge is active.&] +[s3; &] +[s4; &] [s5;:Option`:`:SwitchImage`(bool`): [_^Option^ Option][@(0.0.255) `&]_[* SwitchImage]([@(0.0.255) b ool]_[*@3 b]_`=_[@(0.0.255) true])&] [s2;%% Activates visual representation that paints the Option with the Switch appearance.&] -[s7;%% [%-*C@3 b]-|true to activate.&] -[s7;%% [*/ Return value]-|`*this for chaining.&] [s3;%% &] [s4; &] +[s5;:Upp`:`:Option`:`:IsSwitchImage`(`)const: [@(0.0.255) bool]_[* IsSwitchImage]()_[@(0.0.255) c +onst]&] +[s2;%% Returns true if SwitchImage is active.&] +[s3; &] +[s4; &] [s5;:Option`:`:ThreeState`(bool`): [_^Option^ Option][@(0.0.255) `&]_[* ThreeState]([@(0.0.255) b ool]_[*@3 b]_`=_[@(0.0.255) true])&] [s2;%% Activates three`-state mode. Also activates NoNotNull mode.&] -[s7;%% [%-*C@3 b]-|true to activate.&] -[s7;%% [*/ Return value]-|`*this for chaining.&] [s3;%% &] [s4; &] +[s5;:Upp`:`:Option`:`:IsThreeState`(`)const: [@(0.0.255) bool]_[* IsThreeState]()_[@(0.0.255) c +onst]&] +[s2;%% Returns true if ThreeState is active.&] +[s3; &] +[s4; &] [s5;:Option`:`:NotNull`(bool`): [_^Option^ Option][@(0.0.255) `&]_[* NotNull]([@(0.0.255) boo l]_[*@3 nn]_`=_[@(0.0.255) true])&] [s2;%% Activates NotNull mode `- Null Value assigned to Option (via SetData) is interpreted as false.&] -[s7;%% [%-*C@3 nn]-|true to activate.&] -[s7;%% [*/ Return value]-|`*this for chaining.&] [s3;%% &] [s4; &] [s5;:Option`:`:NoNotNull`(`): [_^Option^ Option][@(0.0.255) `&]_[* NoNotNull]()&] @@ -108,10 +112,23 @@ is interpreted as Null.&] [s7;%% [*/ Return value]-|`*this for chaining.&] [s3;%% &] [s4; &] +[s5;:Upp`:`:Option`:`:IsNotNull`(`)const: [@(0.0.255) bool]_[* IsNotNull]()_[@(0.0.255) con +st]&] +[s2;%% Returns true if NotNull is active.&] +[s3; &] +[s4; &] +[s5;:Upp`:`:Option`:`:SetColor`(Upp`:`:Color`): [_^Upp`:`:Option^ Option][@(0.0.255) `&]_ +[* SetColor]([_^Upp`:`:Color^ Color]_[*@3 c])&] +[s2;%% Sets the color of text of Option label. Setting Null restores +the default color.&] +[s3;%% &] +[s4; &] [s5;:Option`:`:ShowLabel`(bool`): [_^Option^ Option][@(0.0.255) `&]_[* ShowLabel]([@(0.0.255) b ool]_[*@3 b]_`=_[@(0.0.255) true])&] -[s2;%% Togles the display of the option`'s label.&] -[s7; [*@3 b]-|true to show label&] -[s7;%% [*/ Return value]-|`*this for chaining.&] +[s2;%% Toggles the display of the option`'s label.&] [s3;%% &] -[s0; ] \ No newline at end of file +[s4; &] +[s5;:Upp`:`:Option`:`:IsShowLabel`(`)const: [@(0.0.255) bool]_[* IsShowLabel]()_[@(0.0.255) c +onst]&] +[s2;%% Returns true if ShowLabel is active.&] +[s0; ]] \ No newline at end of file diff --git a/uppsrc/TextDiffCtrl/DirDiff.cpp b/uppsrc/TextDiffCtrl/DirDiff.cpp index 35b714a1d..a25ede6ec 100644 --- a/uppsrc/TextDiffCtrl/DirDiff.cpp +++ b/uppsrc/TextDiffCtrl/DirDiff.cpp @@ -70,13 +70,14 @@ void DirDiffDlg::Compare() void DirDiffDlg::ShowResult() { - static Color cs[] = {SColorText(), Red, Green()}; + static Color cs[] = { SColorText(), Red(), Green() }; files.Clear(); for(int i = 0; i < list.GetCount(); i++) { int n = list[i].d; - if( (n==0 && modified) || (n==1 && removed) || (n==2 && added)) - files.Add(list[i].a, NativePathIcon(FileExists(list[i].b) ? list[i].b : list[i].c), StdFont(),cs[list[i].d]); + if(n == 0 && modified || n == 1 && removed || n == 2 && added) + files.Add(list[i].a, NativePathIcon(FileExists(list[i].b) ? list[i].b : list[i].c), + StdFont(), cs[list[i].d]); } info = AsString(files.GetCount()) + " files"; } @@ -124,9 +125,9 @@ DirDiffDlg::DirDiffDlg() hidden.SetLabel(t_("Hidden")); - added.SetLabel(t_("New")); + added.SetColor(Green()).SetLabel(t_("New")); modified.SetLabel(t_("Modified")); - removed.SetLabel(t_("Removed")); + removed.SetColor(Red()).SetLabel(t_("Removed")); compare.SetLabel(t_("Compare")); int bcy = compare.GetStdSize().cy; @@ -160,9 +161,9 @@ DirDiffDlg::DirDiffDlg() dir1 <<= THISBACK(ClearFiles); dir2 <<= THISBACK(ClearFiles); - modified << [=]() {ShowResult();}; - removed << [=]() {ShowResult();}; - added << [=]() {ShowResult();}; + modified << [=] { ShowResult(); }; + removed << [=] { ShowResult(); }; + added << [=] { ShowResult(); }; files.WhenSel = THISBACK(File);