tools/tooluidemo/ortooluidemo_tool.cxx

tools/tooluidemo/ortooluidemo_tool.cxx
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2009 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
//--- Class declaration
#include "ortooluidemo_tool.h"
//--- Registration variables
#define ORTOOLUIDEMO__CLASS ORTOOLUIDEMO__CLASSNAME
#define ORTOOLUIDEMO__NAME "UI Demo"
#define ORTOOLUIDEMO__DESC "UI Demo Tool Description"
//--- FiLMBOX implementation and registration
FBToolImplementation( ORTOOLUIDEMO__CLASS );
FBRegisterTool ( ORTOOLUIDEMO__CLASS,
ORTOOLUIDEMO__NAME,
ORTOOLUIDEMO__DESC,
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* Tool creation function.
************************************************/
bool ORToolUIDemo::FBCreate()
{
StartSize[0] = 600;
StartSize[1] = 350;
// UI Management
UICreate ();
UIConfigure ();
FBSystem lSystem;
mScene = lSystem.Scene;
// Tool callbacks
OnShow.Add ( this, (FBCallback)&ORToolUIDemo::EventToolShow );
OnIdle.Add ( this, (FBCallback)&ORToolUIDemo::EventToolIdle );
OnPaint.Add ( this, (FBCallback)&ORToolUIDemo::EventToolPaint );
OnInput.Add ( this, (FBCallback)&ORToolUIDemo::EventToolInput );
OnResize.Add( this, (FBCallback)&ORToolUIDemo::EventToolResize );
mScene->OnChange.Add( this, (FBCallback) &ORToolUIDemo::EventSceneChange );
return true;
}
/************************************************
* FiLMBOX Destruction function.
************************************************/
void ORToolUIDemo::FBDestroy()
{
// Remove tool callbacks
OnShow.Remove ( this, (FBCallback)&ORToolUIDemo::EventToolShow );
OnIdle.Remove ( this, (FBCallback)&ORToolUIDemo::EventToolIdle );
OnPaint.Remove ( this, (FBCallback)&ORToolUIDemo::EventToolPaint );
OnInput.Remove ( this, (FBCallback)&ORToolUIDemo::EventToolInput );
OnResize.Remove ( this, (FBCallback)&ORToolUIDemo::EventToolResize);
mScene->OnChange.Remove( this, (FBCallback) &ORToolUIDemo::EventSceneChange );
}
/************************************************
* Create the UI.
************************************************/
void ORToolUIDemo::UICreate()
{
int lS = 4;
// Add regions
AddRegion( "LabelDirections", "LabelDirections",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
-lS, kFBAttachRight, "", 1.0,
30, kFBAttachNone, NULL, 1.0 );
AddRegion( "TabPanel", "TabPanel",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "LabelDirections", 1.0,
-lS, kFBAttachRight, "", 1.0,
25, kFBAttachNone, NULL, 1.0 );
AddRegion( "Layout", "Layout",
0, kFBAttachLeft, "TabPanel", 1.0,
0, kFBAttachBottom, "TabPanel", 1.0,
0, kFBAttachRight, "TabPanel", 1.0,
-lS, kFBAttachBottom, "", 1.0 );
// Assign regions
SetControl ("LabelDirections", mLabelDirections );
SetControl ("TabPanel",mTabPanel );
SetControl ("Layout", mLayout[0] );
// Create sub-layouts
UICreateLayout0();
UICreateLayout1();
UICreateLayout2();
UICreateLayout3();
UICreateLayout4();
UICreateLayout5();
UICreateLayout6();
UICreateLayout7();
UICreateLayout8();
UICreateLayout9();
}
/************************************************
* Create the UI layout 0.
************************************************/
void ORToolUIDemo::UICreateLayout0()
{
int lS = 4;
int lW = 100;
int lH = 18;
// Add regions
mLayout[0].AddRegion("Button0", "Button0",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, "", 1.0,
lH, kFBAttachNone, "", 1.0 );
mLayout[0].AddRegion("Button1", "Button1",
0, kFBAttachLeft, "Button0", 1.0,
lS, kFBAttachBottom,"Button0", 1.0,
0, kFBAttachWidth, "Button0", 1.0,
0, kFBAttachHeight,"Button0", 1.0 );
mLayout[0].AddRegion("Button2", "Button2",
0, kFBAttachLeft, "Button1", 1.0,
lS, kFBAttachBottom,"Button1", 1.0,
0, kFBAttachWidth, "Button1", 1.0,
0, kFBAttachHeight,"Button1", 1.0 );
mLayout[0].AddRegion("Button3", "Button3",
0, kFBAttachLeft, "Button2", 1.0,
lS, kFBAttachBottom,"Button2", 1.0,
0, kFBAttachWidth, "Button2", 1.0,
0, kFBAttachHeight,"Button2", 1.0 );
mLayout[0].AddRegion("Button4", "Button4",
0, kFBAttachLeft, "Button3", 1.0,
lS, kFBAttachBottom,"Button3", 1.0,
0, kFBAttachWidth, "Button3", 1.0,
0, kFBAttachHeight,"Button3", 1.0 );
mLayout[0].AddRegion("Button5", "Button5",
0, kFBAttachLeft, "Button4", 1.0,
lS, kFBAttachBottom,"Button4", 1.0,
0, kFBAttachWidth, "Button4", 1.0,
0, kFBAttachHeight,"Button4", 1.0 );
// Assign regions
mLayout[0].SetControl("Button0", mButton[0] );
mLayout[0].SetControl("Button1", mButton[1] );
mLayout[0].SetControl("Button2", mButton[2] );
mLayout[0].SetControl("Button3", mButton[3] );
mLayout[0].SetControl("Button4", mButton[4] );
mLayout[0].SetControl("Button5", mButton[5] );
}
/************************************************
* Create the UI layout 1.
************************************************/
void ORToolUIDemo::UICreateLayout1()
{
int lS = 4;
int lW = 100;
int lH = 18;
// Add regions
mLayout[1].AddRegion("List0", "List0",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, "", 1.0,
lH, kFBAttachNone, "", 1.0 );
mLayout[1].AddRegion("List1", "List1",
0, kFBAttachLeft, "List0", 1.0,
lS, kFBAttachBottom,"List0", 1.0,
0, kFBAttachWidth, "List0", 1.0,
2*lH, kFBAttachNone, NULL, 1.0 );
// Assign regions
mLayout[1].SetControl("List0", mList[0] );
mLayout[1].SetControl("List1", mList[1] );
}
/************************************************
* Create the UI layout 2.
************************************************/
void ORToolUIDemo::UICreateLayout2()
{
int lS = 4;
int lW = 200;
int lH = 18;
// Add regions
mLayout[2].AddRegion("Label", "Label",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, "", 1.0,
lH, kFBAttachNone, "", 1.0 );
mLayout[2].AddRegion("Edit", "Edit",
0, kFBAttachLeft, "Label", 1.0,
lS, kFBAttachBottom, "Label", 1.0,
0, kFBAttachWidth, "Label", 1.0,
0, kFBAttachHeight, "Label", 1.0 );
mLayout[2].AddRegion("EditNumber", "EditNumber",
0, kFBAttachLeft, "Edit", 1.0,
lS, kFBAttachBottom, "Edit", 1.0,
0, kFBAttachWidth, "Edit", 1.0,
0, kFBAttachHeight, "Edit", 1.0 );
mLayout[2].AddRegion("EditVector", "EditVector",
0, kFBAttachLeft, "EditNumber", 1.0,
lS, kFBAttachBottom, "EditNumber", 1.0,
0, kFBAttachWidth, "EditNumber", 1.0,
0, kFBAttachHeight, "EditNumber", 1.0 );
mLayout[2].AddRegion("EditColor", "EditColor",
0, kFBAttachLeft, "EditVector", 1.0,
lS, kFBAttachBottom, "EditVector", 1.0,
0, kFBAttachWidth, "EditVector", 1.0,
0, kFBAttachHeight, "EditVector", 1.0 );
mLayout[2].AddRegion("TimeCode", "TimeCode",
0, kFBAttachLeft, "EditColor", 1.0,
lS, kFBAttachBottom, "EditColor", 1.0,
0, kFBAttachWidth, "EditColor", 1.0,
0, kFBAttachHeight, "EditColor", 1.0 );
// Assign regions
mLayout[2].SetControl( "Label", mLabel );
mLayout[2].SetControl( "Edit", mEdit );
mLayout[2].SetControl( "EditNumber", mEditNumber );
mLayout[2].SetControl( "EditVector", mEditVector );
mLayout[2].SetControl( "EditColor", mEditColor );
mLayout[2].SetControl( "TimeCode", mTimeCode );
}
/************************************************
* Create the UI layout 3.
************************************************/
void ORToolUIDemo::UICreateLayout3()
{
int lS = 4;
int lW = 100;
int lH = 50;
// Add regions
mLayout[3].AddRegion("Container0", "Container0",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[3].AddRegion("Container1", "Container1",
0, kFBAttachLeft, "Container0", 1.0,
lS, kFBAttachBottom, "Container0", 1.0,
0, kFBAttachWidth, "Container0", 1.0,
0, kFBAttachHeight, "Container0", 1.0 );
mLayout[3].AddRegion("Container2", "Container2",
lS, kFBAttachRight, "Container0", 1.0,
0, kFBAttachTop, "Container0", 1.0,
0, kFBAttachWidth, "Container0", 1.0,
0, kFBAttachHeight, "Container0", 1.0 );
mLayout[3].AddRegion("Container3", "Container3",
0, kFBAttachLeft, "Container2", 1.0,
lS, kFBAttachBottom, "Container2", 1.0,
0, kFBAttachWidth, "Container2", 1.0,
0, kFBAttachHeight, "Container2", 1.0 );
mLayout[3].AddRegion("Container4", "Container4",
lS, kFBAttachRight, "Container2", 1.0,
0, kFBAttachTop, "Container2", 1.0,
0, kFBAttachWidth, "Container2", 1.0,
0, kFBAttachHeight, "Container2", 1.0 );
mLayout[3].AddRegion("Container5", "Container5",
0, kFBAttachLeft, "Container4", 1.0,
lS, kFBAttachBottom, "Container4", 1.0,
0, kFBAttachWidth, "Container4", 1.0,
0, kFBAttachHeight, "Container4", 1.0 );
mLayout[3].AddRegion("Container6", "Container6",
lS, kFBAttachRight, "Container4", 1.0,
0, kFBAttachTop, "Container4", 1.0,
0, kFBAttachWidth, "Container4", 1.0,
0, kFBAttachHeight, "Container4", 1.0 );
mLayout[3].AddRegion("Container7", "Container7",
0, kFBAttachLeft, "Container6", 1.0,
lS, kFBAttachBottom, "Container6", 1.0,
0, kFBAttachWidth, "Container6", 1.0,
0, kFBAttachHeight, "Container6", 1.0 );
mLayout[3].AddRegion("Container8", "Container8",
lS, kFBAttachRight, "Container6", 1.0,
0, kFBAttachTop, "Container6", 1.0,
0, kFBAttachWidth, "Container6", 1.0,
0, kFBAttachHeight, "Container6", 1.0 );
mLayout[3].AddRegion("Container9", "Container9",
0, kFBAttachLeft, "Container8", 1.0,
lS, kFBAttachBottom, "Container8", 1.0,
0, kFBAttachWidth, "Container8", 1.0,
0, kFBAttachHeight, "Container8", 1.0 );
mLayout[3].AddRegion("Container10", "Container10",
lS, kFBAttachRight, "Container8", 1.0,
0, kFBAttachTop, "Container8", 1.0,
0, kFBAttachWidth, "Container8", 1.0,
0, kFBAttachHeight, "Container8", 1.0 );
mLayout[3].AddRegion("Container11", "Container11",
0, kFBAttachLeft, "Container10", 1.0,
lS, kFBAttachBottom, "Container10", 1.0,
0, kFBAttachWidth, "Container10", 1.0,
0, kFBAttachHeight, "Container10", 1.0 );
// Assign regions
mLayout[3].SetControl("Container0", mContainer[0] );
mLayout[3].SetControl("Container1", mContainer[1] );
mLayout[3].SetControl("Container2", mContainer[2] );
mLayout[3].SetControl("Container3", mContainer[3] );
mLayout[3].SetControl("Container4", mContainer[4] );
mLayout[3].SetControl("Container5", mContainer[5] );
mLayout[3].SetControl("Container6", mContainer[6] );
mLayout[3].SetControl("Container7", mContainer[7] );
mLayout[3].SetControl("Container8", mContainer[8] );
mLayout[3].SetControl("Container9", mContainer[9] );
mLayout[3].SetControl("Container10", mContainer[10] );
mLayout[3].SetControl("Container11", mContainer[11] );
}
/************************************************
* Create the UI layout 4.
************************************************/
void ORToolUIDemo::UICreateLayout4()
{
int lS = 4;
int lW = 200;
int lH = 50;
// Add regions
mLayout[4].AddRegion( "Image", "Image",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[4].AddRegion( "Slider0", "Slider0",
0, kFBAttachLeft, "Image", 1.0,
lS, kFBAttachBottom, "Image", 1.0,
0, kFBAttachWidth, "Image", 1.0,
0, kFBAttachHeight, "Image", 1.0 );
mLayout[4].AddRegion( "Slider1", "Slider1",
lS, kFBAttachRight, "Image", 1.0,
0, kFBAttachTop, "Image", 1.0,
0, kFBAttachWidth, "Image", 1.0,
0, kFBAttachHeight, "Image", 1.0 );
mLayout[4].AddRegion( "Thermometer", "Thermometer",
0, kFBAttachLeft, "Slider1", 1.0,
lS, kFBAttachBottom, "Slider1", 1.0,
0, kFBAttachWidth, "Slider1", 1.0,
0, kFBAttachHeight, "Slider1", 1.0 );
mLayout[4].AddRegion( "View", "View",
lS, kFBAttachRight, "Slider1", 1.0,
0, kFBAttachTop, "Slider1", 1.0,
0, kFBAttachWidth, "Slider1", 1.0,
0, kFBAttachHeight, "Slider1", 1.0 );
mLayout[4].AddRegion( "Tree", "Tree",
0, kFBAttachLeft, "View", 1.0,
lS, kFBAttachBottom, "View", 1.0,
0, kFBAttachWidth, "View", 1.0,
0, kFBAttachHeight, "View", 1.0 );
// Assign regions
mLayout[4].SetControl( "Image", mImage );
mLayout[4].SetControl( "Slider0", mSlider[0] );
mLayout[4].SetControl( "Slider1", mSlider[1] );
mLayout[4].SetControl( "Thermometer", mThermometer );
mLayout[4].SetView ( "View", mView );
}
/************************************************
* Create the UI layout 5.
************************************************/
void ORToolUIDemo::UICreateLayout5()
{
int lS = 4;
// Add region
mLayout[5].AddRegion("Spread", "Spread",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
-lS, kFBAttachRight, "", 1.0,
-lS, kFBAttachBottom, "", 1.0 );
// Assign region
mLayout[5].SetControl("Spread", mSpread );
}
/************************************************
* Create the UI layout 6.
************************************************/
void ORToolUIDemo::UICreateLayout6()
{
int lS = 10;
int lW = 80;
int lH = 50;
// Add regions
mLayout[6].AddRegion( "ButtonInset", "ButtonInset",
5, kFBAttachLeft, "", 1.0,
5, kFBAttachTop, "", 1.0,
100, kFBAttachNone, NULL, 1.0,
25, kFBAttachNone, NULL, 1.0 );
mLayout[6].AddRegion( "LayoutRegion0", "LayoutRegion0",
lS, kFBAttachRight, "ButtonInset", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[6].AddRegion( "LayoutRegion1", "LayoutRegion1",
0, kFBAttachLeft, "LayoutRegion0", 1.0,
lS, kFBAttachBottom, "LayoutRegion0", 1.0,
0, kFBAttachWidth, "LayoutRegion0", 1.0,
0, kFBAttachHeight, "LayoutRegion0", 1.0 );
mLayout[6].AddRegion( "LayoutRegion2", "LayoutRegion2",
0, kFBAttachLeft, "LayoutRegion1", 1.0,
lS, kFBAttachBottom, "LayoutRegion1", 1.0,
0, kFBAttachWidth, "LayoutRegion1", 1.0,
0, kFBAttachHeight, "LayoutRegion1", 1.0 );
mLayout[6].AddRegion( "LayoutRegion3", "LayoutRegion3",
lS, kFBAttachRight, "LayoutRegion0", 1.0,
0, kFBAttachTop, "LayoutRegion0", 1.0,
0, kFBAttachWidth, "LayoutRegion0", 1.0,
0, kFBAttachHeight, "LayoutRegion0", 1.0 );
mLayout[6].AddRegion( "LayoutRegion4", "LayoutRegion4",
0, kFBAttachLeft, "LayoutRegion3", 1.0,
lS, kFBAttachBottom, "LayoutRegion3", 1.0,
0, kFBAttachWidth, "LayoutRegion3", 1.0,
0, kFBAttachHeight, "LayoutRegion3", 1.0 );
mLayout[6].AddRegion( "LayoutRegion5", "LayoutRegion5",
0, kFBAttachLeft, "LayoutRegion4", 1.0,
lS, kFBAttachBottom, "LayoutRegion4", 1.0,
0, kFBAttachWidth, "LayoutRegion4", 1.0,
0, kFBAttachHeight, "LayoutRegion4", 1.0 );
mLayout[6].AddRegion( "LayoutRegion6", "LayoutRegion6",
lS, kFBAttachRight, "LayoutRegion3", 1.0,
0, kFBAttachTop, "LayoutRegion3", 1.0,
0, kFBAttachWidth, "LayoutRegion3", 1.0,
0, kFBAttachHeight, "LayoutRegion3", 1.0 );
mLayout[6].AddRegion( "LayoutRegion7", "LayoutRegion7",
0, kFBAttachLeft, "LayoutRegion6", 1.0,
lS, kFBAttachBottom, "LayoutRegion6", 1.0,
0, kFBAttachWidth, "LayoutRegion6", 1.0,
0, kFBAttachHeight, "LayoutRegion6", 1.0 );
mLayout[6].AddRegion( "LayoutRegion8", "LayoutRegion8",
0, kFBAttachLeft, "LayoutRegion7", 1.0,
lS, kFBAttachBottom, "LayoutRegion7", 1.0,
0, kFBAttachWidth, "LayoutRegion7", 1.0,
0, kFBAttachHeight, "LayoutRegion7", 1.0 );
mLayout[6].AddRegion( "LayoutRegion9", "LayoutRegion9",
lS, kFBAttachRight, "LayoutRegion6", 1.0,
0, kFBAttachTop, "LayoutRegion6", 1.0,
0, kFBAttachWidth, "LayoutRegion6", 1.0,
0, kFBAttachHeight, "LayoutRegion6", 1.0 );
mLayout[6].AddRegion( "LayoutRegion10", "LayoutRegion10",
0, kFBAttachLeft, "LayoutRegion9", 1.0,
lS, kFBAttachBottom, "LayoutRegion9", 1.0,
0, kFBAttachWidth, "LayoutRegion9", 1.0,
0, kFBAttachHeight, "LayoutRegion9", 1.0 );
mLayout[6].AddRegion( "LayoutRegion11", "LayoutRegion11",
0, kFBAttachLeft, "LayoutRegion10", 1.0,
lS, kFBAttachBottom, "LayoutRegion10", 1.0,
0, kFBAttachWidth, "LayoutRegion10", 1.0,
0, kFBAttachHeight, "LayoutRegion10", 1.0 );
// Assign regions
mLayout[6].SetControl( "ButtonInset", mButtonInset );
mLayout[6].SetControl( "LayoutRegion0", mLayoutRegion[0] );
mLayout[6].SetControl( "LayoutRegion1", mLayoutRegion[1] );
mLayout[6].SetControl( "LayoutRegion2", mLayoutRegion[2] );
mLayout[6].SetControl( "LayoutRegion3", mLayoutRegion[3] );
mLayout[6].SetControl( "LayoutRegion4", mLayoutRegion[4] );
mLayout[6].SetControl( "LayoutRegion5", mLayoutRegion[5] );
mLayout[6].SetControl( "LayoutRegion6", mLayoutRegion[6] );
mLayout[6].SetControl( "LayoutRegion7", mLayoutRegion[7] );
mLayout[6].SetControl( "LayoutRegion8", mLayoutRegion[8] );
mLayout[6].SetControl( "LayoutRegion9", mLayoutRegion[9] );
mLayout[6].SetControl( "LayoutRegion10", mLayoutRegion[10] );
mLayout[6].SetControl( "LayoutRegion11", mLayoutRegion[11] );
}
/************************************************
* Create the UI layout 7.
************************************************/
void ORToolUIDemo::UICreateLayout7()
{
int lS = 4;
int lH = 20;
// Add regions
mLayout[7].AddRegion( "LabelDirectionsProperties", "LabelDirectionsProperties",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
-lS, kFBAttachRight, NULL, 1.0,
30, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "ContainerModel", "ContainerModel",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "LabelDirectionsProperties", 1.0,
-lS, kFBAttachRight, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "ButtonNextProperty", "ButtonNextProperty",
-lS-15, kFBAttachRight, "", 1.0,
lS, kFBAttachBottom, "ContainerModel", 1.0,
-lS, kFBAttachRight, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "ButtonPreviousProperty", "ButtonPreviousProperty",
-lS-15, kFBAttachLeft, "ButtonNextProperty", 1.0,
lS, kFBAttachBottom, "ContainerModel", 1.0,
-lS, kFBAttachLeft, "ButtonNextProperty", 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "ListProperties", "ListProperties",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "ContainerModel", 1.0,
-lS, kFBAttachLeft, "ButtonPreviousProperty", 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "EditProperty", "EditProperty",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "ListProperties", 1.0,
-lS, kFBAttachRight, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[7].AddRegion( "EditPropertyModern", "EditPropertyModern",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom, "EditProperty", 1.0,
-lS, kFBAttachRight, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
// Assign regions
mLayout[7].SetControl( "LabelDirectionsProperties", mLabelDirectionsProperties );
mLayout[7].SetControl( "ContainerModel", mContainerModel );
mLayout[7].SetControl( "ListProperties", mListProperties );
mLayout[7].SetControl( "EditProperty", mEditProperty );
mLayout[7].SetControl( "EditPropertyModern", mEditPropertyModern );
mLayout[7].SetControl( "ButtonPreviousProperty", mButtonPreviousProperty );
mLayout[7].SetControl( "ButtonNextProperty", mButtonNextProperty );
}
/************************************************
* Create the UI layout 8.
************************************************/
void ORToolUIDemo::UICreateLayout8()
{
int lS = 4;
int lW = 200;
int lH = 18;
// Add regions
mLayout[8].AddRegion( "ButtonPopup", "ButtonPopup",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[8].AddRegion( "ButtonFilePopup", "ButtonFilePopup",
0, kFBAttachLeft, "ButtonPopup", 1.0,
lS, kFBAttachBottom, "ButtonPopup", 1.0,
0, kFBAttachWidth, "ButtonPopup", 1.0,
0, kFBAttachHeight, "ButtonPopup", 1.0 );
mLayout[8].AddRegion( "ButtonProgress", "ButtonProgress",
0, kFBAttachLeft, "ButtonFilePopup", 1.0,
lS, kFBAttachBottom, "ButtonFilePopup", 1.0,
0, kFBAttachWidth, "ButtonFilePopup", 1.0,
0, kFBAttachHeight, "ButtonFilePopup", 1.0 );
mLayout[8].AddRegion( "ButtonMessageBox", "ButtonMessageBox",
0, kFBAttachLeft, "ButtonProgress", 1.0,
lS, kFBAttachBottom, "ButtonProgress", 1.0,
0, kFBAttachWidth, "ButtonProgress", 1.0,
0, kFBAttachHeight, "ButtonProgress", 1.0 );
mLayout[8].AddRegion( "ButtonMessageCheck", "ButtonMessageCheck",
0, kFBAttachLeft, "ButtonMessageBox", 1.0,
lS, kFBAttachBottom, "ButtonMessageBox", 1.0,
0, kFBAttachWidth, "ButtonMessageBox", 1.0,
0, kFBAttachHeight, "ButtonMessageBox", 1.0 );
mLayout[8].AddRegion( "ButtonMessageValue", "ButtonMessageValue",
0, kFBAttachLeft, "ButtonMessageCheck", 1.0,
lS, kFBAttachBottom, "ButtonMessageCheck", 1.0,
0, kFBAttachWidth, "ButtonMessageCheck", 1.0,
0, kFBAttachHeight, "ButtonMessageCheck", 1.0 );
mPopup.AddRegion ( "ButtonClosePopup", "ButtonClosePopup",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
-lS, kFBAttachRight, "", 1.0,
-lS, kFBAttachBottom, "", 1.0 );
// Assign regions
mLayout[8].SetControl( "ButtonPopup", mButtonPopup );
mLayout[8].SetControl( "ButtonFilePopup", mButtonFilePopup );
mLayout[8].SetControl( "ButtonProgress", mButtonProgress );
mLayout[8].SetControl( "ButtonMessageBox", mButtonMessageBox );
mLayout[8].SetControl( "ButtonMessageCheck", mButtonMessageCheck );
mLayout[8].SetControl( "ButtonMessageValue", mButtonMessageValue );
mPopup.SetControl ( "ButtonClosePopup", mButtonClosePopup );
}
/************************************************
* Create the UI layout 9.
************************************************/
void ORToolUIDemo::UICreateLayout9()
{
int lS = 4;
int lW = 400;
int lH = 250;
// Add regions
mLayout[9].AddRegion( "Tree", "Tree",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0 );
mLayout[9].SetControl( "Tree", mTree );
}
/************************************************
* Configure the UI.
************************************************/
void ORToolUIDemo::UIConfigure()
{
mLabelDirections.Caption = "This tool gives a demonstration of many of the different\n"
"UI elements avaialble using the Open Reality SDK.";
// Configure main layout
mTabPanel.Items.SetString ("Buttons~Lists~Edit~Container~Views~Spreadsheet~Regions~Properties~Special~Tree");
mTabPanel.OnChange.Add ( this, (FBCallback)&ORToolUIDemo::EventTabPanelChange );
SetBorder ("Layout", kFBStandardBorder, false,true, 1, 0,90,0);
// Configure sub layouts
UIConfigureLayout0();
UIConfigureLayout1();
UIConfigureLayout2();
UIConfigureLayout3();
UIConfigureLayout4();
UIConfigureLayout5();
UIConfigureLayout6();
UIConfigureLayout7();
UIConfigureLayout8();
UIConfigureLayout9();
}
/************************************************
* Configure the UI layout 0.
************************************************/
void ORToolUIDemo::UIConfigureLayout0()
{
mButton[0].Caption = "Push"; mButton[0].Style = kFBPushButton;
mButton[1].Caption = "Bitmap"; mButton[1].Style = kFBBitmapButton;
mButton[2].Caption = "CheckBox"; mButton[2].Style = kFBCheckbox;
mButton[3].Caption = "Radio"; mButton[3].Style = kFBRadioButton;
mButton[4].Caption = "2States"; mButton[4].Style = kFB2States;
mButton[5].Caption = "Bitmap2"; mButton[5].Style = kFBBitmap2States;
FBColor lColorRed( 1.0, 0.0, 0.0 );
mButton[4].SetStateColor( kFBButtonState0, lColorRed );
FBColor lColorGreen( 0.0, 1.0, 0.0 );
mButton[4].SetStateColor( kFBButtonState1, lColorGreen );
}
/************************************************
* Configure the UI layout 1.
************************************************/
void ORToolUIDemo::UIConfigureLayout1()
{
mList[0].Items.SetString("Drop~List" ); mList[0].Style = kFBDropDownList;
mList[1].Items.SetString("Vertical~List" ); mList[1].Style = kFBVerticalList;
}
/************************************************
* Configure the UI layout 2.
************************************************/
void ORToolUIDemo::UIConfigureLayout2()
{
mLabel.Caption = "Label";
mEdit.Text = "Edit";
}
/************************************************
* Configure the UI layout 3.
************************************************/
void ORToolUIDemo::UIConfigureLayout3()
{
mContainer[0].Items.Add( "Horiz", 0 );
mContainer[0].Items.Add( "None", 1 );
mContainer[0].Orientation = kFBHorizontal;
// mContainer[0].IconPosition = kFBIconNone;
mContainer[1].Items.Add( "Horiz", 0 );
mContainer[1].Items.Add( "Left", 1 );
mContainer[1].Orientation = kFBHorizontal;
mContainer[1].IconPosition = kFBIconLeft;
mContainer[2].Items.Add( "Horiz", 0 );
mContainer[2].Items.Add( "Top", 1 );
mContainer[2].Orientation = kFBHorizontal;
mContainer[2].IconPosition = kFBIconTop;
mContainer[3].Items.Add( "Horiz", 0 );
mContainer[3].Items.Add( "Right", 1 );
mContainer[3].Orientation = kFBHorizontal;
// mContainer[3].IconPosition = kFBIconRight;
mContainer[4].Items.Add( "Horiz", 0 );
mContainer[4].Items.Add( "Bottom", 1 );
mContainer[4].Orientation = kFBHorizontal;
// mContainer[4].IconPosition = kFBIconBottom;
mContainer[5].Items.Add( "Horiz", 0 );
mContainer[5].Items.Add( "Icon", 1 );
mContainer[5].Orientation = kFBHorizontal;
// mContainer[5].IconPosition = kFBIconOnly;
mContainer[6].Items.Add( "Vert", 0 );
mContainer[6].Items.Add( "None", 1 );
mContainer[6].Orientation = kFBVertical;
// mContainer[6].IconPosition = kFBIconNone;
mContainer[7].Items.Add( "Vert", 0 );
mContainer[7].Items.Add( "Left", 1 );
mContainer[7].Orientation = kFBVertical;
mContainer[7].IconPosition = kFBIconLeft;
mContainer[8].Items.Add( "Vert", 0 );
mContainer[8].Items.Add( "Top", 1 );
mContainer[8].Orientation = kFBVertical;
mContainer[8].IconPosition = kFBIconTop;
mContainer[9].Items.Add( "Vert", 0 );
mContainer[9].Items.Add( "Right", 1 );
mContainer[9].Orientation = kFBVertical;
// mContainer[9].IconPosition = kFBIconRight;
mContainer[10].Items.Add( "Vert", 0 );
mContainer[10].Items.Add( "Bottom", 1 );
mContainer[10].Orientation = kFBVertical;
// mContainer[10].IconPosition = kFBIconBottom;
mContainer[11].Items.Add( "Vert", 0 );
mContainer[11].Items.Add( "Icon", 1 );
mContainer[11].Orientation = kFBVertical;
// mContainer[11].IconPosition = kFBIconOnly;
int i;
for( i=0; i<12; i++ )
{
mContainer[i].ItemIconSet ( 0, "character_actor.png" );
mContainer[i].ItemIconSet ( 1, "devices_body.png" );
mContainer[i].ItemWidth = 100;
mContainer[i].ItemHeight = 50;
}
}
/************************************************
* Configure the UI layout 4.
************************************************/
void ORToolUIDemo::UIConfigureLayout4()
{
mImage.Filename = "character_actor.png";
mSlider[0].Orientation = kFBHorizontal;
mSlider[1].Orientation = kFBVertical;
}
/************************************************
* Configure the UI layout 5.
************************************************/
void ORToolUIDemo::UIConfigureLayout5()
{
mSpread.Caption = "SpreadSheet";
mSpread.MultiSelect = true;
mSpread.ColumnAdd( "Col 1" );
mSpread.ColumnAdd( "Col 2" );
mSpread.ColumnAdd( "Col 3" );
mSpread.RowAdd( "Row 1", 0 );
mSpread.RowAdd( "Row 2", 1 );
mSpread.RowAdd( "Row 3", 2 );
}
/************************************************
* Configure the UI layout 6.
************************************************/
void ORToolUIDemo::UIConfigureLayout6()
{
mButtonInset.Caption = "Inset";
mButtonInset.Style = kFB2States;
mButtonInset.OnClick.Add( this, (FBCallback)&ORToolUIDemo::EventButtonInsetClick );
// This will set the borders.
EventButtonInsetClick( NULL, NULL );
mLayout[6].SetRegionTitle ("LayoutRegion0", "NoBorder" );
mLayout[6].SetRegionTitle ("LayoutRegion1", "Standard" );
mLayout[6].SetRegionTitle ("LayoutRegion2", "Emboss" );
mLayout[6].SetRegionTitle ("LayoutRegion3", "EmbossSmooth" );
mLayout[6].SetRegionTitle ("LayoutRegion4", "EmbossEdgeSmooth" );
mLayout[6].SetRegionTitle ("LayoutRegion5", "EmbossSmoothEdge" );
mLayout[6].SetRegionTitle ("LayoutRegion6", "Smooth" );
mLayout[6].SetRegionTitle ("LayoutRegion7", "EdgeSmooth" );
mLayout[6].SetRegionTitle ("LayoutRegion8", "SmoothEdge" );
mLayout[6].SetRegionTitle ("LayoutRegion9", "Highlight" );
mLayout[6].SetRegionTitle ("LayoutRegion10", "Picking" );
mLayout[6].SetRegionTitle ("LayoutRegion11", "Standard" );
}
/************************************************
* Configure the UI layout 7.
************************************************/
void ORToolUIDemo::UIConfigureLayout7()
{
mContainerModel.IconPosition = kFBIconLeft;
// Set the button labels.
mLabelDirectionsProperties.Caption = "Drag and drop a model into the container. Double click to clear.";
mButtonPreviousProperty.Caption = "<";
mButtonNextProperty.Caption = ">";
// Set the tooltip strings.
mButtonPreviousProperty.PropertyList.Find( "Hint" )->SetString( "Previous Property" );
mButtonNextProperty.PropertyList.Find ( "Hint" )->SetString( "Next Property" );
// Callbacks
mContainerModel.OnDragAndDrop.Add ( this, (FBCallback) &ORToolUIDemo::EventContainerDragAndDrop );
mContainerModel.OnDblClick.Add ( this, (FBCallback) &ORToolUIDemo::EventContainerDblClick );
mButtonPreviousProperty.OnClick.Add ( this, (FBCallback) &ORToolUIDemo::EventButtonPreviousProperty );
mButtonNextProperty.OnClick.Add ( this, (FBCallback) &ORToolUIDemo::EventButtonNextProperty );
mListProperties.OnChange.Add ( this, (FBCallback) &ORToolUIDemo::EventListPropertyChange );
// Initial setup of the list.
SetupPropertyList( NULL );
}
/************************************************
* Configure the UI layout 8.
************************************************/
void ORToolUIDemo::UIConfigureLayout8()
{
mPopup.Region.X = 100;
mPopup.Region.Y = 100;
mPopup.Region.Width = 100;
mPopup.Region.Height= 100;
mButtonPopup.Caption = "Popup";
mButtonClosePopup.Caption = "Close Poupup";
mButtonFilePopup.Caption = "File Popup";
mButtonProgress.Caption = "Progress";
mButtonMessageBox.Caption = "Message Box";
mButtonMessageCheck.Caption = "Message Box: With Check";
mButtonMessageValue.Caption = "Message Box: Get User Value";
mButtonPopup.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonPopupClick );
mButtonClosePopup.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonClosePopupClick );
mButtonFilePopup.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonFilePopupClick );
mButtonProgress.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonProgressClick );
mButtonMessageBox.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonMessageBoxClick );
mButtonMessageCheck.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonMessageCheckClick );
mButtonMessageValue.OnClick.Add ( this, (FBCallback)&ORToolUIDemo::EventButtonMessageValueClick );
}
/************************************************
* Configure the UI layout 9.
************************************************/
FBArrayTemplate<FBComponent*> ComponentStack;
void ORToolUIDemo::UIConfigureLayout9()
{
int lCnt;
// FBScene* lScene = mSystem.Scene;
// lCnt = lScene->Components.GetCount(); // to force the mapping of the whole scene
FBTreeNode* lRoot = mTree.GetRoot();
mTree.Clear();
mTree.AllowExpansion = true;
mTree.AllowCollapse = true;
mTree.AutoScroll = true;
mTree.MultiSelect = true;
int i;
FBTreeNode* lSceneNode = mTree.InsertLast( lRoot, "Scene" );
FBTreeNode* lAudioSubNode = mTree.InsertLast( lRoot, "Audio" );
FBTreeNode* lCameraSubNode = mTree.InsertLast( lRoot, "Cameras" );
FBTreeNode* lConstraintNode = mTree.InsertLast( lRoot, "Constraints" );
FBTreeNode* lDevNode = mTree.InsertLast( lRoot, "Devices" );
FBTreeNode* lGroupSubNode = mTree.InsertLast( lRoot, "Groups" );
FBTreeNode* lSetSubNode = mTree.InsertLast( lRoot, "Sets" );
FBTreeNode* lLightSubNode = mTree.InsertLast( lRoot, "Lights" );
FBTreeNode* lMaterialSubNode= mTree.InsertLast( lRoot, "Material" );
FBTreeNode* lPoseSubNode = mTree.InsertLast( lRoot, "Poses" );
FBTreeNode* lShaderSubNode = mTree.InsertLast( lRoot, "Shaders" );
FBTreeNode* lTakeSubNode = mTree.InsertLast( lRoot, "Takes" );
FBTreeNode* lTextureSubNode = mTree.InsertLast( lRoot, "Textures" );
FBTreeNode* lVideoSubNode = mTree.InsertLast( lRoot, "Video" );
FBTreeNode* lFBSDK = mTree.InsertLast( lRoot, "FBSDK" );
FBTreeNode* lSceneSubNode = mTree.InsertLast( lFBSDK, "Scene" );
FBTreeNode* lManipSubNode = mTree.InsertLast( lFBSDK, "Manipulators" );
FBTreeNode* lSystemNode = mTree.InsertLast( lFBSDK, "System" );
FBTreeNode* lRenderSubNode = mTree.InsertLast( lFBSDK, "Render" );
FBTreeNode* lAnimSubNode = mTree.InsertLast( lFBSDK, "Animation" );
FBTreeNode* lStorySubNode = mTree.InsertLast( lFBSDK, "Story" );
FBTreeNode* lFolderSubNode = mTree.InsertLast( lFBSDK, "Folders" );
lCnt = FBGetComponentArray().GetCount();
for( i=0; i<lCnt; i++ )
{
FBComponent* lComp = FBGetComponentArray().operator[](i);
ComponentStack.Clear();
if( lComp->Is( FBDevice::TypeInfo ) )
{
AddToTree( lDevNode, lComp );
}
else if( lComp->Is( FBCamera::TypeInfo ) )
{
AddToTree( lCameraSubNode, lComp );
}
else if( lComp->Is( FBLight::TypeInfo )
|| lComp->Is( FBGlobalLight::TypeInfo ) )
{
AddToTree( lLightSubNode, lComp );
}
else if( lComp->Is( FBConstraint::TypeInfo ))
{
AddToTree( lConstraintNode, lComp );
}
else if( lComp->Is( FBPose::TypeInfo ) )
{
AddToTree( lPoseSubNode, lComp );
}
else if( lComp->Is( FBModel::TypeInfo ) )
{
if (FBString(lComp->Name)==FBString("Scene"))
{
AddToTree( lSceneNode, lComp, false );
}
}
else if( lComp->Is( FBShader::TypeInfo ) )
{
AddToTree( lShaderSubNode, lComp );
}
else if(lComp->Is( FBSystem::TypeInfo )
|| lComp->Is( FBApplication::TypeInfo )
|| lComp->Is( FBPlayerControl::TypeInfo )
|| lComp->Is( FBConstraintManager::TypeInfo )
#ifndef K_NO_TRIGGER
|| lComp->Is( FBTriggerManager::TypeInfo )
#endif
)
{
AddToTree( lSystemNode, lComp );
}
else if( lComp->Is( FBScene::TypeInfo ) )
{
AddToTree( lSceneSubNode, lComp, false );
}
else if(lComp->Is( FBRenderer::TypeInfo ))
{
AddToTree( lRenderSubNode, lComp );
}
else if(lComp->Is( FBMaterial::TypeInfo ))
{
AddToTree( lMaterialSubNode, lComp );
}
else if(lComp->Is( FBTexture::TypeInfo ))
{
AddToTree( lTextureSubNode, lComp );
}
else if(lComp->Is( FBVideo::TypeInfo ))
{
AddToTree( lVideoSubNode, lComp );
}
else if(lComp->Is( FBAudioIn::TypeInfo )
|| lComp->Is( FBAudioOut::TypeInfo )
)
{
AddToTree( lAudioSubNode, lComp );
}
else if(lComp->Is( FBStory::TypeInfo ))
{
AddToTree( lStorySubNode, lComp );
}
else if(lComp->Is( FBGroup::TypeInfo ))
{
AddToTree( lGroupSubNode, lComp );
}
else if(lComp->Is( FBSet::TypeInfo ))
{
AddToTree( lSetSubNode, lComp );
}
else if(lComp->Is( FBTake::TypeInfo ))
{
AddToTree( lTakeSubNode, lComp );
}
else if( lComp->Is( FBManipulator::TypeInfo ) )
{
AddToTree( lManipSubNode, lComp );
}
else if( lComp->Is( FBFolder::TypeInfo ) )
{
AddToTree( lFolderSubNode, lComp );
}
else if(lComp->Is( FBAnimationNode::TypeInfo )
|| lComp->Is( FBFCurve::TypeInfo )
)
{
AddToTree( lAnimSubNode, lComp );
}
}
}
void ORToolUIDemo::AddToTree( FBTreeNode* pNode, FBComponent* pComp, bool pAddRoot /*=true */ )
{
if( !pComp )
return;
if (ComponentStack.Find( pComp )==-1)
{
ComponentStack.Add( pComp );
FBTreeNode* lNode;
if (pAddRoot)
{
// Add this
lNode = mTree.InsertLast( pNode, pComp->Name );
lNode->Reference = (kReference)pComp;
} else
{
lNode = pNode;
}
// Add children
int i;
int lCnt = pComp->Components.GetCount();
for( i=0; i<lCnt; i++ )
{
FBComponent* lComp = pComp->Components[i];
AddToTree( lNode, lComp );
}
}
}
/************************************************
* Handle input into the tool.
************************************************/
void ORToolUIDemo::EventToolInput( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Handle tool activation (selection/unselection).
************************************************/
void ORToolUIDemo::EventToolShow( HISender pSender, HKEvent pEvent )
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
// Reset the UI here.
}
else
{
}
}
/************************************************
* UI Idle callback.
************************************************/
void ORToolUIDemo::EventToolIdle( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Paint callback for tool (on expose).
************************************************/
void ORToolUIDemo::EventToolPaint( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Tool resize callback.
************************************************/
void ORToolUIDemo::EventToolResize( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Tab panel change.
************************************************/
void ORToolUIDemo::EventTabPanelChange( HISender pSender, HKEvent pEvent )
{
switch( mTabPanel.ItemIndex )
{
case 0: SetControl( "Layout", mLayout[0] ); break;
case 1: SetControl( "Layout", mLayout[1] ); break;
case 2: SetControl( "Layout", mLayout[2] ); break;
case 3: SetControl( "Layout", mLayout[3] ); break;
case 4: SetControl( "Layout", mLayout[4] ); break;
case 5: SetControl( "Layout", mLayout[5] ); break;
case 6: SetControl( "Layout", mLayout[6] ); break;
case 7: SetControl( "Layout", mLayout[7] ); break;
case 8: SetControl( "Layout", mLayout[8] ); break;
case 9: SetControl( "Layout", mLayout[9] ); break;
}
}
/************************************************
* Button popup callback.
************************************************/
void ORToolUIDemo::EventButtonPopupClick( HISender pSender, HKEvent pEvent )
{
mPopup.Modal = true;
mPopup.Show();
}
/************************************************
* Button file popup callback.
************************************************/
void ORToolUIDemo::EventButtonFilePopupClick( HISender pSender, HKEvent pEvent )
{
FBFilePopup lFilePopup;
lFilePopup.Caption = "File Popup";
lFilePopup.Filter = "*.fbx";
// We suggest the SDK's scenes.
FBSystem lSystem;
FBString lScenesPath( lSystem.ApplicationPath );
lScenesPath += "\\..\\OpenRealitySDK\\Scenes";
lFilePopup.Path = (char*)lScenesPath;
lFilePopup.Style = kFBFilePopupOpen;
lFilePopup.Execute();
}
/************************************************
* Progress button callback.
************************************************/
void ORToolUIDemo::EventButtonProgressClick( HISender pSender, HKEvent pEvent )
{
FBProgress lProgress;
char lBuffer[30];
lProgress.Caption = "Progress Caption";
lProgress.Text = "Progress Text";
FBSleep(100);
int i;
for( i=0; i<10; i++ )
{
sprintf( lBuffer, "Progress %d", i );
lProgress.Text = lBuffer;
FBSleep(100);
}
}
/************************************************
* MessageBox button callback.
************************************************/
void ORToolUIDemo::EventButtonMessageBoxClick( HISender pSender, HKEvent pEvent )
{
FBMessageBox("Message Box", "Message", "Button 1", "Button 2", "Button 3", 1 );
}
void ORToolUIDemo::EventButtonMessageCheckClick( HISender pSender, HKEvent pEvent )
{
bool lCheck;
FBMessageBoxWithCheck( "Message Box with Check", "Check", "Button 1", "Button 2", "Button 3", "Check Box", lCheck, 0, 1 );
}
void ORToolUIDemo::EventButtonMessageValueClick( HISender pSender, HKEvent pEvent )
{
char lValue[100];
lValue[0] = '\0';
FBMessageBoxGetUserValue( "Get User Value", "Enter Password", lValue, kFBPopupPassword, "Button 1", "Button 2", "Button 3", 0 );
}
/************************************************
* Close popup button callback.
************************************************/
void ORToolUIDemo::EventButtonClosePopupClick( HISender pSender, HKEvent pEvent )
{
mPopup.Close();
}
/************************************************
* Switch layout regions Inset Values.
************************************************/
void ORToolUIDemo::EventButtonInsetClick( HISender pSender, HKEvent pEvent )
{
bool lState = mButtonInset.State != 0;
mLayout[6].SetBorder ("LayoutRegion0", kFBNoBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion1", kFBStandardBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion2", kFBEmbossBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion3", kFBEmbossSmoothBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion4", kFBEmbossEdgeSmoothBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion5", kFBEmbossSmoothEdgeBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion6", kFBStandardSmoothBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion7", kFBStandardEdgeSmoothBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion8", kFBStandardSmoothEdgeBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion9", kFBHighlightBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion10", kFBPickingBorder, true,lState, 2, 2, 90,0);
mLayout[6].SetBorder ("LayoutRegion11", kFBStandardBorder, true,lState, 2, 2, 90,0);
}
void ORToolUIDemo::EventContainerDragAndDrop( HISender pSender, HKEvent pEvent )
{
FBEventDragAndDrop lDragAndDrop( pEvent );
switch( lDragAndDrop.State )
{
{
lDragAndDrop.Accept();
}
break;
{
SetupPropertyList( (FBModel*)lDragAndDrop.Get(0) );
}
break;
}
}
void ORToolUIDemo::SetupPropertyList( FBModel* lModel )
{
mContainerModel.Items.Clear();
mListProperties.Items.Clear();
mEditProperty.Property = 0;
mEditPropertyModern.Property = 0;
mButtonPreviousProperty.Enabled = false;
mButtonNextProperty.Enabled = false;
if( lModel )
{
mContainerModel.Items.Add( lModel->Name, (kReference)lModel );
int lIdx = 0;
int lNbProps = lModel->PropertyList.GetCount();
mListProperties.Items.Add( "<Select Property>", (kReference)0 );
mListProperties.ItemIndex = 0;
for( lIdx = 0; lIdx < lNbProps; ++lIdx )
{
FBProperty* lProp = lModel->PropertyList[lIdx];
if( lProp->IsInternal() && !lProp->GetPropertyFlag( kFBPropertyFlagHideProperty ))
{
mListProperties.Items.Add( lProp->GetName(), (kReference)lProp );
}
}
mButtonPreviousProperty.Enabled = true;
mButtonNextProperty.Enabled = true;
}
}
void ORToolUIDemo::EventContainerDblClick( HISender pSender, HKEvent pEvent )
{
SetupPropertyList( NULL );
}
void ORToolUIDemo::EventListPropertyChange( HISender pSender, HKEvent pEvent )
{
FBProperty* lProp = (FBProperty*)mListProperties.Items.GetReferenceAt( mListProperties.ItemIndex );
mEditProperty.Property = lProp;
mEditPropertyModern.Property = lProp;
}
void ORToolUIDemo::EventSceneChange( HISender pSender, HKEvent pEvent )
{
if( mContainerModel.Items.GetCount() != 0 )
{
FBEventSceneChange lEvent( pEvent );
FBModel* lModel = (FBModel*)mContainerModel.Items.GetReferenceAt( 0 );
if( lEvent.Type == kFBSceneChangeDetach && (FBComponent*)lEvent.ChildComponent == lModel )
{
SetupPropertyList( NULL );
}
}
}
void ORToolUIDemo::EventButtonPreviousProperty( HISender pSender, HKEvent pEvent )
{
mListProperties.ItemIndex = ( mListProperties.ItemIndex + mListProperties.Items.GetCount() - 1 ) % mListProperties.Items.GetCount();
EventListPropertyChange( NULL, NULL );
}
void ORToolUIDemo::EventButtonNextProperty( HISender pSender, HKEvent pEvent )
{
mListProperties.ItemIndex = ( mListProperties.ItemIndex + 1 ) % mListProperties.Items.GetCount();
EventListPropertyChange( NULL, NULL );
}