Added StarSonata GUI patch from the tracker, const corrected. Fixed some bugs and changed the style and behaviour of the tabs. Tables aren't fully tested and don't serialize properly yet.

Changed gui editor to show off and test the new tab features.
Updated project files and makefile, have only tested vc8 and dev-cpp. Didn't know how to do the OSX project so I'll leave it for Dean.
Moved EGUI_ALIGNMENT into separate header.
Added getArea and getVolume for bounding boxes, no real reason for them.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1124 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2007-12-22 07:49:29 +00:00
parent 6c7fa2438e
commit aab1dfa7cb
27 changed files with 1959 additions and 332 deletions

View File

@ -2,9 +2,9 @@
Changes in version 1.5 (... 2008)
- Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a ressource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL. D3D will follow soon.
Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To sue this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame.
Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To use this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame.
- MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using teh getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types.
- MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using the getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types.
- GLSL changes for setting arrays. Also allow for only pixel or vertex shader to be set.
@ -24,6 +24,9 @@ Changes in version 1.5 (... 2008)
Removed the seperate rendering states for quake3 Shader Scene Nodes.
Nodes are now solid or transparent. ( but still more states are needed )
- GUI:
Finally added table control and TabControl additions from StarSonata team.
-------------------------------------------
Changes in version 1.4 (30.11.2007)

37
include/EGUIAlignment.h Normal file
View File

@ -0,0 +1,37 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __E_GUI_ALIGNMENT_H_INCLUDED__
#define __E_GUI_ALIGNMENT_H_INCLUDED__
namespace irr
{
namespace gui
{
enum EGUI_ALIGNMENT
{
//! Aligned to parent's top or left side (default)
EGUIA_UPPERLEFT=0,
//! Aligned to parent's bottom or right side
EGUIA_LOWERRIGHT,
//! Aligned to the center of parent
EGUIA_CENTER,
//! Stretched to fit parent
EGUIA_SCALE
};
//! Names for alignments
const c8* const GUIAlignmentNames[] =
{
"upperLeft",
"lowerRight",
"center",
"scale",
0
};
} // namespace gui
} // namespace irr
#endif // __E_GUI_ALIGNMENT_H_INCLUDED__

View File

@ -59,6 +59,9 @@ enum EGUI_ELEMENT_TYPE
//! A scroll bar (IGUIScrollBar)
EGUIET_SCROLL_BAR,
//! A spin box (IGUISpinBox)
EGUIET_SPIN_BOX,
//! A static text (IGUIStaticText)
EGUIET_STATIC_TEXT,
@ -68,15 +71,15 @@ enum EGUI_ELEMENT_TYPE
//! A tab control
EGUIET_TAB_CONTROL,
//! A Table
EGUIET_TABLE,
//! A tool bar (IGUIToolBar)
EGUIET_TOOL_BAR,
//! A window
EGUIET_WINDOW,
//! A spin box (IGUISpinBox)
EGUIET_SPIN_BOX,
//! Not an element, amount of elements in there
EGUIET_COUNT,
@ -107,12 +110,13 @@ const c8* const GUIElementTypeNames[] =
"messageBox",
"modalScreen",
"scrollBar",
"spinBox",
"staticText",
"tab",
"tabControl",
"table",
"toolBar",
"window",
"spinBox",
0
};
@ -121,3 +125,6 @@ const c8* const GUIElementTypeNames[] =
#endif

View File

@ -150,7 +150,12 @@ namespace irr
EGET_COMBO_BOX_CHANGED,
//! The value of a spin box has changed
EGET_SPINBOX_CHANGED
EGET_SPINBOX_CHANGED,
//! A table has changed
EGET_TABLE_CHANGED,
EGET_TABLE_HEADER_CHANGED,
EGET_TABLE_SELECTED_AGAIN
};
} // end namespace gui
@ -261,3 +266,6 @@ public:
#endif

View File

@ -11,6 +11,7 @@
#include "irrString.h"
#include "IEventReceiver.h"
#include "EGUIElementTypes.h"
#include "EGUIAlignment.h"
#include "IAttributes.h"
namespace irr
@ -20,28 +21,6 @@ namespace gui
class IGUIEnvironment;
enum EGUI_ALIGNMENT
{
//! Aligned to parent's top or left side (default)
EGUIA_UPPERLEFT=0,
//! Aligned to parent's bottom or right side
EGUIA_LOWERRIGHT,
//! Aligned to the center of parent
EGUIA_CENTER,
//! Scaled within its parent
EGUIA_SCALE
};
//! Names for alignments
const c8* const GUIAlignmentNames[] =
{
"upperLeft",
"lowerRight",
"center",
"scale",
0
};
//! Base class of all GUI elements.
class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver
{

View File

@ -49,6 +49,7 @@ class IGUIEditBox;
class IGUISpinBox;
class IGUITabControl;
class IGUITab;
class IGUITable;
class IGUIContextMenu;
class IGUIComboBox;
class IGUIToolBar;
@ -369,6 +370,10 @@ public:
virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a table to the environment
virtual IGUITable* addTable(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) = 0;
//! Returns the default element factory which can create all built in elements
virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0;
@ -426,3 +431,6 @@ public:
#endif

View File

@ -6,6 +6,7 @@
#define __I_GUI_SKIN_H_INCLUDED__
#include "IAttributeExchangingObject.h"
#include "EGUIAlignment.h"
#include "SColor.h"
#include "rect.h"
@ -464,7 +465,7 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect, const core::rect<s32>* clip=0) = 0;
const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 0;
//! draws a tab control body
/** \param element: Pointer to the element which wishes to draw this. This parameter
@ -475,7 +476,7 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip=0) = 0;
const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 0;
//! draws an icon, usually from the skin's sprite bank
/** \param element: Pointer to the element which wishes to draw this icon.
@ -513,3 +514,6 @@ namespace gui
#endif

View File

@ -7,6 +7,7 @@
#include "IGUIElement.h"
#include "SColor.h"
#include "IGUISkin.h"
namespace irr
{
@ -39,6 +40,12 @@ namespace gui
//! returns the color of the background
virtual video::SColor getBackgroundColor() const = 0;
//! sets the color of the text
virtual void setTextColor(video::SColor c) = 0;
//! gets the color of the text
virtual video::SColor getTextColor() const = 0;
};
//! A standard tab control
@ -77,6 +84,28 @@ namespace gui
//! Returns which tab is currently active
virtual s32 getActiveTab() const = 0;
//! Set the height of the tabs
virtual void setTabHeight( s32 height ) = 0;
//! Get the height of the tabs
/** return Returns the height of the tabs */
virtual s32 getTabHeight() const = 0;
//! Set the alignment of the tabs
//! Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) = 0;
//! Get the alignment of the tabs
/** return Returns the alignment of the tabs */
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0;
//! Set the extra width added to tabs on each side of the text
virtual void setTabExtraWidth( s32 extraWidth ) = 0;
//! Get the extra width added to tabs on each side of the text
/** return Returns the extra width of the tabs */
virtual s32 getTabExtraWidth() const = 0;
};
@ -85,3 +114,7 @@ namespace gui
#endif

125
include/IGUITable.h Normal file
View File

@ -0,0 +1,125 @@
// Copyright (C) 2003-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// 07.10.2005 - Multicolor-Listbox added by A. Buschhüter (Acki)
// A_Buschhueter@gmx.de
#ifndef __I_GUI_TABLE_H_INCLUDED__
#define __I_GUI_TABLE_H_INCLUDED__
#include "IGUIElement.h"
#include "irrTypes.h"
#include "SColor.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
enum EGUI_ORDERING_MODE
{
//! Order the elements from the smallest to the largest.
EGOM_ASCENDING,
//! Order the elements from the largest to the smallest.
EGOM_DESCENDING,
//! this value is not used, it only specifies the amount of default ordering types
//! available.
EGOM_COUNT
};
class IGUIFont;
//! Default list box GUI element.
class IGUITable : public IGUIElement
{
public:
//! constructor
IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
//! Adds a column
virtual void addColumn(const wchar_t* caption, s32 id=-1) = 0;
//! Returns the number of columns in the table control
virtual s32 getColumncount() const = 0;
//! Makes a column active. This will trigger an ordering process.
/** \param idx: The id of the column to make active.
\return Returns true if successful. */
virtual bool setActiveColumn(s32 idx) = 0;
//! Returns which header is currently active
virtual s32 getActiveColumn() const = 0;
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
//! set a column width
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
//! This tells the table control wether is should send a EGET_TABLE_HEADER_CHANGED message or not when
//! a column header is clicked. If set to false, the table control will use a default alphabetical ordering scheme.
/** \param columnIndex: The index of the column header.
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
virtual void setColumnCustomOrdering(u32 columnIndex, bool state) = 0;
//! Returns which row is currently selected
virtual s32 getSelected() const = 0;
//! Returns amount of rows in the tabcontrol
virtual s32 getRowcount() const = 0;
//! adds a row to the table
/** \param rowIndex: zero based index of rows. The row will be inserted at this
position, if a row already exist there, it will be placed after it. If the row
is larger than the actual number of row by more than one, it won't be created.
Note that if you create a row that's not at the end, there might be performance issues*/
virtual void addRow(u32 rowIndex) = 0;
//! Remove a row from the table
virtual void removeRow(u32 rowIndex) = 0;
//! clears the table rows, but keeps the columns intact
virtual void clearRows() = 0;
//! Swap two row positions. This is useful for a custom ordering algo.
virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;
//! This tells the table to start ordering all the rows. You need to explicitly
//! tell the table to re order the rows when a new row is added or the cells data is
//! changed. This makes the system more flexible and doesn't make you pay the cost of
//! ordering when adding a lot of rows.
virtual void orderRows() = 0;
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text) = 0;
//! Set the text of a cell, and set a color of this cell.
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color) = 0;
//! Set the data of a cell
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;
//! Set the color of a cell text
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;
//! Get the text of a cell
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;
//! Get the data of a cell
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;
//! clears the table, deletes all items in the table
virtual void clear() = 0;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -274,6 +274,20 @@ class aabbox3d
(other.MaxEdge*inv) + (MaxEdge*d));
}
//! returns the volume enclosed by the box in cubed units
T getVolume() const
{
const vector3d<T> e = getExtent();
return e.X * e.Y * e.Z;
}
//! returns the surface area of the box in squared units
T getArea() const
{
const vector3d<T> e = getExtent();
return 2*(e.X*e.Y + e.X*e.Z + e.Y*e.Z);
}
// member variables
vector3d<T> MinEdge;

