Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » hiding the vertical scrollbar of LineEdit Ctrl
hiding the vertical scrollbar of LineEdit Ctrl [message #38044] Thu, 29 November 2012 08:59 Go to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Hi All,

Just wondering, Is there a way to hide the vertical scrollbar of LineEdit Ctrl? I have two LineEdit Ctrl displaying almost similar text with same number of lines and I only want one of them to show the vertical scrollbar and they both can be scrolled together with only one showing the bar.

I have extend the LineEdit Ctrl as follwing to get the synchronize scrolling. Now I just need a way to hide one of the vertical scrollbar now.

there is a function LineEdit::NoHorzScrollbar() but could not find a similar function for Vertical Scrollbar. I also skim through the LineEdit Class but the Scrolling mechanism looks not that easy to understand. It uses the 'Scroller' Class that I could not find any documentation for.


#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class LineEditExtended : public LineEdit{
	public:
		virtual void NewScrollPos(){ WhenScrollChange();}
		Callback WhenScrollChange;
		
};



class MainWindowDlg : public TopWindow {

	typedef MainWindowDlg CLASSNAME;
	
	public:
	    MainWindowDlg(){
            
                SetRect(0,0,600,400);
                tx1.VSizePos(10,10).LeftPos(10,290);
                tx2.VSizePos(10,10).RightPos(10, 290);
            
                this<<tx1<<tx2;
            
                String tmp;
            
                for(int i=0; i<100; i++) tmp<<i<<"\n";
            
                tx1.Set(tmp);
                tx2.Set(tmp);
            
                tx2.WhenScrollChange=THISBACK(tx1Totx2SyncScrol);
	        tx1.WhenScrollChange=THISBACK(tx2Totx1SyncScrol);
            		
	    }
	
	private: 
		void tx2Totx1SyncScrol(){ 
			tx2.SetScrollPos(tx1.GetScrollPos()); 
		}
		
		void tx1Totx2SyncScrol(){ 
			tx1.SetScrollPos(tx2.GetScrollPos()); 
		}

		LineEditExtended tx1, tx2;
		

};

GUI_APP_MAIN
{
    MainWindowDlg w;
    
    w.Run();

}



Thank & Regards

Navi
  • Attachment: main.cpp
    (Size: 1.10KB, Downloaded 205 times)
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38045 is a reply to message #38044] Thu, 29 November 2012 09:01 Go to previous messageGo to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
index.php?t=getfile&id=3947&private=0
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38047 is a reply to message #38045] Thu, 29 November 2012 09:44 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi navi,

Simple trick:
class LineEditExtended : public LineEdit{
	public:
		virtual void NewScrollPos(){ WhenScrollChange();}
		Callback WhenScrollChange;
		void RemoveScrollBar(){ RemoveFrame(sb); }
};

Then just call tx1.RemoveScrollBar() in MainWindowDlg constructor. I believe it does exactly what you need Wink

Best regards,
Honza
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38048 is a reply to message #38047] Thu, 29 November 2012 10:05 Go to previous messageGo to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Thanks Honza for your very quick reply. Brilliant & simple solution Honza. It does remove the scrollbar as I wanted. However, we have a small problem. if the scrollbar frame is removed and user click on the tx1 then the tx1 goes mad!! text and blank lines get printed all over the place! any way to prevent this?

Regards
Navi
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38053 is a reply to message #38048] Thu, 29 November 2012 11:13 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

navi wrote on Thu, 29 November 2012 10:05

Thanks Honza for your very quick reply. Brilliant & simple solution Honza. It does remove the scrollbar as I wanted. However, we have a small problem. if the scrollbar frame is removed and user click on the tx1 then the tx1 goes mad!! text and blank lines get printed all over the place! any way to prevent this?

Regards
Navi

Oups, sorry I missed that. I'm not even sure why that happens, I'll have too look at it deeper, later today (not enough time right now, sorry...).

Honza
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38076 is a reply to message #38044] Thu, 29 November 2012 18:12 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Navi,

Finally got it Smile It works much better when you only Hide the scrollbars instead of removing them completely:
		void HideScrollBar(){
			sb.NoAutoHide();
			sb.Hide();
		}


Best regards,
Honza
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38082 is a reply to message #38076] Thu, 29 November 2012 20:36 Go to previous messageGo to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
dolik.rce wrote on Thu, 29 November 2012 18:12


Finally got it Smile It works much better when you only Hide the scrollbars instead of removing them completely:[code]



Thank you very much Honza. It is working this way. Very Happy

Regards

Navi
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38090 is a reply to message #38076] Fri, 30 November 2012 08:29 Go to previous messageGo to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
dolik.rce wrote on Thu, 29 November 2012 18:12

