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 » U++ Library support » TreeCtrl » [solved] Can we get the private members of TreeCtrl made protected?
[solved] Can we get the private members of TreeCtrl made protected? [message #44753] Tue, 16 June 2015 15:59 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I created a custom TreeCtrl than only overrides Paint for prettier display of a list of trees and some members used by Paint are private.

[Updated on: Tue, 03 January 2017 11:57]

Report message to a moderator

Re: Can we get the private members of TreeCtrl made protected? [message #44756 is a reply to message #44753] Wed, 17 June 2015 09:04 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Could you show some pictures of it?

Best regards
IƱaki
Re: Can we get the private members of TreeCtrl made protected? [message #44758 is a reply to message #44756] Wed, 17 June 2015 11:10 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Sure!

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


I created a custom TreeCtrl. Normally, the tree control is designed for a single root kind of structure. Even when not displaying the root node, there is still a line pointing upwards and it looks like a tree.

My change is about making it behave like a list of trees. Each entry in that list is a root of a tree, but they do not have a parent. I also changed the way lines are displayed for children nodes, enhanced IMHO for minor aesthetics.

In my particular case, I use this tree control to display folders from a classpath. That's why some folders are amrked with an "x", to show that they are invalid.

I implemented this only changing a few lines in the TreeCtrl::Paint override.

If you wish, I can give you the exact members than need to be made protected.
  • Attachment: tree.png
    (Size: 2.45KB, Downloaded 601 times)
Re: Can we get the private members of TreeCtrl made protected? [message #44811 is a reply to message #44758] Thu, 02 July 2015 14:01 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Here is the list of things I need protected for my Paint:

protected:
	struct Item : Node {
		union {
			int            parent;
			int            freelink;
		};

		bool           free;
		bool           isopen;
		bool           sel;
		Vector<int>    child;
		int            linei;

		Size GetValueSize(const Display *treedisplay) const;
		Size GetCtrlSize() const;
		Size GetSize(const Display *treedisplay) const;

		Item() { isopen = false; linei = -1; parent = -1; canselect = true; sel = false; free = false; }
	};
	struct Line : Moveable<Line> {
		int  level;
		int  itemi;
		int  ll;
		int  y;
	};
	
	ScrollBars   sb;	
	Scroller     scroller;
	bool         nobg;
	int          levelcx;
	bool         noroot;
	Vector<Line> line;	
	Array<Item>  item;	
	int          dropitem, dropinsert;
	bool         highlight_ctrl;		
	int          cursor;
	bool         nocursor;
	bool         multiselect;
	
	const Display *display;
	
	int    FindLine(int y) const;
	const Display *GetStyle(int i, Color& fg, Color& bg, dword& st);


Re: Can we get the private members of TreeCtrl made protected? [message #44874 is a reply to message #44811] Sun, 12 July 2015 09:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I do not know. Generally, things are private to maintain narrow interface. If they become protected, they become part of interface.

OTOH, I like the functionality you propose. I suggest adding this to regular TreeCtrl as option... (files please?)

Mirek
Re: Can we get the private members of TreeCtrl made protected? [message #44883 is a reply to message #44874] Thu, 16 July 2015 10:37 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
How about this?
  • Attachment: TreeCtrl.cpp
    (Size: 35.88KB, Downloaded 240 times)
  • Attachment: TreeCtrl.h
    (Size: 15.61KB, Downloaded 520 times)
Re: Can we get the private members of TreeCtrl made protected? [message #45078 is a reply to message #44883] Fri, 28 August 2015 08:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Sorry for the delay... applied.

However:

					op -= CtrlImg::cross().GetSize() / 2;
					w.DrawImage(op.x, op.y, imgEmpty);


Should not that be rather

					op -= imgEmpty.GetSize() / 2;
					w.DrawImage(op.x, op.y, imgEmpty);


?

Also, perhaps RenderMultiRoot should call NoRoot?

I have added docs, please check them too...

Mirek

[Updated on: Fri, 28 August 2015 09:01]

Report message to a moderator

Re: Can we get the private members of TreeCtrl made protected? [message #45079 is a reply to message #45078] Fri, 28 August 2015 12:51 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Thanks!

Use any name that you think is best. I can adapt. Now if we resolve the TimeStopHR, I can use stock U++ again Smile.
Re: Can we get the private members of TreeCtrl made protected? [message #45083 is a reply to message #45079] Sat, 29 August 2015 07:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 28 August 2015 12:51
Thanks!

Use any name that you think is best. I can adapt. Now if we resolve the TimeStopHR, I can use stock U++ again Smile.


Ops, looks like I have not explained myself well... (english not being my native language).

Please, what I ask about is not about names, but semantics:

- using imgEmpty dimension for calculation in TreeCtrl::Paint instead of surrogate 'cross'

- calling ('executing') NoRoot in RenderMultiRoot (becuse I believe that you need to call NoRoot anyway to make it active).

Mirek
Re: Can we get the private members of TreeCtrl made protected? [message #45097 is a reply to message #45083] Mon, 31 August 2015 12:35 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Oh, I see now.

Using "imgEmpty" for size calculations is indeed better.

As for calling NoRoot, this will have the side effect of forcing the display of the empty node icon for all users who call NoRoot right? That's partially why I added a new flag.
Previous Topic: Node id calculation after removal ?
Next Topic: Manually set option in OptionTree
Goto Forum:
  


Current Time: Thu Apr 18 16:52:41 CEST 2024

Total time taken to generate the page: 0.02213 seconds