View File

@ -78,6 +78,7 @@
#include "IGUISpriteBank.h"
#include "IGUIStaticText.h"
#include "IGUITabControl.h"
#include "IGUITable.h"
#include "IGUIToolbar.h"
#include "IGUIWindow.h"
#include "IImage.h"
@ -331,3 +332,4 @@ namespace irr
#endif

View File

@ -7,26 +7,26 @@
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IGUIButton.h"
#include "IGUICheckBox.h"
#include "IGUIColorSelectDialog.h"
#include "IGUIComboBox.h"
#include "IGUIContextMenu.h"
#include "IGUIEditBox.h"
#include "IGUISpinBox.h"
#include "IGUIFileOpenDialog.h"
#include "IGUIColorSelectDialog.h"
#include "IGUIInOutFader.h"
#include "IGUIImage.h"
#include "IGUIListBox.h"
#include "IGUIMeshViewer.h"
#include "IGUIScrollBar.h"
#include "IGUISpinBox.h"
#include "IGUIStaticText.h"
#include "IGUITabControl.h"
#include "IGUITable.h"
#include "IGUIToolbar.h"
#include "IGUIWindow.h"
#include <string.h>
namespace irr
{
namespace gui
@ -80,6 +80,8 @@ IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IG
return Environment->addTab(core::rect<s32>(0,0,100,100),parent);
case EGUIET_TAB_CONTROL:
return Environment->addTabControl(core::rect<s32>(0,0,100,100),parent);
case EGUIET_TABLE:
return Environment->addTable(core::rect<s32>(0,0,100,100), parent);
case EGUIET_TOOL_BAR:
return Environment->addToolBar(parent);
case EGUIET_WINDOW:

View File

@ -32,6 +32,7 @@
#include "CGUIComboBox.h"
#include "CGUIMenu.h"
#include "CGUIToolBar.h"
#include "CGUITable.h"
#include "CDefaultGUIElementFactory.h"
#include "IWriteFile.h"
@ -984,6 +985,12 @@ IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect<s
return bar;
}
IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, bool drawBackground)
{
CGUITable* b = new CGUITable(this, parent ? parent : this, id, rectangle, true, drawBackground, false);
b->drop();
return b;
}
//! Adds an image element.
IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d<s32> pos,
@ -1495,3 +1502,4 @@ IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs,
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -155,6 +155,10 @@ public:
virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1);
//! Adds a table element.
virtual IGUITable* addTable(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false);
//! sets the focus to an element
virtual bool setFocus(IGUIElement* element);
@ -292,3 +296,4 @@ private:
#endif // __C_GUI_ENVIRNMENT_H_INCLUDED__

View File

