I noticed that the one control the gui interface is missing is the tree control. For those who don't know what I'm talking about, look here:
It basically does all the things the Windows one does. Click on the squares to show/hide the list. It's a work in progress, but it's looking pretty good so far. (By the way, it works for any font. Just so you know you aren't stuck with Xenotron.)
Get the code here: http://www.geocities.com/veylon_ii/TreeCtrl.zip
I'll add support for the event receiver so that you can know when something gets clicked and support for little icons, drag and drop, and all that jazz.
Treeview Control (GUI)
Here's the new update version of the tree control: http://www.geocities.com/veylon_ii/TreeCtrl2.zip
Now it does work with the event receiver, just like all the other controls. A sample program is included to show how to use it. Also, it does the override font (like other controls) and supports an icon font, so the plus signs can be folders or something and have different icons for different nodes.
Try it out.
Now it does work with the event receiver, just like all the other controls. A sample program is included to show how to use it. Also, it does the override font (like other controls) and supports an icon font, so the plus signs can be folders or something and have different icons for different nodes.
Try it out.
Looks nice !!!
But there is a minor bug...
If you scroll to the side, the text will go outside the treeview:
And 2 cosmetic issues:
it would be nicer if the intern size of the treeview changes when tree nodes are opened or closed...
I mean if all nodes are closed, now the box has still the space to show all nodes...
And if you scroll up/down by using the mouse wheel, the scrollbar should also scroll up/down...
But there is a minor bug...
If you scroll to the side, the text will go outside the treeview:
And 2 cosmetic issues:
it would be nicer if the intern size of the treeview changes when tree nodes are opened or closed...
I mean if all nodes are closed, now the box has still the space to show all nodes...
And if you scroll up/down by using the mouse wheel, the scrollbar should also scroll up/down...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Here is a patch to fix the drawing outside of the box:Eck! It shouldn't do that!
I'll have to at least fix it to stay inside it's box. No 1 rule of GUI objects: no going outside of the box!
Code: Select all
--- orig/CGUITreeCtrl.cpp Sun Jun 17 21:25:19 2007
+++ CGUITreeCtrl.cpp Mon Jun 18 08:06:15 2007
@@ -374,6 +374,8 @@
{
MyClip = &clientClip;
}
+ // this seems to fix the horizontal clipping problem
+ MyClip = &clientClip;
s32 IconWidth = 0;
// Get Origin
// = ItemWidth to the left of the text
@@ -448,7 +450,8 @@
{
wchar_t Txt[2] = {node->Open ? node->IconOpen : node->IconClosed, L'\0'};
IconWidth = IconFont->getDimension(Txt).Width+1;
- IconFont->draw(Txt, core::rect<s32>(Origin, Origin + core::position2d<s32>(IconWidth, ItemHeight)), col, false, true, MyClip);
+ // Use EGDC_BUTTON_TEXT color (colblk) for everything except selected text, otherwise it doesn't show properly against certain background colors
+ IconFont->draw(Txt, core::rect<s32>(Origin, Origin + core::position2d<s32>(IconWidth, ItemHeight)), colblk, false, true, MyClip);
}
else
{
@@ -467,17 +470,17 @@
// Horizontal
DrawHorizontalLine(
Origin + core::position2d<s32>(Frac18, Frac12),
- SqSize, col, MyClip);
+ SqSize, colblk, MyClip);
// Vertical
DrawVerticalLine(
Origin + core::position2d<s32>(Frac12, Frac18),
- SqSize, col, MyClip);
+ SqSize, colblk, MyClip);
}
// Draw Square (After, so it covers up and looks nice
- DrawVerticalLine(UpperLeft, SqSize, col, MyClip);
- DrawHorizontalLine(UpperLeft, SqSize, col, MyClip);
- DrawVerticalLine(UpperRight, SqSize, col, MyClip);
- DrawHorizontalLine(LowerLeft, SqSize, col, MyClip);
+ DrawVerticalLine(UpperLeft, SqSize, colblk, MyClip);
+ DrawHorizontalLine(UpperLeft, SqSize, colblk, MyClip);
+ DrawVerticalLine(UpperRight, SqSize, colblk, MyClip);
+ DrawHorizontalLine(LowerLeft, SqSize, colblk, MyClip);
IconWidth = ItemHeight;
}
}
@@ -495,7 +498,8 @@
IconWidth = IconFont->getDimension(Txt).Width+1;
}
if(node == Selected)
- video->draw2DRectangle(skin->getColor(gui::EGDC_3D_HIGH_LIGHT),core::rect<s32>(Origin + core::position2d<s32>(IconWidth,0), Origin + core::position2d<s32>(ItemHeight + Font->getDimension(node->Text.c_str()).Width+IconWidth-ItemHeight+1,ItemHeight)), &clientClip);
+// video->draw2DRectangle(skin->getColor(gui::EGDC_3D_HIGH_LIGHT),core::rect<s32>(Origin + core::position2d<s32>(IconWidth,0), Origin + core::position2d<s32>(ItemHeight + Font->getDimension(node->Text.c_str()).Width+IconWidth-ItemHeight+1,ItemHeight)), &clientClip);
+ video->draw2DRectangle(skin->getColor(gui::EGDC_HIGH_LIGHT),core::rect<s32>(Origin + core::position2d<s32>(IconWidth,0), Origin + core::position2d<s32>(ItemHeight + Font->getDimension(node->Text.c_str()).Width+IconWidth-ItemHeight+1,ItemHeight)), &clientClip);
Font->draw(node->Text.c_str(),
core::rect<s32>
( AbsoluteRect.UpperLeftCorner.X + (Indent-1)*ItemHeight + IconWidth + 2,
@@ -557,7 +561,12 @@
// Line can't be draw here
if(ClipRect)
{
- if(!ClipRect->isPointInside(start))
+// this fixes the 'missing vert lines in top row' prob
+// if(!ClipRect->isPointInside(start))
+// return false;
+ rect<s32> ExpClipRect( ClipRect->UpperLeftCorner - position2d<s32>(1,1),
+ ClipRect->LowerRightCorner + position2d<s32>(1,1));
+ if(!ExpClipRect.isPointInside(start))
return;
if(start.Y + length > ClipRect->LowerRightCorner.Y)
length = ClipRect->LowerRightCorner.Y - start.Y;
@@ -901,3 +910,4 @@
{
return OverrideFont;
}
+