Home » U++ Library support » TreeCtrl » Problem displaying labels under ubuntu 7.10
Problem displaying labels under ubuntu 7.10 [message #15088] |
Sat, 29 March 2008 17:05  |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Thanks for the 2008.2 beta for linux 
My code compiles and runs fine apart from a few display problems. I use a drag and drop option tree and whilst I can see the option control and the image, the text gets hidden behind the option and is limited to the client space of the option control.
I have reproduced the problem by adapting the DND tree control example
EDIT: this code runs perfectly under Windows XP, just not under ubuntu 7.10
#include "CtrlLib/CtrlLib.h"
using namespace Upp;
struct App : TopWindow {
TreeCtrl tree;
Option options[10000];
typedef App CLASSNAME;
void DropInsert(int parent, int ii, PasteClip& d)
{
tree.AdjustAction(parent, d);
if(AcceptInternal<TreeCtrl>(d, "mytreedrag")) {
tree.InsertDrop(parent, ii, d);
tree.SetFocus();
return;
}
if(AcceptText(d)) {
tree.SetCursor(tree.Insert(parent, ii, Image(), GetString(d)));
tree.SetFocus();
return;
}
}
void Drag()
{
if(tree.DoDragAndDrop(InternalClip(tree, "mytreedrag"),
tree.GetDragSample()) == DND_MOVE)
tree.RemoveSelection();
}
App() {
Add(tree.SizePos());
Vector<int> parent, parent2;
parent.Add(0);
tree.SetRoot(Image(), "The Tree");
for(int i = 1; i < 10000; i++)
{
TreeCtrl::Node node(CtrlImg::File(),options[i],20);
node.Set(FormatIntRoman(i, true));
parent.Add(tree.Add(parent[rand() % parent.GetCount()],node));
// parent.Add(tree.Add(parent[rand() % parent.GetCount()], Image(),
// FormatIntRoman(i, true)));
if((rand() & 3) == 0)
tree.Open(parent.Top());
}
tree.Open(0);
tree.WhenDropInsert = THISBACK(DropInsert);
tree.WhenDrag = THISBACK(Drag);
tree.MultiSelect();
Sizeable();
}
};
GUI_APP_MAIN
{
App().Run();
}
[Updated on: Sun, 30 March 2008 03:02] Report message to a moderator
|
|
|
|
Re: Problem displaying labels under ubuntu 7.10 [message #15180 is a reply to message #15178] |
Mon, 07 April 2008 19:24   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I believe the problem is probably linked to the changes suggested here but I'm not sure why it would only affect Ubuntu.
I think the problem might be the change to TreeCtrl::Item::GetValueSize. Unfortunately I can't test this on Ubuntu at the mo, but if you want a quick fix I can suggest 2 changes that might fix it:
Size TreeCtrl::Item::GetValueSize() const
{
return display ? display->GetStdSize(value) : StdDisplay().GetStdSize(value);
}
Size TreeCtrl::Item::GetCtrlSize() const
{
return IsNull(size) ? (ctrl ? ctrl->GetStdSize() : Size(0, 0)) : size;
}
Size TreeCtrl::Item::GetSize() const
{
Size sz = GetValueSize();
Size csz = GetCtrlSize();
sz += Size(2 * margin, 2 * margin);
Size isz = image.GetSize();
sz.cx += isz.cx;
sz.cy = max(sz.cy, isz.cy);
sz.cx += csz.cx;
sz.cy = max(sz.cy, csz.cy);
return sz;
}
and then in TreeCtrl::Paint you need to add:
if(m.ctrl)
x += m.GetCtrlSize().cx;
after the 'dword st;' line (near the end).
The problem with TreeCtrl is that everyone seems to find new and interesting ways of breaking it and the fixes always break something else . So I can't guarantee that these changes will work for everyone but it works for both reference examples, your example and the one from the thread linked above.
James
[Updated on: Wed, 09 April 2008 09:57] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 13:14:19 CEST 2025
Total time taken to generate the page: 0.00734 seconds
|