@ -680,41 +680,79 @@ implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
void CGUISkin::draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& frameRect,
const core::rect<s32>* clip)
const core::rect<s32>& frameRect, const core::rect<s32>* clip, EGUI_ALIGNMENT alignment)
{
if (!Driver)
return;
core::rect<s32> tr = frameRect;
tr.LowerRightCorner.X -= 2;
tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
tr.UpperLeftCorner.X += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
if ( alignment == EGUIA_UPPERLEFT )
{
tr.LowerRightCorner.X -= 2;
tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
tr.UpperLeftCorner.X += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw left highlight
tr = frameRect;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
tr.UpperLeftCorner.Y += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw left highlight
tr = frameRect;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
tr.UpperLeftCorner.Y += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw grey background
tr = frameRect;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y += 1;
tr.LowerRightCorner.X -= 2;
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
// draw grey background
tr = frameRect;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y += 1;
tr.LowerRightCorner.X -= 2;
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
// draw right middle gray shadow
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
// draw right middle gray shadow
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
}
else
{
tr.LowerRightCorner.X -= 2;
tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
tr.UpperLeftCorner.X += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw left highlight
tr = frameRect;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
tr.LowerRightCorner.Y -= 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw grey background
tr = frameRect;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y -= 1;
tr.LowerRightCorner.X -= 2;
tr.LowerRightCorner.Y -= 1;
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
// draw right middle gray shadow
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
//tr.LowerRightCorner.Y -= 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X += 1;
tr.LowerRightCorner.Y -= 1;
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
}
tr.LowerRightCorner.X += 1;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y += 1;
Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
}
@ -727,46 +765,85 @@ implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw.
\param clip: Clip area. */
void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip)
const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, EGUI_ALIGNMENT alignment)
{
if (!Driver)
return;
core::rect<s32> tr = rect;
if ( tabHeight == -1 )
tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT);
// draw border.
if (border)
{
// draw left hightlight
tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
if ( alignment == EGUIA_UPPERLEFT )
{
// draw left hightlight
tr.UpperLeftCorner.Y += tabHeight + 2;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw right shadow
tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
// draw right shadow
tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
// draw lower shadow
tr = rect;
tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
// draw lower shadow
tr = rect;
tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
}
else
{
// draw left hightlight
tr.LowerRightCorner.Y -= tabHeight + 2;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
// draw right shadow
tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
// draw lower shadow
tr = rect;
tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
}
}
if (background)
{
tr = rect;
tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
tr.LowerRightCorner.X -= 1;
tr.UpperLeftCorner.X += 1;
tr.LowerRightCorner.Y -= 1;
if ( alignment == EGUIA_UPPERLEFT )
{
tr = rect;
tr.UpperLeftCorner.Y += tabHeight + 2;
tr.LowerRightCorner.X -= 1;
tr.UpperLeftCorner.X += 1;
tr.LowerRightCorner.Y -= 1;
}
else
{
tr = rect;
tr.UpperLeftCorner.X += 1;
tr.UpperLeftCorner.Y -= 1;
tr.LowerRightCorner.X -= 1;
tr.LowerRightCorner.Y -= tabHeight + 2;
//tr.UpperLeftCorner.X += 1;
}
if (!UseGradient)
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
else
{
const video::SColor c1 = getColor(EGDC_3D_FACE);
const video::SColor c2 = getColor(EGDC_3D_SHADOW);
video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = getColor(EGDC_3D_SHADOW);
Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip);
}
}
@ -856,3 +933,4 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -164,8 +164,7 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);
//! draws a tab control body
/** \param element: Pointer to the element which wishes to draw this. This parameter
@ -175,10 +174,8 @@ namespace gui
\param background: Specifies if the background should be drawn.
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DTabBody(IGUIElement* element, bool border,
bool background,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);
//! draws an icon, usually from the skin's sprite bank
/** \param element: Pointer to the element which wishes to draw this icon.
@ -244,3 +241,4 @@ namespace gui
#endif

View File

@ -5,6 +5,7 @@
#include "CGUITabControl.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIButton.h"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIFont.h"
@ -31,6 +32,12 @@ CGUITab::CGUITab(s32 number, IGUIEnvironment* environment,
#ifdef _DEBUG
setDebugName("CGUITab");
#endif
IGUISkin* skin = environment->getSkin();
if (skin)
TextColor = skin->getColor(EGDC_BUTTON_TEXT);
else
TextColor.set(255,0,0,0);
}
@ -77,6 +84,16 @@ void CGUITab::setBackgroundColor(video::SColor c)
BackColor = c;
}
//! sets the color of the text
void CGUITab::setTextColor(video::SColor c)
{
TextColor = c;
}
video::SColor CGUITab::getTextColor() const
{
return TextColor;
}
//! returns true if the tab is drawing its background, false if not
bool CGUITab::isDrawingBackground() const
@ -98,9 +115,10 @@ void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteO
{
IGUITab::serializeAttributes(out,options);
out->addInt ("TabNumber", Number);
out->addInt ("TabNumber", Number);
out->addBool ("DrawBackground", DrawBackground);
out->addColor ("BackColor", BackColor);
out->addColor ("TextColor", TextColor);
}
@ -113,6 +131,7 @@ void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrite
setNumber(in->getAttributeAsInt("TabNumber"));
setDrawBackground(in->getAttributeAsBool("DrawBackground"));
setBackgroundColor(in->getAttributeAsColor("BackColor"));
setTextColor(in->getAttributeAsColor("TextColor"));
if (Parent && Parent->getType() == EGUIET_TAB_CONTROL)
{
@ -127,16 +146,60 @@ void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrite
// Tabcontrol
// ------------------------------------------------------------------
//! destructor
//! constructor
CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
IGUIElement* parent, const core::rect<s32>& rectangle,
bool fillbackground, bool border, s32 id)
: IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1),
Border(border), FillBackground(fillbackground)
Border(border), FillBackground(fillbackground), ScrollControl(false), TabHeight(0), VerticalAlignment(EGUIA_UPPERLEFT),
UpButton(0), DownButton(0), TabMaxWidth(0), CurrentScrollTabIndex(0), TabExtraWidth(20)
{
#ifdef _DEBUG
setDebugName("CGUITabControl");
#endif
#endif
video::SColor color(255,255,255,255);
IGUISkin* skin = Environment->getSkin();
IGUISpriteBank* sprites = 0;
TabHeight = 32;
if (skin)
{
sprites = skin->getSpriteBank();
color = skin->getColor(EGDC_WINDOW_SYMBOL);
TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
}
UpButton = Environment->addButton(core::rect<s32>(0,0,10,10), this);
if (UpButton)
{
UpButton->setSpriteBank(sprites);
UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color);
UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color);
UpButton->setVisible(false);
UpButton->setSubElement(true);
UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
UpButton->setOverrideFont(Environment->getBuiltInFont());
UpButton->grab();
}
DownButton = Environment->addButton(core::rect<s32>(0,0,10,10), this);
if (DownButton)
{
DownButton->setSpriteBank(sprites);
DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color);
DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color);
DownButton->setVisible(false);
DownButton->setSubElement(true);
DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
DownButton->setOverrideFont(Environment->getBuiltInFont());
DownButton->grab();
}
setTabVerticalAlignment(EGUIA_UPPERLEFT);
}
@ -146,6 +209,12 @@ CGUITabControl::~CGUITabControl()
for (s32 i=0; i<(s32)Tabs.size(); ++i)
if (Tabs[i])
Tabs[i]->drop();
if (UpButton)
UpButton->drop();
if (DownButton)
DownButton->drop();
}
@ -156,16 +225,28 @@ IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id)
if (!skin)
return 0;
s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
core::rect<s32> r(1,tabheight,
AbsoluteRect.getWidth()-1,
AbsoluteRect.getHeight()-1);
core::rect<s32> r;
if ( VerticalAlignment == EGUIA_UPPERLEFT )
{
r.UpperLeftCorner.X = 1;
r.UpperLeftCorner.Y = TabHeight;
CGUITab* tab = new CGUITab(Tabs.size(), Environment, this,
r, id);
tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
r.LowerRightCorner.X = AbsoluteRect.getWidth()-1;
r.LowerRightCorner.Y = AbsoluteRect.getHeight()-1;
}
else
{
r.UpperLeftCorner.X = 1;
r.UpperLeftCorner.Y = 1;
r.LowerRightCorner.X = AbsoluteRect.getWidth()-1;
r.LowerRightCorner.Y = AbsoluteRect.getHeight()-TabHeight;
}
CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, r, id);
tab->setText(caption);
tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
tab->setVisible(false);
Tabs.push_back(tab);
@ -175,6 +256,8 @@ IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id)
tab->setVisible(true);
}
recalculateScrollBar();
return tab;
}
@ -241,16 +324,34 @@ bool CGUITabControl::OnEvent(const SEvent& event)
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (event.GUIEvent.Caller == UpButton)
{
scrollLeft();
return true;
}
else if (event.GUIEvent.Caller == DownButton)
{
scrollRight();
return true;
}
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
Environment->setFocus(this);
return true;
//case EMIE_LMOUSE_PRESSED_DOWN:
// Environment->setFocus(this);
// return true;
case EMIE_LMOUSE_LEFT_UP:
Environment->removeFocus(this);
selectTab(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y));
return true;
if (selectTab(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y)))
return true;
break;
default:
break;
}
@ -262,20 +363,48 @@ bool CGUITabControl::OnEvent(const SEvent& event)
return Parent ? Parent->OnEvent(event) : false;
}
void CGUITabControl::selectTab(core::position2d<s32> p)
void CGUITabControl::scrollLeft()
{
if ( CurrentScrollTabIndex > 0 )
--CurrentScrollTabIndex;
recalculateScrollBar();
}
void CGUITabControl::scrollRight()
{
if ( CurrentScrollTabIndex < (s32)(Tabs.size()) - 1 )
{
if ( needScrollControl(CurrentScrollTabIndex, true) )
++CurrentScrollTabIndex;
}
recalculateScrollBar();
}
bool CGUITabControl::needScrollControl(s32 startIndex, bool withScrollControl)
{
if ( startIndex >= (s32)Tabs.size() )
startIndex -= 1;
if ( startIndex < 0 )
startIndex = 0;
IGUISkin* skin = Environment->getSkin();
if (!skin)
return false;
IGUIFont* font = skin->getFont();
core::rect<s32> frameRect(AbsoluteRect);
s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT);
frameRect.UpperLeftCorner.Y += 2;
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight;
if (Tabs.empty())
return false;
if (!font)
return false;
s32 pos = frameRect.UpperLeftCorner.X + 2;
for (u32 i=0; i<Tabs.size(); ++i)
for (s32 i=startIndex; i<(s32)Tabs.size(); ++i)
{
// get Text
const wchar_t* text = 0;
@ -283,20 +412,70 @@ void CGUITabControl::selectTab(core::position2d<s32> p)
text = Tabs[i]->getText();
// get text length
s32 len = 20;
if (font)
len += font->getDimension(text).Width;
s32 len = font->getDimension(text).Width + TabExtraWidth;
frameRect.LowerRightCorner.X += len;
frameRect.UpperLeftCorner.X = pos;
frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len;
pos += len;
if ( withScrollControl && pos > AbsoluteRect.LowerRightCorner.X - TabMaxWidth)
return true;
if ( !withScrollControl && pos > AbsoluteRect.LowerRightCorner.X )
return true;
}
return false;
}
bool CGUITabControl::selectTab(core::position2d<s32> p)
{
IGUISkin* skin = Environment->getSkin();
IGUIFont* font = skin->getFont();
core::rect<s32> frameRect(AbsoluteRect);
if ( VerticalAlignment == EGUIA_UPPERLEFT )
{
frameRect.UpperLeftCorner.Y += 2;
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight;
}
else
{
frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight;
}
s32 pos = frameRect.UpperLeftCorner.X + 2;
if (!frameRect.isPointInside(p))
return false;
for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i)
{
// get Text
const wchar_t* text = 0;
if (Tabs[i])
text = Tabs[i]->getText();
// get text length
s32 len = font->getDimension(text).Width + TabExtraWidth;
frameRect.UpperLeftCorner.X = pos;
frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len;
if ( ScrollControl && pos > AbsoluteRect.LowerRightCorner.X)
return false;
pos += len;
if (frameRect.isPointInside(p))
{
setActiveTab(i);
return;
return true;
}
}
return false;
}
@ -311,28 +490,38 @@ void CGUITabControl::draw()
return;
IGUIFont* font = skin->getFont();
video::IVideoDriver* driver = Environment->getVideoDriver();
core::rect<s32> frameRect(AbsoluteRect);
if (Tabs.empty())
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT),
frameRect, &AbsoluteClippingRect);
driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);
if (!font)
return;
if ( VerticalAlignment == EGUIA_UPPERLEFT )
{
frameRect.UpperLeftCorner.Y += 2;
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight;
}
else
{
frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight - 1;
frameRect.LowerRightCorner.Y -= 2;
}
s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT);
frameRect.UpperLeftCorner.Y += 2;
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight;
core::rect<s32> tr;
s32 pos = frameRect.UpperLeftCorner.X + 2;
// left and right pos of the active tab
s32 left = 0;
s32 right = 0;
const wchar_t* activetext = 0;
for (s32 i=0; i<(s32)Tabs.size(); ++i)
//const wchar_t* activetext = 0;
CGUITab *activeTab = 0;
for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i)
{
// get Text
const wchar_t* text = 0;
@ -340,57 +529,208 @@ void CGUITabControl::draw()
text = Tabs[i]->getText();
// get text length
s32 len = font->getDimension(text).Width + 20;
s32 len = font->getDimension(text).Width + TabExtraWidth;
frameRect.LowerRightCorner.X += len;
frameRect.UpperLeftCorner.X = pos;
frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len;
if ( ScrollControl && pos > frameRect.LowerRightCorner.X )
break;
pos += len;
if (i == ActiveTab)
{
left = frameRect.UpperLeftCorner.X;
right = frameRect.LowerRightCorner.X;
activetext = text;
//activetext = text;
activeTab = Tabs[i];
}
else
{
skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect);
skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment);
// draw text
font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT),
font->draw(text, frameRect, Tabs[i]->getTextColor(),
true, true, &AbsoluteClippingRect);
}
}
// draw active tab
if (left != 0 && right != 0)
{
frameRect.UpperLeftCorner.X = left-2;
frameRect.LowerRightCorner.X = right+2;
frameRect.UpperLeftCorner.Y -= 2;
skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect);
// draw text
font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT),
true, true, &AbsoluteClippingRect);
if (left != 0 && right != 0 && activeTab != 0)
{
// draw upper highlight frame
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = left - 1;
tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1;
tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect);
if ( VerticalAlignment == EGUIA_UPPERLEFT )
{
frameRect.UpperLeftCorner.X = left-2;
frameRect.LowerRightCorner.X = right+2;
frameRect.UpperLeftCorner.Y -= 2;
tr.UpperLeftCorner.X = right;
tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect);
skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment);
// draw text
font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(),
true, true, &AbsoluteClippingRect);
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = left - 1;
tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1;
tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y;
driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect);
tr.UpperLeftCorner.X = right;
tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect);
}
else
{
frameRect.UpperLeftCorner.X = left-2;
frameRect.LowerRightCorner.X = right+2;
frameRect.LowerRightCorner.Y += 2;
skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment);
// draw text
font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(),
true, true, &AbsoluteClippingRect);
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = left - 1;
tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1;
tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y;
driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect);
tr.UpperLeftCorner.X = right;
tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect);
}
}
else
{
if ( VerticalAlignment == EGUIA_UPPERLEFT )
{
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1;
tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y;
driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect);
}
else
{
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = 1000;
tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1;
tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y;
driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect);
}
}
skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect);
skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect, TabHeight, VerticalAlignment);
IGUIElement::draw();
}
//! Set the height of the tabs
void CGUITabControl::setTabHeight( s32 height )
{
if ( height < 0 )
height = 0;
TabHeight = height;
TabMaxWidth = 2 * TabHeight;
recalculateScrollBar();
}
//! Get the height of the tabs
s32 CGUITabControl::getTabHeight() const
{
return TabHeight;
}
//! Set the extra width added to tabs on each side of the text
void CGUITabControl::setTabExtraWidth( s32 extraWidth )
{
if ( extraWidth < 0 )
extraWidth = 0;
TabExtraWidth = extraWidth;
recalculateScrollBar();
}
//! Get the extra width added to tabs on each side of the text
s32 CGUITabControl::getTabExtraWidth() const
{
return TabExtraWidth;
}
void CGUITabControl::recalculateScrollBar()
{
ScrollControl = needScrollControl() || CurrentScrollTabIndex > 0;
if (ScrollControl)
{
UpButton->setVisible( true );
DownButton->setVisible( true );
}
else
{
UpButton->setVisible( false );
DownButton->setVisible( false );
}
this->bringToFront( UpButton );
this->bringToFront( DownButton );
}
//! Set the alignment of the tabs
void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment )
{
VerticalAlignment = alignment;
IGUISkin* skin = Environment->getSkin();
s32 ButtonSize = 16;
if (skin)
{
ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
if (ButtonSize > TabHeight)
ButtonSize = TabHeight;
}
TabMaxWidth = s32(f32(ButtonSize) * 2.5f);
s32 ButtonX = RelativeRect.getWidth() - TabMaxWidth - 1;
s32 ButtonY = 0;
if (VerticalAlignment == EGUIA_UPPERLEFT)
{
ButtonY = (TabHeight / 2) - (ButtonSize / 2);
UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
}
else
{
ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonSize / 2);
UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
}
UpButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));
ButtonX += ButtonSize + 1;
DownButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));
recalculateScrollBar();
}
//! Get the alignment of the tabs
EGUI_ALIGNMENT CGUITabControl::getTabVerticalAlignment() const
{
return VerticalAlignment;
}
//! Returns which tab is currently active
s32 CGUITabControl::getActiveTab() const
@ -398,16 +738,6 @@ s32 CGUITabControl::getActiveTab() const
return ActiveTab;
}
bool CGUITabControl::setActiveTab(IGUIElement *tab)
{
for (s32 i=0; i<(s32)Tabs.size(); ++i)
if (Tabs[i] == tab)
return setActiveTab(i);
return false;
}
//! Brings a tab to front.
bool CGUITabControl::setActiveTab(s32 idx)
{
@ -435,6 +765,13 @@ bool CGUITabControl::setActiveTab(s32 idx)
return true;
}
bool CGUITabControl::setActiveTab(IGUIElement *tab)
{
for (s32 i=0; i<(s32)Tabs.size(); ++i)
if (Tabs[i] == tab)
return setActiveTab(i);
return false;
}
//! Removes a child.
void CGUITabControl::removeChild(IGUIElement* child)
@ -465,31 +802,44 @@ void CGUITabControl::removeChild(IGUIElement* child)
// remove real element
IGUIElement::removeChild(child);
recalculateScrollBar();
}
//! Update the position of the element, decides scroll button status
void CGUITabControl::updateAbsolutePosition()
{
IGUIElement::updateAbsolutePosition();
recalculateScrollBar();
}
//! Writes attributes of the element.
void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUITabControl::serializeAttributes(out,options);
out->addInt("ActiveTab", ActiveTab);
out->addInt ("ActiveTab", ActiveTab);
out->addBool("Border", Border);
out->addBool("FillBackground", FillBackground);
out->addInt ("TabHeight", TabHeight);
out->addEnum("TabVerticalAlignment", s32(VerticalAlignment), GUIAlignmentNames);
}
//! Reads attributes of the element
void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
Border = in->getAttributeAsBool("Border");
Border = in->getAttributeAsBool("Border");
FillBackground = in->getAttributeAsBool("FillBackground");
ActiveTab = -1;
setTabHeight(in->getAttributeAsInt("TabHeight"));
IGUITabControl::deserializeAttributes(in,options);
setActiveTab(in->getAttributeAsInt("ActiveTab"));
setTabVerticalAlignment( static_cast<EGUI_ALIGNMENT>(in->getAttributeAsEnumeration("TabVerticalAlignment" , GUIAlignmentNames)) );
}
@ -498,3 +848,4 @@ void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -10,11 +10,15 @@
#include "IGUITabControl.h"
#include "irrArray.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
class CGUITabControl;
class IGUIButton;
// A tab, onto which other gui elements could be added.
class CGUITab : public IGUITab
{
@ -25,6 +29,9 @@ namespace gui
IGUIElement* parent, const core::rect<s32>& rectangle,
s32 id);
//! destructor
//virtual ~CGUITab();
//! Returns number of this tab in tabcontrol. Can be accessed
//! later IGUITabControl::getTab() by this number.
virtual s32 getNumber() const;
@ -40,6 +47,9 @@ namespace gui
//! sets the color of the background, if it should be drawn.
virtual void setBackgroundColor(video::SColor c);
//! sets the color of the text
virtual void setTextColor(video::SColor c);
//! returns true if the tab is drawing its background, false if not
virtual bool isDrawingBackground() const;
@ -47,6 +57,8 @@ namespace gui
//! returns the color of the background
virtual video::SColor getBackgroundColor() const;
virtual video::SColor getTextColor() const;
//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
@ -59,6 +71,8 @@ namespace gui
s32 Number;
bool DrawBackground;
video::SColor BackColor;
video::SColor TextColor;
};
@ -108,18 +122,51 @@ namespace gui
//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
//! Set the height of the tabs
virtual void setTabHeight( s32 height );
//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
//! Get the height of the tabs
virtual s32 getTabHeight() const;
//! Set the alignment of the tabs
//! note: EGUIA_CENTER is not an option
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment );
//! Get the alignment of the tabs
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const;
//! Set the extra width added to tabs on each side of the text
virtual void setTabExtraWidth( s32 extraWidth );
//! Get the extra width added to tabs on each side of the text
virtual s32 getTabExtraWidth() const;
//! Update the position of the element, decides scroll button status
virtual void updateAbsolutePosition();
private:
void selectTab(core::position2d<s32> p);
bool selectTab(core::position2d<s32> p);
void scrollLeft();
void scrollRight();
bool needScrollControl( s32 startIndex=0, bool withScrollControl=false );
void recalculateScrollBar();
core::array<CGUITab*> Tabs;
s32 ActiveTab;
bool Border;
bool FillBackground;
bool ScrollControl;
s32 TabHeight;
gui::EGUI_ALIGNMENT VerticalAlignment;
IGUIButton* UpButton;
IGUIButton* DownButton;
s32 TabMaxWidth;
s32 CurrentScrollTabIndex;
s32 TabExtraWidth;
};
@ -130,3 +177,6 @@ namespace gui
#endif

View File

@ -0,0 +1,723 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// 07.10.2005 - Multicolor-Listbox addet by A. Buschhüter (Acki)
// A_Buschhueter@gmx.de
#include "CGUITable.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "CGUIScrollBar.h"
#include "os.h"
#define ARROW_PAD 15
namespace irr
{
namespace gui
{
//! constructor
CGUITable::CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip,
bool drawBack, bool moveOverSelect)
: IGUITable(environment, parent, id, rectangle), ScrollBar(0),
ItemHeight(0), TotalItemHeight(0), Font(0), Selected(-1),
Clip(clip), DrawBack(drawBack), Selecting(false), ActiveTab(-1),
MoveOverSelect(moveOverSelect), CellHeightPadding(2), CellWidthPadding(5), m_CurrentOrdering(EGOM_ASCENDING)
{
#ifdef _DEBUG
setDebugName("CGUITable");
#endif
IGUISkin* skin = Environment->getSkin();
s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
ScrollBar = new CGUIScrollBar(false, Environment, this, -1,
core::rect<s32>(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()),
!clip);
if (ScrollBar)
{
ScrollBar->setPos(0);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ScrollBar->setSubElement(true);
ScrollBar->grab();
}
recalculate();
}
//! destructor
CGUITable::~CGUITable()
{
if (ScrollBar)
ScrollBar->drop();
if (Font)
Font->drop();
}
void CGUITable::addColumn(const wchar_t* caption, s32 id)
{
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
Column tabHeader;
tabHeader.name = caption;
tabHeader.width = Font->getDimension(caption).Width + (CellWidthPadding * 2) + ARROW_PAD;
tabHeader.TextColor = skin->getColor(EGDC_BUTTON_TEXT);
tabHeader.useCustomOrdering = false;
Columns.push_back(tabHeader);
if (ActiveTab == -1)
ActiveTab = 0;
}
s32 CGUITable::getColumncount() const
{
return Columns.size();
}
s32 CGUITable::getRowcount() const
{
return Rows.size();
}
bool CGUITable::setActiveColumn(s32 idx)
{
if (idx < 0 || idx >= (s32)Columns.size())
return false;
bool changed = (ActiveTab != idx);
ActiveTab = idx;
m_CurrentOrdering = EGOM_ASCENDING;
if ( !Columns[idx].useCustomOrdering )
orderRows();
if (changed)
{
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED;
Parent->OnEvent(event);
}
return true;
}
s32 CGUITable::getActiveColumn() const
{
return ActiveTab;
}
EGUI_ORDERING_MODE CGUITable::getActiveColumnOrdering() const
{
return m_CurrentOrdering;
}
void CGUITable::setColumnWidth(u32 columnIndex, u32 width)
{
if ( columnIndex < Columns.size() )
{
if ( width < ( Font->getDimension(Columns[columnIndex].name.c_str() ).Width + (u32(CellWidthPadding) * 2) ) )
width = Font->getDimension(Columns[columnIndex].name.c_str() ).Width + (CellWidthPadding * 2) + ARROW_PAD;
Columns[columnIndex].width = width;
}
}
void CGUITable::addRow(u32 rowIndex)
{
if (!( rowIndex < (Rows.size() + 1) ) )
return;
Row row;
if ( rowIndex == Rows.size() )
Rows.push_back(row);
else
Rows.insert(row, rowIndex);
for ( u32 i = 0 ; i < Columns.size() ; ++i )
{
Cell cell;
cell.data = 0;
Rows[rowIndex].Items.push_back(cell);
}
recalculate();
}
void CGUITable::removeRow(u32 rowIndex)
{
if (!( rowIndex < Rows.size() ) )
return;
Rows.erase( rowIndex );
if ( !(Selected < s32(Rows.size())) )
Selected = Rows.size() - 1;
recalculate();
}
//! adds an list item, returns id of item
void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text)
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
Rows[rowIndex].Items[columnIndex].text = text;
breakText( Rows[rowIndex].Items[columnIndex].text, Columns[columnIndex].width );
IGUISkin* skin = Environment->getSkin();
if ( skin )
Rows[rowIndex].Items[columnIndex].color = skin->getColor(EGDC_BUTTON_TEXT);
}
}
void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color)
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
Rows[rowIndex].Items[columnIndex].text = text;
breakText( Rows[rowIndex].Items[columnIndex].text, Columns[columnIndex].width );
Rows[rowIndex].Items[columnIndex].color = color;
}
}
void CGUITable::setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color)
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
Rows[rowIndex].Items[columnIndex].color = color;
}
}
void CGUITable::setCellData(u32 rowIndex, u32 columnIndex, void *data)
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
Rows[rowIndex].Items[columnIndex].data = data;
}
}
const wchar_t* CGUITable::getCellText(u32 rowIndex, u32 columnIndex ) const
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
return Rows[rowIndex].Items[columnIndex].text.c_str();
}
return 0;
}
void* CGUITable::getCellData(u32 rowIndex, u32 columnIndex ) const
{
if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() )
{
return Rows[rowIndex].Items[columnIndex].data;
}
return 0;
}
//! clears the list
void CGUITable::clear()
{
Rows.clear();
Columns.clear();
if (ScrollBar)
ScrollBar->setPos(0);
recalculate();
}
void CGUITable::clearRows()
{
Rows.clear();
if (ScrollBar)
ScrollBar->setPos(0);
recalculate();
}
s32 CGUITable::getSelected() const
{
return Selected;
}
void CGUITable::recalculate()
{
IGUISkin* skin = Environment->getSkin();
if (Font != skin->getFont())
{
if (Font)
Font->drop();
Font = skin->getFont();
ItemHeight = 0;
if(Font)
{
ItemHeight = Font->getDimension(L"A").Height + (CellHeightPadding * 2);
Font->grab();
}
}
ScrollBar->setMax((ItemHeight * Rows.size()) - AbsoluteRect.getHeight() + ItemHeight);
}
//! called if an event happened.
bool CGUITable::OnEvent(const SEvent& event)
{
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case gui::EGET_SCROLL_BAR_CHANGED:
if (event.GUIEvent.Caller == ScrollBar)
{
s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
return true;
}
break;
/*case gui::EGET_ELEMENT_FOCUS_LOST:
{
Selecting = false;
return true;
}
break;*/
}
break;
case EET_MOUSE_INPUT_EVENT:
{
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
switch(event.MouseInput.Event)
{
case EMIE_MOUSE_WHEEL:
ScrollBar->setPos(ScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10);
return true;
case EMIE_LMOUSE_PRESSED_DOWN:
if (Environment->hasFocus(this) &&
ScrollBar->getAbsolutePosition().isPointInside(p) &&
ScrollBar->OnEvent(event))
return true;
if ( selectColumnHeader( event.MouseInput.X, event.MouseInput.Y ) )
return true;
Selecting = true;
Environment->setFocus(this);
return true;
case EMIE_LMOUSE_LEFT_UP:
if (Environment->hasFocus(this) &&
ScrollBar->getAbsolutePosition().isPointInside(p) &&
ScrollBar->OnEvent(event))
{
return true;
}
Selecting = false;
Environment->removeFocus(this);
selectNew(event.MouseInput.Y);
return true;
case EMIE_MOUSE_MOVED:
if (Selecting || MoveOverSelect)
{
if (getAbsolutePosition().isPointInside(p))
{
selectNew(event.MouseInput.Y);
return true;
}
}
}
}
break;
}
return Parent ? Parent->OnEvent(event) : false;
}
void CGUITable::setColumnCustomOrdering(u32 columnIndex, bool state)
{
if ( columnIndex < Columns.size() )
Columns[columnIndex].useCustomOrdering = state;
}
void CGUITable::swapRows(u32 rowIndexA, u32 rowIndexB)
{
if ( rowIndexA >= Rows.size() )
return;
if ( rowIndexB >= Rows.size() )
return;
Row swap = Rows[rowIndexA];
Rows[rowIndexA] = Rows[rowIndexB];
Rows[rowIndexB] = swap;
if ( Selected == s32(rowIndexA) )
Selected = rowIndexB;
else if( Selected == s32(rowIndexB) )
Selected = rowIndexA;
}
bool CGUITable::selectColumnHeader(s32 xpos, s32 ypos)
{
if ( ypos > ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) )
return false;
core::rect<s32> frameRect(AbsoluteRect);
s32 pos = frameRect.UpperLeftCorner.X;;
u32 colWidth;
for ( u32 i = 0 ; i < Columns.size() ; ++i )
{
colWidth = Columns[i].width;
if ( xpos >= pos && xpos < ( pos + s32(colWidth) ) )
{
if ( ActiveTab == s32(i) )
{
if ( m_CurrentOrdering == EGOM_ASCENDING )
m_CurrentOrdering = EGOM_DESCENDING;
else
m_CurrentOrdering = EGOM_ASCENDING;
}
else
{
ActiveTab = i;
m_CurrentOrdering = EGOM_ASCENDING;
}
if ( !Columns[i].useCustomOrdering )
orderRows();
else
{
if (Parent)
{
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED;
Parent->OnEvent(event);
}
}
break;
}
pos += colWidth;
}
return false;
}
void CGUITable::orderRows()
{
Row swap;
s32 columnIndex = getActiveColumn();
if ( m_CurrentOrdering == EGOM_ASCENDING )
{
for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i )
{
for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j )
{
if ( Rows[j+1].Items[columnIndex].text < Rows[j].Items[columnIndex].text )
{
swap = Rows[j];
Rows[j] = Rows[j+1];
Rows[j+1] = swap;
if ( Selected == j )
Selected = j+1;
else if( Selected == j+1 )
Selected = j;
}
}
}
}
else
{
for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i )
{
for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j )
{
if ( Rows[j].Items[columnIndex].text < Rows[j+1].Items[columnIndex].text)
{
swap = Rows[j];
Rows[j] = Rows[j+1];
Rows[j+1] = swap;
if ( Selected == j )
Selected = j+1;
else if( Selected == j+1 )
Selected = j;
}
}
}
}
}
void CGUITable::selectNew(s32 ypos, bool onlyHover)
{
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
s32 oldSelected = Selected;
if ( ypos < ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) )
return;
// find new selected item.
if (ItemHeight!=0)
Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - ItemHeight - 1) + ScrollBar->getPos()) / ItemHeight;
if (Selected >= (s32)Rows.size())
Selected = Rows.size() - 1;
else if (Selected<0)
Selected = 0;
// post the news
if (Parent && !onlyHover)
{
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.EventType = (Selected != oldSelected) ? EGET_TABLE_CHANGED : EGET_TABLE_SELECTED_AGAIN;
Parent->OnEvent(event);
}
}
//! draws the element and its children
void CGUITable::draw()
{
if (!IsVisible)
return;
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
core::rect<s32> frameRect(AbsoluteRect);
core::rect<s32> columnSeparator(AbsoluteRect);
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
IGUIFont* font = skin->getFont();
if (!font)
return;
s32 headerFinalPosition = frameRect.UpperLeftCorner.Y + ItemHeight;
frameRect = AbsoluteRect;
frameRect.UpperLeftCorner.X += 1;
frameRect.UpperLeftCorner.Y = headerFinalPosition;
frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
frameRect.LowerRightCorner.Y = headerFinalPosition + ItemHeight;
frameRect.UpperLeftCorner.Y -= ScrollBar->getPos();
frameRect.LowerRightCorner.Y -= ScrollBar->getPos();
core::rect<s32> clientClip(AbsoluteRect);
clientClip.UpperLeftCorner.Y = headerFinalPosition + 1;
clientClip.UpperLeftCorner.X += 1;
clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
clientClip.LowerRightCorner.Y -= 1;
u32 pos;
for ( u32 i = 0 ; i < Rows.size() ; ++i )
{
if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y &&
frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y)
{
core::rect<s32> textRect = frameRect;
textRect.UpperLeftCorner.Y = textRect.LowerRightCorner.Y - 1;
driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), textRect, &clientClip);
textRect = frameRect;
pos = frameRect.UpperLeftCorner.X;
if (s32(i) == Selected)
driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip);
for ( u32 j = 0 ; j < Columns.size() ; ++j )
{
textRect.UpperLeftCorner.X = pos + CellWidthPadding;
textRect.LowerRightCorner.X = pos + Columns[j].width - CellWidthPadding;
s32 test = font->getDimension(Rows[i].Items[j].text.c_str()).Width;
if (s32(i) == Selected)
{
font->draw(Rows[i].Items[j].text.c_str(), textRect, skin->getColor(EGDC_HIGH_LIGHT_TEXT), false, true, &clientClip);
}
else
{
font->draw(Rows[i].Items[j].text.c_str(), textRect, Rows[i].Items[j].color, false, true, &clientClip);
}
pos += Columns[j].width;
}
}
frameRect.UpperLeftCorner.Y += ItemHeight;
frameRect.LowerRightCorner.Y += ItemHeight;
}
frameRect = AbsoluteRect;
columnSeparator.UpperLeftCorner.Y = headerFinalPosition;
core::rect<s32>* clipRect = 0;
if (Clip)
clipRect = &AbsoluteClippingRect;
const wchar_t* text = 0;
pos = frameRect.UpperLeftCorner.X;
u32 colWidth;
skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, DrawBack, frameRect, clipRect);
for (u32 i = 0 ; i < Columns.size() ; ++i )
{
text = Columns[i].name.c_str();
colWidth = Columns[i].width;
core::dimension2d<s32 > dim = font->getDimension(text);
core::rect<s32> columnrect(pos, frameRect.UpperLeftCorner.Y, pos + colWidth, headerFinalPosition);
skin->draw3DButtonPaneStandard(this, columnrect, &AbsoluteClippingRect);
columnSeparator.UpperLeftCorner.X = columnrect.LowerRightCorner.X;
columnSeparator.LowerRightCorner.X = columnrect.LowerRightCorner.X + 1;
driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), columnSeparator, &AbsoluteClippingRect);
columnrect.UpperLeftCorner.X += CellWidthPadding;
font->draw(text, columnrect, skin->getColor(EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect);
if ( s32(i) == ActiveTab )
{
if ( m_CurrentOrdering == EGOM_ASCENDING )
{
columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2;
columnrect.UpperLeftCorner.Y += 7;
skin->drawIcon(this,EGDI_CURSOR_UP,columnrect.UpperLeftCorner);
}
else
{
columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2;
columnrect.UpperLeftCorner.Y += 7;
skin->drawIcon(this,EGDI_CURSOR_DOWN,columnrect.UpperLeftCorner);
}
}
pos += colWidth;
}
core::rect<s32> columnrect(pos, frameRect.UpperLeftCorner.Y, frameRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE), headerFinalPosition);
skin->draw3DButtonPaneStandard(this, columnrect, &AbsoluteClippingRect);
IGUIElement::draw();
}
void CGUITable::breakText(core::stringw &text, u32 cellWidth )
{
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
if (!Font)
return;
IGUIFont* font = skin->getFont();
if (!font)
return;
core::stringw line, lineDots, character;
wchar_t c[2];
c[1] = L'\0';
u32 maxLength = cellWidth - (CellWidthPadding * 2);
u32 maxLengthDots = cellWidth - (CellWidthPadding * 2) - font->getDimension(L"...").Width;
u32 size = text.size();
u32 pos = 0;
u32 i;
for (i=0; i<size; ++i)
{
c[0] = text[i];
if (c[0] == L'\n')
break;
pos += font->getDimension( c ).Width;
if ( pos > maxLength )
break;
if ( font->getDimension( (line + c[0]).c_str() ).Width > s32(maxLengthDots) )
lineDots = line;
line += c[0];
}
if ( i < size )
line = lineDots + L"...";
text = line;
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

171
source/Irrlicht/CGUITable.h Normal file
View File

@ -0,0 +1,171 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// 07.10.2005 - Multicolor-Listbox addet by A. Buschhüter (Acki)
// A_Buschhueter@gmx.de
#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__
#define __C_GUI_TABLE_BAR_H_INCLUDED__
#include "IGUITable.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUIScrollBar;
class CGUITable : public IGUITable
{
public:
//! constructor
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip=true,
bool drawBack=false, bool moveOverSelect=true);
//! destructor
~CGUITable();
//! Adds a column
virtual void addColumn(const wchar_t* caption, s32 id=-1);
//! Returns the number of columns in the table control
virtual s32 getColumncount() const;
//! Makes a column active. This will trigger an ordering process.
/** \param idx: The id of the column to make active.
\return Returns true if successful. */
virtual bool setActiveColumn(s32 idx);
//! Returns which header is currently active
virtual s32 getActiveColumn() const;
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const;
//! set a column width
virtual void setColumnWidth(u32 columnIndex, u32 width);
//! This tells the table control wether is should send a EGET_TABLE_HEADER_CHANGED message or not when
//! a column header is clicked. If set to false, the table control will use a default alphabetical ordering scheme.
/** \param columnIndex: The index of the column header.
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
virtual void setColumnCustomOrdering(u32 columnIndex, bool state);
//! Returns which row is currently selected
virtual s32 getSelected() const;
//! Returns amount of rows in the tabcontrol
virtual s32 getRowcount() const;
//! adds a row to the table
/** \param rowIndex: zero based index of rows. The row will be inserted at this
position, if a row already exist there, it will be placed after it. If the row
is larger than the actual number of row by more than one, it won't be created.
Note that if you create a row that's not at the end, there might be performance issues*/
virtual void addRow(u32 rowIndex);
//! Remove a row from the table
virtual void removeRow(u32 rowIndex);
//! clears the table rows, but keeps the columns intact
virtual void clearRows();
//! Swap two row positions. This is useful for a custom ordering algo.
virtual void swapRows(u32 rowIndexA, u32 rowIndexB);
//! This tells the table to start ordering all the rows. You need to explicitly
//! tell the table to re order the rows when a new row is added or the cells data is
//! changed. This makes the system more flexible and doesn't make you pay the cost of
//! ordering when adding a lot of rows.
virtual void orderRows();
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text);
//! Set the text of a cell, and set a color of this cell.
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color);
//! Set the data of a cell
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data);
//! Set the color of a cell text
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color);
//! Get the text of a cell
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const;
//! Get the data of a cell
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const;
//! clears the table, deletes all items in the table
virtual void clear();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
//! draws the element and its children
virtual void draw();
private:
struct Cell
{
core::stringw text;
core::stringw BrokenText;
video::SColor color;
void *data;
};
struct Row
{
core::array<Cell> Items;
u32 height;
};
struct Column
{
core::stringw name;
video::SColor TextColor;
u32 width;
bool useCustomOrdering;
};
void breakText(core::stringw &text, u32 cellWidth);
void selectNew(s32 ypos, bool onlyHover=false);
bool selectColumnHeader(s32 xpos, s32 ypos);
void recalculate();
core::array< Column > Columns;
core::array< Row > Rows;
s32 ItemHeight;
s32 TotalItemHeight;
gui::IGUIFont* Font;
gui::IGUIScrollBar* ScrollBar;
bool Clip;
bool DrawBack;
bool MoveOverSelect;
s32 Selected;
s32 CellWidthPadding;
s32 CellHeightPadding;
s32 ActiveTab;
bool Selecting;
EGUI_ORDERING_MODE m_CurrentOrdering;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -619,6 +619,9 @@
<File
RelativePath=".\..\..\include\IGUITabControl.h">
</File>
<File
RelativePath=".\..\..\include\IGUITable.h">
</File>
<File
RelativePath=".\..\..\include\IGUIToolbar.h">
</File>
@ -630,31 +633,31 @@
<Filter
Name="gui impl">
<File
RelativePath=".\BuiltInFont.h">
RelativePath="BuiltInFont.h">
</File>
<File
RelativePath=".\CDefaultGUIElementFactory.cpp">
RelativePath="CDefaultGUIElementFactory.cpp">
</File>
<File
RelativePath=".\CDefaultGUIElementFactory.h">
RelativePath="CDefaultGUIElementFactory.h">
</File>
<File
RelativePath=".\CGUIButton.cpp">
RelativePath="CGUIButton.cpp">
</File>
<File
RelativePath=".\CGUIButton.h">
RelativePath="CGUIButton.h">
</File>
<File
RelativePath=".\CGUICheckbox.cpp">
RelativePath="CGUICheckbox.cpp">
</File>
<File
RelativePath=".\CGUICheckbox.h">
RelativePath="CGUICheckbox.h">
</File>
<File
RelativePath=".\CGUIColorSelectDialog.cpp">
RelativePath="CGUIColorSelectDialog.cpp">
</File>
<File
RelativePath=".\CGUIColorSelectDialog.h">
RelativePath="CGUIColorSelectDialog.h">
</File>
<File
RelativePath="CGUIComboBox.cpp">
@ -675,28 +678,28 @@
RelativePath="CGUIEditBox.h">
</File>
<File
RelativePath=".\CGUIEnvironment.cpp">
RelativePath="CGUIEnvironment.cpp">
</File>
<File
RelativePath=".\CGUIEnvironment.h">
RelativePath="CGUIEnvironment.h">
</File>
<File
RelativePath=".\CGUIFileOpenDialog.cpp">
RelativePath="CGUIFileOpenDialog.cpp">
</File>
<File
RelativePath=".\CGUIFileOpenDialog.h">
RelativePath="CGUIFileOpenDialog.h">
</File>
<File
RelativePath=".\CGUIFont.cpp">
RelativePath="CGUIFont.cpp">
</File>
<File
RelativePath=".\CGUIFont.h">
RelativePath="CGUIFont.h">
</File>
<File
RelativePath=".\CGUIImage.cpp">
RelativePath="CGUIImage.cpp">
</File>
<File
RelativePath=".\CGUIImage.h">
RelativePath="CGUIImage.h">
</File>
<File
RelativePath="CGUIInOutFader.cpp">
@ -705,10 +708,10 @@
RelativePath="CGUIInOutFader.h">
</File>
<File
RelativePath=".\CGUIListBox.cpp">
RelativePath="CGUIListBox.cpp">
</File>
<File
RelativePath=".\CGUIListBox.h">
RelativePath="CGUIListBox.h">
</File>
<File
RelativePath="CGUIMenu.cpp">
@ -717,10 +720,10 @@
RelativePath="CGUIMenu.h">
</File>
<File
RelativePath=".\CGUIMeshViewer.cpp">
RelativePath="CGUIMeshViewer.cpp">
</File>
<File
RelativePath=".\CGUIMeshViewer.h">
RelativePath="CGUIMeshViewer.h">
</File>
<File
RelativePath="CGUIMessageBox.cpp">
@ -735,34 +738,34 @@
RelativePath="CGUIModalScreen.h">
</File>
<File
RelativePath=".\CGUIScrollBar.cpp">
RelativePath="CGUIScrollBar.cpp">
</File>
<File
RelativePath=".\CGUIScrollBar.h">
RelativePath="CGUIScrollBar.h">
</File>
<File
RelativePath=".\CGUISkin.cpp">
RelativePath="CGUISkin.cpp">
</File>
<File
RelativePath=".\CGUISkin.h">
RelativePath="CGUISkin.h">
</File>
<File
RelativePath=".\CGUISpinBox.cpp">
RelativePath="CGUISpinBox.cpp">
</File>
<File
RelativePath=".\CGUISpinBox.h">
RelativePath="CGUISpinBox.h">
</File>
<File
RelativePath=".\CGUISpriteBank.cpp">
RelativePath="CGUISpriteBank.cpp">
</File>
<File
RelativePath=".\CGUISpriteBank.h">
RelativePath="CGUISpriteBank.h">
</File>
<File
RelativePath=".\CGUIStaticText.cpp">
RelativePath="CGUIStaticText.cpp">
</File>
<File
RelativePath=".\CGUIStaticText.h">
RelativePath="CGUIStaticText.h">
</File>
<File
RelativePath="CGUITabControl.cpp">
@ -770,6 +773,12 @@
<File
RelativePath="CGUITabControl.h">
</File>
<File
RelativePath="CGUITable.cpp">
</File>
<File
RelativePath="CGUITable.h">
</File>
<File
RelativePath="CGUIToolBar.cpp">
</File>
@ -777,10 +786,10 @@
RelativePath="CGUIToolBar.h">
</File>
<File
RelativePath=".\CGUIWindow.cpp">
RelativePath="CGUIWindow.cpp">
</File>
<File
RelativePath=".\CGUIWindow.h">
RelativePath="CGUIWindow.h">
</File>
</Filter>
<Filter
@ -794,166 +803,166 @@
<Filter
Name="Software">
<File
RelativePath=".\CSoftwareDriver.cpp">
RelativePath="CSoftwareDriver.cpp">
</File>
<File
RelativePath=".\CSoftwareDriver.h">
RelativePath="CSoftwareDriver.h">
</File>
<File
RelativePath=".\CSoftwareTexture.cpp">
RelativePath="CSoftwareTexture.cpp">
</File>
<File
RelativePath=".\CSoftwareTexture.h">
RelativePath="CSoftwareTexture.h">
</File>
<File
RelativePath=".\CTRFlat.cpp">
RelativePath="CTRFlat.cpp">
</File>
<File
RelativePath=".\CTRFlatWire.cpp">
RelativePath="CTRFlatWire.cpp">
</File>
<File
RelativePath=".\CTRGouraud.cpp">
RelativePath="CTRGouraud.cpp">
</File>
<File
RelativePath=".\CTRGouraudWire.cpp">
RelativePath="CTRGouraudWire.cpp">
</File>
<File
RelativePath=".\CTRTextureFlat.cpp">
RelativePath="CTRTextureFlat.cpp">
</File>
<File
RelativePath=".\CTRTextureFlatWire.cpp">
RelativePath="CTRTextureFlatWire.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraud.cpp">
RelativePath="CTRTextureGouraud.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraud.h">
RelativePath="CTRTextureGouraud.h">
</File>
<File
RelativePath=".\CTRTextureGouraudAdd.cpp">
RelativePath="CTRTextureGouraudAdd.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudNoZ.cpp">
RelativePath="CTRTextureGouraudNoZ.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudWire.cpp">
RelativePath="CTRTextureGouraudWire.cpp">
</File>
<File
RelativePath=".\CZBuffer.cpp">
RelativePath="CZBuffer.cpp">
</File>
<File
RelativePath=".\CZBuffer.h">
RelativePath="CZBuffer.h">
</File>
<File
RelativePath=".\ITriangleRenderer.h">
RelativePath="ITriangleRenderer.h">
</File>
<File
RelativePath=".\IZBuffer.h">
RelativePath="IZBuffer.h">
</File>
<File
RelativePath=".\S2DVertex.h">
RelativePath="S2DVertex.h">
</File>
</Filter>
<Filter
Name="OpenGL">
<File
RelativePath=".\COpenGLDriver.cpp">
RelativePath="COpenGLDriver.cpp">
</File>
<File
RelativePath=".\COpenGLDriver.h">
RelativePath="COpenGLDriver.h">
</File>
<File
RelativePath=".\COpenGLExtensionHandler.cpp">
RelativePath="COpenGLExtensionHandler.cpp">
</File>
<File
RelativePath=".\COpenGLExtensionHandler.h">
RelativePath="COpenGLExtensionHandler.h">
</File>
<File
RelativePath=".\COpenGLMaterialRenderer.h">
RelativePath="COpenGLMaterialRenderer.h">
</File>
<File
RelativePath=".\COpenGLNormalMapRenderer.cpp">
RelativePath="COpenGLNormalMapRenderer.cpp">
</File>
<File
RelativePath=".\COpenGLNormalMapRenderer.h">
RelativePath="COpenGLNormalMapRenderer.h">
</File>
<File
RelativePath=".\COpenGLParallaxMapRenderer.cpp">
RelativePath="COpenGLParallaxMapRenderer.cpp">
</File>
<File
RelativePath=".\COpenGLParallaxMapRenderer.h">
RelativePath="COpenGLParallaxMapRenderer.h">
</File>
<File
RelativePath=".\COpenGLShaderMaterialRenderer.cpp">
RelativePath="COpenGLShaderMaterialRenderer.cpp">
</File>
<File
RelativePath=".\COpenGLShaderMaterialRenderer.h">
RelativePath="COpenGLShaderMaterialRenderer.h">
</File>
<File
RelativePath=".\COpenGLSLMaterialRenderer.cpp">
RelativePath="COpenGLSLMaterialRenderer.cpp">
</File>
<File
RelativePath=".\COpenGLSLMaterialRenderer.h">
RelativePath="COpenGLSLMaterialRenderer.h">
</File>
<File
RelativePath=".\COpenGLTexture.cpp">
RelativePath="COpenGLTexture.cpp">
</File>
<File
RelativePath=".\COpenGLTexture.h">
RelativePath="COpenGLTexture.h">
</File>
<File
RelativePath=".\glext.h">
RelativePath="glext.h">
</File>
</Filter>
<Filter
Name="Direct3D8">
<File
RelativePath=".\CD3D8Driver.cpp">
RelativePath="CD3D8Driver.cpp">
</File>
<File
RelativePath=".\CD3D8Driver.h">
RelativePath="CD3D8Driver.h">
</File>
<File
RelativePath=".\CD3D8MaterialRenderer.h">
RelativePath="CD3D8MaterialRenderer.h">
</File>
<File
RelativePath=".\CD3D8NormalMapRenderer.cpp">
RelativePath="CD3D8NormalMapRenderer.cpp">
</File>
<File
RelativePath=".\CD3D8NormalMapRenderer.h">
RelativePath="CD3D8NormalMapRenderer.h">
</File>
<File
RelativePath=".\CD3D8ParallaxMapRenderer.cpp">
RelativePath="CD3D8ParallaxMapRenderer.cpp">
</File>
<File
RelativePath=".\CD3D8ParallaxMapRenderer.h">
RelativePath="CD3D8ParallaxMapRenderer.h">
</File>
<File
RelativePath=".\CD3D8ShaderMaterialRenderer.cpp">
RelativePath="CD3D8ShaderMaterialRenderer.cpp">
</File>
<File
RelativePath=".\CD3D8ShaderMaterialRenderer.h">
RelativePath="CD3D8ShaderMaterialRenderer.h">
</File>
<File
RelativePath=".\CD3D8Texture.cpp">
RelativePath="CD3D8Texture.cpp">
</File>
<File
RelativePath=".\CD3D8Texture.h">
RelativePath="CD3D8Texture.h">
</File>
</Filter>
<Filter
Name="Null">
<File
RelativePath=".\CColorConverter.cpp">
RelativePath="CColorConverter.cpp">
</File>
<File
RelativePath=".\CColorConverter.h">
RelativePath="CColorConverter.h">
</File>
<File
RelativePath=".\CFPSCounter.cpp">
RelativePath="CFPSCounter.cpp">
</File>
<File
RelativePath=".\CFPSCounter.h">
RelativePath="CFPSCounter.h">
</File>
<File
RelativePath="CImage.cpp">
@ -1010,10 +1019,10 @@
RelativePath="CImageLoaderWAL.h">
</File>
<File
RelativePath=".\CNullDriver.cpp">
RelativePath="CNullDriver.cpp">
</File>
<File
RelativePath=".\CNullDriver.h">
RelativePath="CNullDriver.h">
</File>
<File
RelativePath="IImagePresenter.h">
@ -1021,216 +1030,216 @@
<Filter
Name="Writer">
<File
RelativePath=".\CImageWriterBMP.cpp">
RelativePath="CImageWriterBMP.cpp">
</File>
<File
RelativePath=".\CImageWriterBMP.h">
RelativePath="CImageWriterBMP.h">
</File>
<File
RelativePath=".\CImageWriterJPG.cpp">
RelativePath="CImageWriterJPG.cpp">
</File>
<File
RelativePath=".\CImageWriterJPG.h">
RelativePath="CImageWriterJPG.h">
</File>
<File
RelativePath=".\CImageWriterPCX.cpp">
RelativePath="CImageWriterPCX.cpp">
</File>
<File
RelativePath=".\CImageWriterPCX.h">
RelativePath="CImageWriterPCX.h">
</File>
<File
RelativePath=".\CImageWriterPNG.cpp">
RelativePath="CImageWriterPNG.cpp">
</File>
<File
RelativePath=".\CImageWriterPNG.h">
RelativePath="CImageWriterPNG.h">
</File>
<File
RelativePath=".\CImageWriterPPM.cpp">
RelativePath="CImageWriterPPM.cpp">
</File>
<File
RelativePath=".\CImageWriterPPM.h">
RelativePath="CImageWriterPPM.h">
</File>
<File
RelativePath=".\CImageWriterPSD.cpp">
RelativePath="CImageWriterPSD.cpp">
</File>
<File
RelativePath=".\CImageWriterPSD.h">
RelativePath="CImageWriterPSD.h">
</File>
<File
RelativePath=".\CImageWriterTGA.cpp">
RelativePath="CImageWriterTGA.cpp">
</File>
<File
RelativePath=".\CImageWriterTGA.h">
RelativePath="CImageWriterTGA.h">
</File>
</Filter>
</Filter>
<Filter
Name="Direct3D9">
<File
RelativePath=".\CD3D9Driver.cpp">
RelativePath="CD3D9Driver.cpp">
</File>
<File
RelativePath=".\CD3D9Driver.h">
RelativePath="CD3D9Driver.h">
</File>
<File
RelativePath=".\CD3D9HLSLMaterialRenderer.cpp">
RelativePath="CD3D9HLSLMaterialRenderer.cpp">
</File>
<File
RelativePath=".\CD3D9HLSLMaterialRenderer.h">
RelativePath="CD3D9HLSLMaterialRenderer.h">
</File>
<File
RelativePath=".\CD3D9MaterialRenderer.h">
RelativePath="CD3D9MaterialRenderer.h">
</File>
<File
RelativePath=".\CD3D9NormalMapRenderer.cpp">
RelativePath="CD3D9NormalMapRenderer.cpp">
</File>
<File
RelativePath=".\CD3D9NormalMapRenderer.h">
RelativePath="CD3D9NormalMapRenderer.h">
</File>
<File
RelativePath=".\CD3D9ParallaxMapRenderer.cpp">
RelativePath="CD3D9ParallaxMapRenderer.cpp">
</File>
<File
RelativePath=".\CD3D9ParallaxMapRenderer.h">
RelativePath="CD3D9ParallaxMapRenderer.h">
</File>
<File
RelativePath=".\CD3D9ShaderMaterialRenderer.cpp">
RelativePath="CD3D9ShaderMaterialRenderer.cpp">
</File>
<File
RelativePath=".\CD3D9ShaderMaterialRenderer.h">
RelativePath="CD3D9ShaderMaterialRenderer.h">
</File>
<File
RelativePath=".\CD3D9Texture.cpp">
RelativePath="CD3D9Texture.cpp">
</File>
<File
RelativePath=".\CD3D9Texture.h">
RelativePath="CD3D9Texture.h">
</File>
</Filter>
<Filter
Name="Burning Video">
<File
RelativePath=".\CBurningShader_Raster_Reference.cpp">
RelativePath="CBurningShader_Raster_Reference.cpp">
</File>
<File
RelativePath=".\CDepthBuffer.cpp">
RelativePath="CDepthBuffer.cpp">
</File>
<File
RelativePath=".\CDepthBuffer.h">
RelativePath="CDepthBuffer.h">
</File>
<File
RelativePath=".\CSoftware2MaterialRenderer.h">
RelativePath="CSoftware2MaterialRenderer.h">
</File>
<File
RelativePath=".\CSoftwareDriver2.cpp">
RelativePath="CSoftwareDriver2.cpp">
</File>
<File
RelativePath=".\CSoftwareDriver2.h">
RelativePath="CSoftwareDriver2.h">
</File>
<File
RelativePath=".\CSoftwareTexture2.cpp">
RelativePath="CSoftwareTexture2.cpp">
</File>
<File
RelativePath=".\CSoftwareTexture2.h">
RelativePath="CSoftwareTexture2.h">
</File>
<File
RelativePath=".\CTRGouraud2.cpp">
RelativePath="CTRGouraud2.cpp">
</File>
<File
RelativePath=".\CTRGouraudAlpha2.cpp">
RelativePath="CTRGouraudAlpha2.cpp">
</File>
<File
RelativePath=".\CTRGouraudAlphaNoZ2.cpp">
RelativePath="CTRGouraudAlphaNoZ2.cpp">
</File>
<File
RelativePath=".\CTRTextureBlend.cpp">
RelativePath="CTRTextureBlend.cpp">
</File>
<File
RelativePath=".\CTRTextureDetailMap2.cpp">
RelativePath="CTRTextureDetailMap2.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraud2.cpp">
RelativePath="CTRTextureGouraud2.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudAdd2.cpp">
RelativePath="CTRTextureGouraudAdd2.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudAddNoZ2.cpp">
RelativePath="CTRTextureGouraudAddNoZ2.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudAlpha.cpp">
RelativePath="CTRTextureGouraudAlpha.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudAlphaNoZ.cpp">
RelativePath="CTRTextureGouraudAlphaNoZ.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudNoZ2.cpp">
RelativePath="CTRTextureGouraudNoZ2.cpp">
</File>
<File
RelativePath=".\CTRTextureGouraudVertexAlpha2.cpp">
RelativePath="CTRTextureGouraudVertexAlpha2.cpp">
</File>
<File
RelativePath=".\CTRTextureLightMap2_Add.cpp">
RelativePath="CTRTextureLightMap2_Add.cpp">
</File>
<File
RelativePath=".\CTRTextureLightMap2_M1.cpp">
RelativePath="CTRTextureLightMap2_M1.cpp">
</File>
<File
RelativePath=".\CTRTextureLightMap2_M2.cpp">
RelativePath="CTRTextureLightMap2_M2.cpp">
</File>
<File
RelativePath=".\CTRTextureLightMap2_M4.cpp">
RelativePath="CTRTextureLightMap2_M4.cpp">
</File>
<File
RelativePath=".\CTRTextureLightMapGouraud2_M4.cpp">
RelativePath="CTRTextureLightMapGouraud2_M4.cpp">
</File>
<File
RelativePath=".\CTRTextureWire2.cpp">
RelativePath="CTRTextureWire2.cpp">
</File>
<File
RelativePath=".\IBurningShader.cpp">
RelativePath="IBurningShader.cpp">
</File>
<File
RelativePath=".\IBurningShader.h">
RelativePath="IBurningShader.h">
</File>
<File
RelativePath=".\IDepthBuffer.h">
RelativePath="IDepthBuffer.h">
</File>
<File
RelativePath=".\S4DVertex.h">
RelativePath="S4DVertex.h">
</File>
<File
RelativePath=".\SoftwareDriver2_compile_config.h">
RelativePath="SoftwareDriver2_compile_config.h">
</File>
<File
RelativePath=".\SoftwareDriver2_helper.h">
RelativePath="SoftwareDriver2_helper.h">
</File>
</Filter>
</Filter>
<Filter
Name="scene impl">
<File
RelativePath=".\CDefaultSceneNodeAnimatorFactory.cpp">
RelativePath="CDefaultSceneNodeAnimatorFactory.cpp">
</File>
<File
RelativePath=".\CDefaultSceneNodeAnimatorFactory.h">
RelativePath="CDefaultSceneNodeAnimatorFactory.h">
</File>
<File
RelativePath=".\CDefaultSceneNodeFactory.cpp">
RelativePath="CDefaultSceneNodeFactory.cpp">
</File>
<File
RelativePath=".\CDefaultSceneNodeFactory.h">
RelativePath="CDefaultSceneNodeFactory.h">
</File>
<File
RelativePath=".\CGeometryCreator.cpp">
RelativePath="CGeometryCreator.cpp">
</File>
<File
RelativePath=".\CGeometryCreator.h">
RelativePath="CGeometryCreator.h">
</File>
<File
RelativePath=".\CMeshCache.cpp">
RelativePath="CMeshCache.cpp">
</File>
<File
RelativePath=".\CMeshCache.h">
RelativePath="CMeshCache.h">
</File>
<File
RelativePath="CMeshManipulator.cpp">
@ -1239,27 +1248,27 @@
RelativePath="CMeshManipulator.h">
</File>
<File
RelativePath=".\CSceneManager.cpp">
RelativePath="CSceneManager.cpp">
</File>
<File
RelativePath=".\CSceneManager.h">
RelativePath="CSceneManager.h">
</File>
<File
RelativePath=".\OctTree.h">
RelativePath="OctTree.h">
</File>
<Filter
Name="loaders">
<File
RelativePath=".\C3DSMeshFileLoader.cpp">
RelativePath="C3DSMeshFileLoader.cpp">
</File>
<File
RelativePath=".\C3DSMeshFileLoader.h">
RelativePath="C3DSMeshFileLoader.h">
</File>
<File
RelativePath=".\CAnimatedMeshMD2.cpp">
RelativePath="CAnimatedMeshMD2.cpp">
</File>
<File
RelativePath=".\CAnimatedMeshMD2.h">
RelativePath="CAnimatedMeshMD2.h">
</File>
<File
RelativePath=".\CAnimatedMeshMD3.cpp">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="Irrlicht"
ProjectGUID="{E08E042A-6C45-411B-92BE-3CC31331019F}"
RootNamespace="Irrlicht"
@ -747,6 +747,10 @@
<Filter
Name="gui"
>
<File
RelativePath="..\..\include\EGUIAlignment.h"
>
</File>
<File
RelativePath=".\..\..\include\EGUIElementTypes.h"
>
@ -1040,6 +1044,14 @@
RelativePath="CGUITabControl.h"
>
</File>
<File
RelativePath=".\CGUITable.cpp"
>
</File>
<File
RelativePath=".\CGUITable.h"
>
</File>
<File
RelativePath="CGUIToolBar.cpp"
>

