|
|
Home » U++ Library support » TreeCtrl » OptionTree - something missing? [FIXED]
OptionTree - something missing? [FIXED] [message #5437] |
Thu, 21 September 2006 16:59 |
James Thomas
Messages: 26 Registered: June 2006
|
Promising Member |
|
|
Currently there doesn't seem to be a way of correctly configuring the OptionTree control from code, if you set one of the options it's parent does not get correctly updated.
In the example below I set an option using two different methods and neither results in a change to the parent nodes state (it should turn grey).
#include <CtrlLib/CtrlLib.h>
class AWindow : public TopWindow
{
public:
typedef AWindow CLASSNAME;
Option _optA, _optAA, _optAAA, _optAAB, _optAAC;
OptionTree _tree;
Button _btn;
AWindow()
{
_tree.SetRoot(_optA, "Root");
_tree.Add(0, _optAA, "Node");
_tree.Add(1, _optAAA, "Leaf 1");
_tree.Add(1, _optAAB, "Leaf 2");
_tree.Add(1, _optAAC, "Leaf 3");
_tree.LeftPosZ(0, 140).TopPosZ(0, 164);
_btn.LeftPosZ(0, 140).TopPosZ(164, 20);
_btn <<= THISBACK(ButtonPush);
Add(_tree);
Add(_btn);
_tree.Set(3, 1); // Set through the TreeCtrl::Set - no call to SetOption
}
void ButtonPush()
{
_optAAC.Set(1); // Set using the Option ctrl - also no call to SetOption
}
};
GUI_APP_MAIN
{
AWindow w;
w.Run();
}
The work of setting the parent node is done in the OptionTree::SetOption function, which never gets called. I can understand that setting the option directly probably shouldn't work, but calling the Set function should. Perhaps there needs to be an override of TreeCtrl::Set() so that SetOption can be called, but there may be a more elegant way.
Strangely I think this used to work in release 602 because I'm sure I would have noticed, but I can't find any relevant changes to Option or OptionTree so I could be wrong.
EDIT: I'm using 605 RC, but I've looked at the dev source and the problem looks like it's still there.
[Updated on: Fri, 22 September 2006 11:57] Report message to a moderator
|
|
|
|
|
|
Re: OptionTree - something missing? [message #8912 is a reply to message #5452] |
Sat, 07 April 2007 06:18 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
I'm using it too and I have a question:
is it possible to select items as well as checking and unchecking the options?
I have a GIS style interface in which I use the options to set visibility but I also want to be able to have a selected item. at the moment clicking on the item activates the option. would it be possible to configure it so that the user has to click on the actual option box and leave the item text to detect selection?
great control - very easy to use. I'm just one of those people who is never happy
Nick
p.s. any examples of changing the item hierarchy by dragging and dropping items?
[Updated on: Sat, 07 April 2007 06:20] Report message to a moderator
|
|
|
|
|
|
|
|
Re: OptionTree - something missing? [message #9025 is a reply to message #9016] |
Fri, 13 April 2007 03:58 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
ok think i got that but how does run stop? I want it to stop when the left mouse button gets released and then I want to know where the mouse is so I can check for drop targets.
So far, the mouse cursor doesnt change when am dragging and the run doesnt appear to have any stop condition. Do I need to override LocalLoop?
Nick
class LayerTree : public TreeCtrl
{
public:
typedef LayerTree CLASSNAME;
virtual void RightDown(Point p, dword flags);
virtual void LeftDown(Point p, dword flags);
int GetNodeIDAt(Point p);
};
....
void LayerTree::LeftDown(Point p, dword flags)
{
// here we implement drag and drop for nodes in the tree view
// first see if there is a node at this point p
int i,id=GetNodeIDAt(p);
if(id<0)
return; // didnt click on a node
Rect rc = GetNode(id).ctrl->GetRect();
// draw the node into an image
// sample the tree ctrls view in this rectangle and make an image
Size sz(rc.Width(),rc.Height());
ImageDraw w(sz);
GetNode(id).ctrl->DrawCtrl(w);
Image img = w;
// start local loop and see where it ends
RectTracker rt(*this);
// use the image as a cursor
rt.SetCursorImage(img);
rt.SetMaster(*this);
rt.Run();
// rt.Track(rc,ALIGN_CENTER,ALIGN_CENTER);
}
int LayerTree::GetNodeIDAt(Point p)
{
// step through all nodes in the tree
// and see if one of them contains p
int id,n=GetLineCount(); //all (visible) items
Ctrl* ptr;
Rect rc;
for(int i=0;i<n;i++)
{
id = GetItemAtLine(i);
TreeCtrl::Node node = GetNode(id);
ptr = node.ctrl;
if(ptr)
{
rc = ptr->GetRect();
if(rc.Contains(p))
return id;
}
}
return -1;
}
hmmm, should have start my own thread really...
I tried the following
void LayerTree::LeftUp(Point p, dword flags)
{
m_pRT->EndLoop(); // tried this with recttracker as member pointer
EndLoop(); // and this
}
and nothing appears to have any effect. Am still quite new to UPP and it seems I still have a lot to learn. There does appear to be a loop starting. But I dont understand why the cursor does not change and I don't understand why the master (LayerCtrl) cannot intercept LeftUp and stop the loop. I'm missing something fundamental and obvious it seems.
I think this is the most complex part of my GUI but I need to know it can be done before I go further.
Cheers,
Nick
[Updated on: Fri, 13 April 2007 05:56] Report message to a moderator
|
|
|
|
Re: OptionTree - something missing? [message #9038 is a reply to message #9027] |
Sun, 15 April 2007 06:58 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
thanks for the continuing help and advice.
I tried PointLooper and it almost works but not quite in that it will paint the option ctrl but the rest is always black and too small in any case. (Is there some limit on the size of the cursor?)
However, I think I know what direction to take. I am attempting to derive a new class from RectTracker so I can customise the way it draws. So far its messy but promising
Cheers,
Nick
[Updated on: Sun, 15 April 2007 07:17] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Jun 10 12:33:44 CEST 2024
Total time taken to generate the page: 0.01080 seconds
|
|
|