|
|
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 |
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 207 times)
|
|
|
|
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38047 is a reply to message #38045] |
Thu, 29 November 2012 09:44 |
|
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
Best regards,
Honza
|
|
|
|
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38053 is a reply to message #38048] |
Thu, 29 November 2012 11:13 |
|
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 #38093 is a reply to message #38090] |
Fri, 30 November 2012 09:25 |
|
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?
Honza
[Updated on: Fri, 30 November 2012 10:08] 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 |
|
navi wrote on Fri, 30 November 2012 12:19 | But you are awesome too. How do you know these things?
| Thanks Some parts I met in past (or struggled with ), 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
Honza
|
|
|
Re: hiding the vertical scrollbar of LineEdit Ctrl [message #38101 is a reply to message #38096] |
Fri, 30 November 2012 14:03 |
|
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
Honza
|
|
|
|
Goto Forum:
Current Time: Sat May 04 18:07:36 CEST 2024
Total time taken to generate the page: 0.02750 seconds
|
|
|