From 71e28936a6a1b882e30c3cbe93abc7edbe04e083 Mon Sep 17 00:00:00 2001 From: koldo Date: Fri, 21 Aug 2015 21:22:54 +0000 Subject: [PATCH] Controls4U.h: New InfoCtrl helper classes git-svn-id: svn://ultimatepp.org/upp/trunk@8831 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Controls4U/Controls4U.h | 91 +++++++++++++++++++ bazaar/Controls4U/VLCPlayer.cpp | 1 - bazaar/Controls4U/src.tpp/AboutUpp$en-us.tpp | 4 +- bazaar/Controls4U/src.tpp/AboutUpp$en-us.tppi | 6 +- 4 files changed, 96 insertions(+), 6 deletions(-) diff --git a/bazaar/Controls4U/Controls4U.h b/bazaar/Controls4U/Controls4U.h index 0b8b47d24..ad8d116cc 100644 --- a/bazaar/Controls4U/Controls4U.h +++ b/bazaar/Controls4U/Controls4U.h @@ -650,6 +650,97 @@ private: virtual void LeftDown(Point p, dword keyflags) {LaunchWebBrowser(hyperlink);} }; +class BarDisplay : public Display { +public: + BarDisplay() : ink(SColorText), value(0), align(ALIGN_LEFT) {} + + virtual void Paint(Draw& w, const Rect& r, const Value& , Color, Color, dword) const { + int width = int(r.Width()*value); + w.DrawRect(r.left, r.top, width, r.bottom, color); + w.DrawRect(r.left + width, r.top, r.right - width, r.bottom, paper); + if (!text.IsEmpty()) { + Size sz = GetTextSize(text, StdFont()); + int xtext; + switch (align) { + case ALIGN_LEFT: xtext = 0; break; + case ALIGN_CENTER: xtext = (r.GetWidth() - sz.cx)/2; break; + default: xtext = r.GetWidth() - sz.cx; + } + + w.DrawText(r.left + xtext, r.top + (r.Height() - StdFont().Info().GetHeight())/2, + text, StdFont(), ink); + } + } + BarDisplay &SetValue(double _value) {value = _value;return *this;} + BarDisplay &SetText(const char *str){text = str; return *this;} + BarDisplay &SetColor(Color _color, Color _paper = Null, Color _ink = SColorText) {color = _color; + ink = _ink; paper = _paper; return *this;} + BarDisplay &SetAlign(int a) {align = a; return *this;} + +private: + Color color, ink, paper; + String text; + double value; + int align; +}; + +class TextDisplay : public Display { +public: + TextDisplay() : ink(SColorText), align(ALIGN_LEFT) {} + + virtual void Paint(Draw& w, const Rect& r, const Value&, Color, Color, dword) const { + w.DrawRect(r.left, r.top, r.right, r.bottom, paper); + + Size sz = GetTextSize(text, StdFont()); + int xtext; + switch (align) { + case ALIGN_LEFT: xtext = 0; break; + case ALIGN_CENTER: xtext = (r.GetWidth() - sz.cx)/2; break; + default: xtext = r.GetWidth() - sz.cx; + } + w.DrawText(r.left + xtext, r.top + (r.Height() - StdFont().Info().GetHeight()) / 2, + text, StdFont(), ink); + } + TextDisplay &SetText(const char *str) {text = str; return *this;} + TextDisplay &SetColor(Color _ink, Color _paper = Null) {ink = _ink; paper = _paper; return *this;} + TextDisplay &SetInk(Color _ink) {ink = _ink; return *this;} + TextDisplay &SetPaper(Color _paper) {paper = _paper; return *this;} + TextDisplay &SetAlign(int a) {align = a; return *this;} + +private: + Color ink, paper; + String text; + int align; +}; + +class InfoCtrlBar : public InfoCtrl { +public: + InfoCtrlBar() {Set(PaintRect(bar));} + + InfoCtrlBar &SetValue(double value) {bar.SetValue(value); return *this;} + InfoCtrlBar &SetText(const char *str) {bar.SetText(str); return *this;} + InfoCtrlBar &SetColor(Color color, Color paper = Null, Color ink = SColorText) {bar.SetColor(color, paper, ink); return *this;} + InfoCtrlBar &SetAlign(int a) {bar.SetAlign(a); return *this;} + +private: + BarDisplay bar; +}; + +class InfoCtrlText : public InfoCtrl { +public: + InfoCtrlText() {Set(PaintRect(text));} + + InfoCtrlText &SetText(const char *str) {text.SetText(str); return *this;} + InfoCtrlText &SetColor(Color ink, Color paper = Null) {text.SetColor(ink, paper); return *this;} + InfoCtrlText &SetInk(Color ink) {text.SetInk(ink); return *this;} + InfoCtrlText &SetPaper(Color paper) {text.SetPaper(paper); return *this;} + InfoCtrlText &SetAlign(int a) {text.SetAlign(a); return *this;} + +private: + TextDisplay text; +}; + + END_UPP_NAMESPACE #endif diff --git a/bazaar/Controls4U/VLCPlayer.cpp b/bazaar/Controls4U/VLCPlayer.cpp index 85dd6cf96..791c812d1 100644 --- a/bazaar/Controls4U/VLCPlayer.cpp +++ b/bazaar/Controls4U/VLCPlayer.cpp @@ -29,7 +29,6 @@ bool VLCPlayer::AddTarget(const String movie) { return true; } - bool VLCPlayer::Play() { IIVLC vlc(this); if (!vlc) diff --git a/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tpp b/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tpp index 21f19c5fa..9effaeffc 100644 --- a/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tpp +++ b/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tpp @@ -15,9 +15,9 @@ taticRect]&] [s6; AboutUpp shows a StaticRect with the U`+`+ authors, licensing info and related links.&] [s6; &] +[s4; &] [ {{10000F(128)G(128)@1 [s0; [*2 Constructor Detail]]}}&] [s1; &] [s2;:AboutUpp`:`:AboutUpp`(`):%- [* AboutUpp]()&] [s3; Initializes AbouUpp.&] -[s4;%- &] -[s0; ]] \ No newline at end of file +[s4; ]] \ No newline at end of file diff --git a/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tppi b/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tppi index 107fb833b..f1bcc4c89 100644 --- a/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tppi +++ b/bazaar/Controls4U/src.tpp/AboutUpp$en-us.tppi @@ -1,6 +1,6 @@ TITLE("EditFile") COMPRESSED -120,156,133,145,111,107,219,48,16,198,191,138,32,237,72,210,52,145,238,36,203,177,223,100,172,127,54,6,27,172,228,149,112,107,199,86,27,81,215,14,150,66,97,165,223,125,231,164,105,187,49,168,95,72,226,238,158,187,223,61,54,236,232,136,79,248,128,127,240,37,103,246,182,216,214,33,51,95,163,148,147,72,244,34,21,81,42,82,66,74,201,37,68,130,35,72,20,200,1,149,152,171,40,89,217,59,215,100,198,73,25,167,5,168,244,254,251,207,121,10,164,6,82,163,22,24,43,20,36,164,67,160,0,5,40,69,12,115,25,35,106,158,148,109,101,93,176,15,153,169,33,142,119,58,36,29,104,5,66,203,88,198,2,117,12,36,7,206,129,107,32,14,140,65,37,149,245,101,102,122,72,73,229,243,8,231,92,112,174,69,143,167,57,42,41,4,2,181,0,13,130,171,196,54,213,255,16,213,135,136,49,33,214,133,247,153,89,73,216,105,162,73,52,160,245,81,113,61,231,90,106,37,201,16,16,145,32,52,222,203,8,37,105,218,238,161,168,51,243,116,243,124,124,254,227,116, -121,197,12,123,122,18,189,203,11,100,198,243,148,153,241,66,167,146,125,94,181,219,176,220,108,178,236,249,249,83,102,188,76,89,127,169,52,57,100,242,36,79,124,232,182,101,72,142,79,153,89,12,249,148,79,65,169,17,178,125,56,51,200,110,50,51,198,183,102,125,36,161,216,251,226,205,118,85,187,242,80,188,192,20,217,85,40,130,43,127,89,234,177,31,58,190,14,237,198,149,52,114,150,207,190,180,77,232,218,218,203,101,62,243,93,153,207,206,43,23,46,92,109,47,218,186,178,93,126,100,155,252,116,235,243,193,63,113,226,221,121,118,189,64,2,238,27,71,233,43,26,243,235,246,209,179,226,221,108,246,232,194,154,133,181,101,203,252,36,63,97,197,54,172,219,206,79,24,225,218,198,187,230,142,185,230,182,101,69,83,177,206,214,69,176,21,165,154,123,63,125,233,77,215,193,221,139,161,128,120,116,185,59,23,226,224,52,48,218,101,111,86,219,177,51,27,10,87,31,12,23,123,195,225,111,195,95,223,195,124,180,179,125,252,102,238,112,212,11,48,101,223,26,23,92,81, -187,223,214,239,178,148,156,238,255,225,203,222,52,60,203,254,0,113,82,252,19, +120,156,133,144,95,107,219,48,20,197,191,138,32,233,72,210,252,145,238,149,44,199,126,201,88,155,110,12,54,88,201,147,80,107,199,86,27,81,215,14,150,66,97,161,223,125,114,210,180,221,24,212,15,178,184,247,158,115,127,58,138,244,251,116,76,123,244,131,47,185,48,119,249,174,242,90,125,141,82,26,68,172,19,137,40,180,34,193,56,231,148,67,196,40,2,71,134,20,80,176,185,136,146,181,185,183,181,86,150,243,56,205,65,164,15,223,127,206,83,8,106,8,106,148,12,99,129,44,8,195,193,144,129,0,228,44,134,57,143,17,37,77,138,166,52,214,155,71,173,42,136,227,131,14,131,14,164,0,38,121,204,99,134,50,134,32,7,74,129,74,8,28,24,131,72,74,227,10,173,58,72,30,198,231,17,206,41,163,84,178,14,79,82,20,156,49,132,96,1,18,24,21,137,169,203,255,33,138,15,17,227,128,88,229,206,105,181,230,112,208,68,227,168,23,158,143,130,202,57,149,92,10,30,2,1,22,177,128,70,59,89,64,73,234,166,125,204,43,173,246,183,207,103,151,63,38, +171,107,162,200,126,207,186,148,23,72,148,163,41,81,163,133,76,57,249,188,110,118,126,181,221,106,253,252,252,73,43,199,83,210,253,68,154,156,58,89,146,37,206,183,187,194,39,103,19,162,22,3,58,165,83,16,98,136,228,88,214,10,201,173,86,35,124,51,235,42,73,168,189,31,222,238,214,149,45,78,195,11,76,145,92,251,220,219,226,151,9,30,199,165,163,27,223,108,109,17,86,206,178,217,151,166,246,109,83,57,190,202,102,174,45,178,217,101,105,253,210,86,102,217,84,165,105,179,190,169,179,201,206,101,189,127,234,129,247,144,217,205,2,3,112,103,28,165,175,104,196,109,154,39,71,242,119,187,201,147,245,27,226,55,134,172,178,243,236,156,228,59,191,105,90,55,38,1,215,212,206,214,247,196,214,119,13,201,235,146,180,166,202,189,41,67,171,126,112,211,23,239,183,220,78,33,47,7,12,226,225,213,225,92,176,83,224,64,194,147,142,153,53,45,185,48,62,183,213,41,119,118,180,129,191,115,127,189,15,178,225,33,253,209,91,198,131,97,39,192,148,124,171,173,183,121, +101,127,27,119,232,134,230,244,5,73,235,63,78,126,251,197,