Hi Navi,

Finally got it Smile It works much better when you only Hide the scrollbars instead of removing them completely:
		void HideScrollBar(){
			sb.NoAutoHide();
			sb.Hide();
		}


Best regards,
Honza



Hi Honza, Just thought I will let you know that. this way has a little bit of issue to. If I hide the 'sb' then Horizontal Scrollbar get hidden along with the Vertical one. Please note this is not a big issue for me at present. As in this particular case I am not worried about showing the Horizontal Scrollbar. But in case you find a better way that ONLY hides the Vertical Scrollbar, Please leave a reply on this thread. It might come in handy for me and others in future.

Thanks & Regards
Navi
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38093 is a reply to message #38090] Fri, 30 November 2012 09:25 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

navi wrote on Fri, 30 November 2012 08:29

But in case you find a better way that ONLY hides the Vertical Scrollbar, Please leave a reply on this thread. It might come in handy for me and others in future.

Sure, it should be simple, the scrollbars in ScrollBars are publicly accessible, so this should hide only the vertical one:
		void HideScrollBar(){
			sb.y.NoAutoHide();
			sb.y.Hide();
		}


Don't you love it how the U++ interface is uniform across all the widgets? Smile

Honza

[Updated on: Fri, 30 November 2012 10:08]

Report message to a moderator

Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38096 is a reply to message #38093] Fri, 30 November 2012 12:19 Go to previous messageGo to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Quote:

Don't you love it how the U++ interface is uniform across all the widgets?

absolutely love u++ uniform interface acrosse the widgets!! as well as everything else about it. I am adicted to U++. But you are awesome too. How do you know these things? isn't scrollbar still a undocumented class?


also as per your code I have modified my version of LineEditExtended to the followings. works like a charm. I am also planing to make some farther modification to LineEdit to make it more like NotePad++. like adding Find And Replace, Block Selection, Syntex Highlight etc. I found my starting point here at this thread: Advanced Line Edit proposal - part I

class LineEditExtended : public LineEdit{
	public:
		virtual void NewScrollPos(){
                        WhenScrollChange();
                }
		
		void NoScrollbar(){
			sb.NoAutoHide();
			sb.Hide();
		}
		
		void NoVertScrollbar(){		
			sb.y.NoAutoHide();
			sb.y.Hide();
		}

		Callback WhenScrollChange;
};




I have already manage to teach it (LineEditExtended) to sort filneams and filetype for me! Very Happy no credit to me, but HUGE thanks to U++ and its awesomeness.

index.php?t=getfile&id=3954&private=0

regards
Navi
  • Attachment: rp.png
    (Size: 45.50KB, Downloaded 452 times)

[Updated on: Fri, 30 November 2012 13:54]

Report message to a moderator

Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38100 is a reply to message #38096] Fri, 30 November 2012 13:48 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

navi wrote on Fri, 30 November 2012 12:19

But you are awesome too. How do you know these things?
Thanks Smile Some parts I met in past (or struggled with Wink ), some parts I just look up in the code when trying to answer.

navi wrote on Fri, 30 November 2012 12:19

isn't scrollbar still a undocumented class?
Well, it is not documented, but it is really simple, so it is quick and easy to figure out what it does. In combination with general knowledge of U++ interfaces, it is even easier. BTW: If you want, you can write docs for it, that's generally good way to learn more about some code Wink

Honza
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38101 is a reply to message #38096] Fri, 30 November 2012 14:03 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

navi wrote on Fri, 30 November 2012 12:19

I am also planing to make some farther modification to LineEdit to make it more like NotePad++. like adding Find And Replace, Block Selection, Syntex Highlight etc.

Maybe it would be better to base your code on CodeEditor instead of LineEdit -> you will get most of those features for free Wink

Honza
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38102 is a reply to message #38101] Fri, 30 November 2012 14:23 Go to previous message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
dolik.rce wrote on Fri, 30 November 2012 14:03


Maybe it would be better to base your code on CodeEditor instead of LineEdit -> you will get most of those features for free Wink

Honza


Thank you once again Honza. Didn't even know that CodeEditor class existed. Didn't actually explore theIDE package up until you mention the CodeEditor. Interestingly CodeEditor is based on LineEdit. I have to read up on TextCtrl to understand LineEdit to understand CodeEditor. Thanks for the guidence, let me read up on them.

regards
Navi.
Previous Topic: moveable question
Next Topic: Changing EditFields from header files
Goto Forum:
  


Current Time: Fri Apr 26 16:19:06 CEST 2024

Total time taken to generate the page: 0.03237 seconds