View File

@ -119,6 +119,7 @@
<Unit filename="../../include/IGUISpriteBank.h" />
<Unit filename="../../include/IGUIStaticText.h" />
<Unit filename="../../include/IGUITabControl.h" />
<Unit filename="../../include/IGUITable.h" />
<Unit filename="../../include/IGUIToolbar.h" />
<Unit filename="../../include/IGUIWindow.h" />
<Unit filename="../../include/IImage.h" />
@ -346,6 +347,8 @@
<Unit filename="CGUIStaticText.h" />
<Unit filename="CGUITabControl.cpp" />
<Unit filename="CGUITabControl.h" />
<Unit filename="CGUITable.cpp" />
<Unit filename="CGUITable.h" />
<Unit filename="CGUIToolBar.cpp" />
<Unit filename="CGUIToolBar.h" />
<Unit filename="CGUIWindow.cpp" />

View File

@ -153,6 +153,7 @@
<Unit filename="..\..\include\IGUISpriteBank.h" />
<Unit filename="..\..\include\IGUIStaticText.h" />
<Unit filename="..\..\include\IGUITabControl.h" />
<Unit filename="..\..\include\IGUITable.h" />
<Unit filename="..\..\include\IGUIToolbar.h" />
<Unit filename="..\..\include\IGUIWindow.h" />
<Unit filename="..\..\include\IImage.h" />
@ -363,6 +364,8 @@
<Unit filename="CGUIStaticText.h" />
<Unit filename="CGUITabControl.cpp" />
<Unit filename="CGUITabControl.h" />
<Unit filename="CGUITable.cpp" />
<Unit filename="CGUITable.h" />
<Unit filename="CGUIToolBar.cpp" />
<Unit filename="CGUIToolBar.h" />
<Unit filename="CGUIWindow.cpp" />

