virtual Value GetData(int nIndex = 0) const; virtual Value GetData() const;
slider.SetTextLabels(5); slider.SetGradations(3);
SetTickNum(int n); // SetTickCount TickHaveLabel(bool b = true); // TickHaveNum , TickHaveText, HaveTickText, etc.
App() { Add(slider.BottomPosZ(5, 50).HSizePos(10, 10)); Add(progress.VSizePos(10, 50).HCenterPos(50)); Add(text.LeftPos(5, 200).TopPos(5, 40)); slider <<= THISBACK(Slider); slider.Range(100); slider <<= 5; slider.SetMajorTicks(10); slider.SetMinorTicks(1); slider.SetMinorTicksSize(40); slider.SetMajorTicksSize(50); //slider.SetTickPosition(BOTTOM); Slider(); Sizeable().Zoomable(); }
Quote: |
What I want to do is do a vector.clear operation and populate the vector either from the Main.cpp or from USC code (better option) so that I can visualize it correctly in the designer. |
Quote: |
I feel the ESC documentation is incomplete or maybe I am not looking correctly. |
Quote: |
I might contribute some more controls as I progress in UPP. |
Quote: |
- user defined formatting fn, this sounds like a great idea. So it would be a virtual fn I guess? Or is there a better way? |
graph.LabelFormat = THISBACK(MyFormatFunction); ... void MyClass::MyFormatFunction(String &s, int val) { int min = int(val/60); int secs = val - 60*min; s = Format("%02d:%02d", min, sec); }
Quote: |
- I don't know much about .usc files, but I will try, can you point me to some information? - Your idea to better use the space is a good one. I will look into this as well. |
Callback2<String&, int> LabelFormat;
slider.LabelFormat = THISBACK(LabelFormatting);
void LabelFormatting(String &str, int val) { str = SecondsToString(val, false); }
koldo wrote on Wed, 08 December 2010 02:10 |
Hello avpavp and Mirek I have uploaded to Bazaar/SliderCtrlX the SliderCtrl improved version included by avpavp plus a label formatting function: Callback2<String&, int> LabelFormat; For example, if SliderCtrl contains time in seconds, but you want to visualize hour:min:sec format, you would do this: In the constructor: slider.LabelFormat = THISBACK(LabelFormatting); And after that: void LabelFormatting(String &str, int val) { str = SecondsToString(val, false); } And you would get something like this: |
jerson wrote on Fri, 22 April 2011 08:30 |
I checked it on WinXP and it still works. |
#ifndef _JBControlsTest_JBControlsTest_h #define _JBControlsTest_JBControlsTest_h #include <CtrlLib/CtrlLib.h> #include <Controls4U/Controls4U.h> #include <JBControls/SliderCtrlX.h> using namespace Upp; class JBControlsTest : public TopWindow { public: typedef JBControlsTest CLASSNAME; JBControlsTest(); SliderCtrlX slider; }; #endif
#include "JBControlsTest.h" JBControlsTest::JBControlsTest() { Add(slider.FillColor(Color(255, 85, 0)).SetThickness(3).SetThumbType(4).LeftPosZ(63, 330).TopPosZ(220, 52)); slider.Jump(true); } GUI_APP_MAIN { JBControlsTest().Run(); }
#include "JBControlsTest.h" JBControlsTest::JBControlsTest() { Add(slider.FillColor(Color(255, 85, 0)).SetThickness(3).SetThumbType(4).Jump(true).LeftPosZ(63, 330).TopPosZ(220, 52)); } GUI_APP_MAIN { JBControlsTest().Run(); }
... private: ... bool m_bJump; // Jumps directly to mouse pos if click on the scale ... public: ... SliderCtrlX& Jump(bool v = false) { m_bJump = v; } ...
... SliderCtrlX::SliderCtrlX() : m_nMin(0) , m_nMax(100) , m_bInverted(false) , m_nStep(1) , m_bRound_step(false) , m_bJump(false) , m_bUseCustomThumbs( 0 ) , m_nMajorTicks( 10 ) , m_nMinorTicks( 2 ) , m_nMajorTickSize( 30 ) , m_nMinorTickSize( 20 ) , m_nTickPosition( TOP ) , m_nThickness( 2 ) , m_nSliderType( 0 ) , m_nThumbNumber( 1 ) { ... } ... void SliderCtrlX::LeftDown(Point pos, dword keyflags) { ... else if( m_bJump ) { m_vValues[0] = ClientToSlider(p); WhenSlideFinish(); UpdateActionRefresh(); } ... } ...
SliderCtrlX& Jump(bool v = false) { m_bJump = v; return *this; } // Added return *this;
w.DrawImage(max( SliderToClient(m_vValues[i]) - ( ( m_bUseCustomThumbs ? m_vThumbImgs[i].GetSize().cx : m_ThumbImg.GetSize().cx ) >> 1 ), 0), m_nThickness + ((size.cy - ( m_bUseCustomThumbs ? m_vThumbImgs[i].GetSize().cy : (m_ThumbImg.GetSize().cy ))) >> 1), // Added parenthesis HasCapture() || HasFocus() ? (m_bUseCustomThumbs ? m_vThumbImgsFocus[i] : m_ThumbImg) : (m_bUseCustomThumbs ? m_vThumbImgs[i] : m_ThumbImg));
m_ThumbImg = SliderThumbsImg::Get(m_nThumbType);
koldo wrote on Fri, 13 May 2011 22:32 |
First jibe version works well in debug and optimal just doing these changes: In SliderCtrlX.h SliderCtrlX& Jump(bool v = false) { m_bJump = v; return *this; } // Added return *this; |
koldo wrote on Fri, 13 May 2011 22:32 |
this line was hard to understand for me |
koldo wrote on Fri, 13 May 2011 22:32 |
What is the problem with FillColor ? |
koldo wrote on Fri, 13 May 2011 22:32 |
it hangs in SliderCtrlX& SliderCtrlX::SetThumbType(int n) |
koldo wrote on Sat, 14 May 2011 21:32 |
Hello About the return *this;, it has been reported that gcc options in TheIDE could check more warnings like this . It is very simple to add it to TheIDE |
koldo wrote on Sat, 14 May 2011 21:32 |
About the FillColor, I change it in layout designer without problems... |
koldo wrote on Sat, 14 May 2011 21:32 |
About the hanging in MinGW, do you mean that in Linux it works now well? It is very strange. |
void StarIndicator::Layout() { ... int y = int(ceil(double(x/5)));
koldo wrote on Thu, 26 May 2011 22:41 |
Just do this change or similar to avoid MSVC complains |
jibe wrote on Thu, 26 May 2011 19:06 |
BTW : I wanted to have a hand cursor when it goes on the thumb. How can I do that ? |
/*********************************************************************************************** * SliderCtrlX * * Enhanced Slider Control / Slider indicator * * Autors : avpavp, jerson, jibe, koldo * Last modified : May 28, 2011 * * 2do : adjust DrawTicks() in every position * Thumbs are not always at the right position at Min and Max values (we should have a half * thumb). * adjust default values when changing CONTROL/INDICATOR * Known bugs : Invalid memory access when choosing FillColor with .lay designer (seems to be * only with ubuntu. See http://www.ultimatepp.org/forum/index.php?t=msg&th=6022&start=0& **********************************************************************************************/
koldo wrote on Thu, 09 June 2011 12:44 |
The thumb in the beginning touches the end of the control, but at the end there is a little gap between it and the end of the control. |
koldo wrote on Thu, 09 June 2011 12:44 |
changing a little bit the authors list of course |
Quote: |
changing a little bit the authors list of course |
koldo wrote on Fri, 10 June 2011 10:11 |
See this: It happens the same to the horizontal ones. |
koldo wrote on Thu, 09 June 2011 12:44 |
The thumb in the beginning touches the end of the control, but at the end there is a little gap between it and the end of the control. |
koldo wrote on Mon, 28 November 2011 16:56 |
About the stars, the best way to paint something resizable in U++ is using Painter. |
StarIndicator& StarIndicator::SetVotes(int n) /*********************************************************************************************** * Sets the number of votes and the associated color * virtual - public **********************************************************************************************/ { m_nVotes=n; if (n<0) SetColor(LtCyan); else if (n < m_nVotesLow) SetColor(Color(255,128,128)); else if (n < m_nVotesHigh) SetColor(Yellow); else SetColor(LtGreen); Refresh(); return *this; }
koldo wrote on Tue, 29 November 2011 09:07 |
It is rather easy to translate the Paint function to Painter. If you want I can do a simple version for you to extend it when you learn more. |
koldo wrote on Tue, 29 November 2011 09:07 |
If I were you I would move all the comments like this to a .tpp help file. This way they will be accessible to help system and they will appear in web Smile. |
koldo wrote on Tue, 29 November 2011 17:02 |
Here Mirek left excellent Painter examples. |
koldo wrote on Tue, 29 November 2011 17:02 |
A good thing is that with Painter we would not use star images and we could get nice visual effects. |
koldo wrote on Tue, 29 November 2011 17:02 |
About .tpp help file I can begin one for you for StarIndicator and you could complete it. |
koldo wrote on Sat, 23 March 2013 00:27 |
It is now uploaded. |
koldo wrote on Sat, 23 March 2013 00:27 |
However remember that uppweb shows in internet all tpp pages that are linked. I mean, if anybody adds a new tpp help page and it is not linked by any other, it will not be shown in the web. |
koldo wrote on Wed, 30 November 2011 17:57 |
Hello Jibe If you want I can include Painter in StarIndicator with few and commented changes from original code for you to understand better. When you learn more you can add nice effects to the stars like shades and reflections... if it makes sense . |