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 » PopUpTree related questions
PopUpTree related questions [message #20475] Fri, 20 March 2009 13:17 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
1. PopUpTree.PopUp doesn't seem to work only if I inserted the tree in a TopWindows, possibly any container. If I don't add it and I call PopUp without coordinates, I couldn't get it to display with any other height except zero. Also x, top and bottom seem to be screen relative, not parent relative, which is in contrast to the call without coordinates. Is this a control that is not supposed to be used directly?

2. What is this control good for. Clicking or opening and item in the tree closes the popup. I can imagine useful scenarios where selecting a tree item closes the popup, but not one where closing/opening an item.

3. Should I document this?
Re: PopUpTree related questions [message #20599 is a reply to message #20475] Wed, 25 March 2009 10:47 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
cbpporter wrote on Fri, 20 March 2009 12:17

1. PopUpTree.PopUp doesn't seem to work only if I inserted the tree in a TopWindows, possibly any container. If I don't add it and I call PopUp without coordinates, I couldn't get it to display with any other height except zero. Also x, top and bottom seem to be screen relative, not parent relative, which is in contrast to the call without coordinates. Is this a control that is not supposed to be used directly?

2. What is this control good for. Clicking or opening and item in the tree closes the popup. I can imagine useful scenarios where selecting a tree item closes the popup, but not one where closing/opening an item.

3. Should I document this?


What an interesting ctrl Smile

1- It seems to me from looking at the code that this was originally designed to used as part of something like a DropChoice or perhaps independently as part of something else. Once you understand this it becomes a bit clearer.
- Like any popup it shouldn't work if it has a parent, as that makes no sense.
- The parameters to PopUp aren't obvious, but make sense if you were using at as a DropChoice:
x: x position
top: place to open upwards if there is insufficient space to open downwards (usually top of owner ctrl)
bottom: position to slide open downwards (usually bottom of owner ctrl)
width: popup width (usually width of owner ctrl)
All coordinates are relative to the screen because a popup is a top ctrl and is positioned in screen-space.
- The height the ctrl is determined by min(maxheight, treesize), so is dependent on what you have put in it. An empty tree will display with zero height. See PopUpTree::OpenClose.

2- It is intended that the ctrl should automatically close when an item is selected. You can open/close parent nodes as long as they have Null data (maybe NoSelect will work too), but it doesn't correctly distinguish between open/close events and selection when parent node can also be selected. This is easily fixed, and I've attached my fixed files.

3 - Up to you. I can't imagine many people would have a use for this and there aren't any references to it in uppsrc.

Here is my test usage of the ctrl (added to TreeCtrlDnd reference):
	void PopTree()
	{
		pop.Clear();
		pop.NoRoot();
		Copy(pop, 0, 0, tree, 0);
		pop.MaxHeight(150);
		
		Point p = GetMousePos();
		pop.PopUp(this, p.x, p.y, p.y, 200);		
	}


Additionally the Copy function (TreeCtrl.cpp) is slightly incorrect. It should be:
int Copy(TreeCtrl& dst, int did, int i, const TreeCtrl& src, int id)
{
	TreeCtrl::Node x = src.GetNode(id);
	x.ctrl = NULL;
	did = dst.Insert(did, i, x);
	for(int i = 0; i < src.GetChildCount(id); i++)
		Copy(dst, did, i, src, src.GetChild(id, i));
	dst.Open(did, src.IsOpen(id));
	return did;
}

'dst.Open' was being called before node children were added and so was not syncing correctly (causing incorrect Ctrl sizing), so I moved it to after the for loop.

That's certainly got my brain working this morning Smile
  • Attachment: TreeCtrl.cpp
    (Size: 38.35KB, Downloaded 295 times)
  • Attachment: TreeCtrl.h
    (Size: 13.46KB, Downloaded 314 times)

[Updated on: Wed, 25 March 2009 10:51]

Report message to a moderator

Previous Topic: ArrayCtrl as a node of TreeCtrl
Next Topic: Bug crashing application in Upp2008.1
Goto Forum:
  


Current Time: Tue Aug 20 21:20:17 CEST 2019

Total time taken to generate the page: 0.00710 seconds