View File

@ -35,7 +35,7 @@ IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o
IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceStub.o CIrrDeviceWin32.o CLogger.o COSOperator.o Irrlicht.o os.o
IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o
IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o
ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o
JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcphuff.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdphuff.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jidctred.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o
LIBPNGOBJ = libpng/png.o libpng/pngerror.o libpng/pngget.o libpng/pngmem.o libpng/pngpread.o libpng/pngread.o libpng/pngrio.o libpng/pngrtran.o libpng/pngrutil.o libpng/pngset.o libpng/pngtrans.o libpng/pngwio.o libpng/pngwrite.o libpng/pngwtran.o libpng/pngwutil.o

View File

@ -54,13 +54,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
//L"Sprite Editor"
//Environment->addGUIElement("textureCacheBrowser", this);
IGUITab* OptionsTab = TabControl->addTab(L"Attributes");
IGUITabControl *AttribTabControl = environment->addTabControl(core::rect<s32>(1,1,100,100), OptionsTab, false, true);
AttribTabControl->setRelativePosition( core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f));
AttribTabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
IGUITab* EditorTab = AttribTabControl->addTab(L"Editor");
IGUITab* EditorTab = TabControl->addTab(L"Editor");
OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab);
OptionEditor->grab();
OptionEditor->setID(EGUIEDCE_OPTION_EDITOR);
@ -69,14 +63,14 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rec
if (Parent && Parent->getParent() == Environment->getRootGUIElement())
{
IGUITab* EnvTab = AttribTabControl->addTab(L"Env");
IGUITab* EnvTab = TabControl->addTab(L"Env");
EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab);
EnvEditor->grab();
EnvEditor->setID(EGUIEDCE_ENV_EDITOR);
EnvEditor->setRelativePosition(core::rect<f32>(0.0f, 0.0f, 1.0f, 1.0f));
EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
}
IGUITab* ElementTab = AttribTabControl->addTab(L"Element");
IGUITab* ElementTab = TabControl->addTab(L"Element");
AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab);
AttribEditor->grab();

View File

@ -70,7 +70,7 @@ int main()
now we add the GUI Editor Workspace
*/
env->loadGUI("c:\\out.xml");
env->loadGUI("guiTest.xml");
env->addGUIElement("GUIEditor");