Home » U++ Library support » LineEdit, EditFields, DocEdit » need some expert advice to extend the LineEdit
need some expert advice to extend the LineEdit [message #38128] |
Sun, 02 December 2012 14:54 |
navi
Messages: 107 Registered: February 2012 Location: Sydney, Australia
|
Experienced Member |
|
|
I need some expert advice/pointer. I am trying to extend the LineEdit Class to add an option for displaying line number on the left of the each line possible with PAPER_READONLY color background.
So far I have I have extended my class as follows:
class LineEditExtended : public LineEdit{
public:
virtual void Paint(Draw& w);
void Paint0(Draw& w);
Rect DropCaret();
...}
As I do not wish the break the original LineEdit Ctrl, I am overriding the above function then copy/pasting the content from LineEdit.cpp and modifying it. I have modified the above function codes to use x-offset “new_x” variable to use as "x origin" or "left pos" for drawing texts and regular backgrounds. My plan is to create some empty space on the left of the LineEdit ctrl vie making it start drawing from x-offset. Once that is achieved then I plan to add my own codes to draw the line number on that empty space as read-only non-selectable text.
So far I have manage to create some empty space on the left but have broken the 'Caret' placement on the text. I am still trying to fix the issue but finding quite hard to understand the mechanism of the TextCtrl/LineEdit Ctrl.
I have thought of doing it in other ways like making a compound ctrl with either two LineEdit or a "Label" ctrl and a LineEdit ctrl. Where one of the LineEdit or Label ctrl will be used to print the line numbers. In this way, I am not quite sure how I might be able to deal with scrolling and new lines.
I have tried investigating the CodeEditor Ctrl to see how it implemented line number. I concluded it does it through the friend class EditorBar. I am still trying to understand how.
Attached with this post is a test project using the LineEditExtended Ctrl.
|
|
|
Goto Forum:
Current Time: Fri Nov 01 01:05:08 CET 2024
Total time taken to generate the page: 0.05659 seconds
|