miscellaneous/popup_template/orpopup_template_tool.cxx

miscellaneous/popup_template/orpopup_template_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 "orpopup_template_tool.h"
//--- Registration defines
#define ORTOOLPOPUP__CLASS ORTOOLPOPUP__CLASSNAME
#define ORTOOLPOPUP__LABEL "Popup"
#define ORTOOLPOPUP__DESC "OR - Popup Creation Tool"
//--- FiLMBOX implementation and registration
FBToolImplementation( ORTOOLPOPUP__CLASS );
FBRegisterTool ( ORTOOLPOPUP__CLASS,
ORTOOLPOPUP__LABEL,
ORTOOLPOPUP__DESC,
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* FiLMBOX Creation Function.
************************************************/
bool ORToolPopup::FBCreate()
{
// UI creation & configuration
UICreate ();
UIConfigure ();
// Successful creation.
return true;
}
/************************************************
* FiLMBOX Destruction function.
************************************************/
void ORToolPopup::FBDestroy()
{
}
/************************************************
* Create & Assigne the UI regions (for Tool).
************************************************/
void ORToolPopup::UICreate()
{
int lS = 4;
int lW = 220;
int lH = 18;
// Create regions
AddRegion( "ButtonPopupCreate", "ButtonPopupCreate",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachTop, "", 1.0,
lW, kFBAttachNone, NULL, 1.0,
lH, kFBAttachNone, NULL, 1.0);
AddRegion( "ButtonPopupTemplateCreate", "ButtonPopupTemplateCreate",
0, kFBAttachLeft, "ButtonPopupCreate", 1.0,
lS, kFBAttachBottom, "ButtonPopupCreate", 1.0,
0, kFBAttachWidth, "ButtonPopupCreate", 1.0,
0, kFBAttachHeight, "ButtonPopupCreate", 1.0);
AddRegion( "ButtonPopupTemplateNonModalCreate", "ButtonPopupTemplateNonModalCreate",
0, kFBAttachLeft, "ButtonPopupTemplateCreate", 1.0,
lS, kFBAttachBottom, "ButtonPopupTemplateCreate", 1.0,
0, kFBAttachWidth, "ButtonPopupTemplateCreate", 1.0,
0, kFBAttachHeight, "ButtonPopupTemplateCreate", 1.0);
// Assign regions
SetControl( "ButtonPopupCreate", mButtonPopupCreate );
SetControl( "ButtonPopupTemplateCreate", mBtnModalPopupTemplate );
SetControl( "ButtonPopupTemplateNonModalCreate", mBtnModelessPopupTemplate );
UICreatePopup();
}
/************************************************
* Create & Assign the UI regions (for Popup).
************************************************/
void ORToolPopup::UICreatePopup()
{
int lB = 10;
mPopup.Region.X = 100;
mPopup.Region.Y = 100;
mPopup.Region.Width = 200;
mPopup.Region.Height = 100;
mPopup.Caption = "Popup";
// Add regions
mPopup.AddRegion( "ButtonPopupClose", "ButtonPopupClose",
lB, kFBAttachLeft, "", 1.0,
lB, kFBAttachTop, "", 1.0,
-lB, kFBAttachRight, "", 1.0,
-lB, kFBAttachBottom, "", 1.0);
// Assign regions
mPopup.SetControl("ButtonPopupClose", mButtonPopupClose );
}
/************************************************
* Configure & add callbacks to the UI Elements (for Tool).
************************************************/
void ORToolPopup::UIConfigure()
{
mButtonPopupCreate.Caption = "Create Popup";
mButtonPopupCreate.OnClick.Add( this, (FBCallback) &ORToolPopup::EventButtonPopupCreateClick );
mBtnModalPopupTemplate.Caption = "Create Modal Popup [Template]";
mBtnModalPopupTemplate.OnClick.Add( this, (FBCallback) &ORToolPopup::OnBtnModalPopupTemplateCloseClicked );
mBtnModelessPopupTemplate.Caption = "Create Modeless Popup [Template]";
mBtnModelessPopupTemplate.OnClick.Add( this, (FBCallback) &ORToolPopup::OnBtnModelessPopupTemplateCloseClicked );
UIConfigurePopup();
}
/************************************************
* Configure & add callbacks to the UI Elements (for Popup).
************************************************/
void ORToolPopup::UIConfigurePopup()
{
mButtonPopupClose.Caption = "Close Popup";
mButtonPopupClose.OnClick.Add( this, (FBCallback) &ORToolPopup::EventButtonPopupCloseClick );
mPopupTemplateModal.Caption = "Modal Popup [Template]";
mPopupTemplateModeless.Caption = "Modeless Popup [Template]";
}
/************************************************
* Create popup callback.
************************************************/
void ORToolPopup::EventButtonPopupCreateClick( HISender pSender, HKEvent pEvent )
{
mPopup.Show();
}
/************************************************
* Close popup callback.
************************************************/
void ORToolPopup::EventButtonPopupCloseClick( HISender pSender, HKEvent pEvent )
{
mPopup.Close();
}
/************************************************
* Create popup template callback.
************************************************/
void ORToolPopup::OnBtnModalPopupTemplateCloseClicked( HISender pSender, HKEvent pEvent )
{
mPopupTemplateModal.Modal = true;
mPopupTemplateModal.Show( this );
}
/************************************************
* Create non-modal popup template callback.
************************************************/
void ORToolPopup::OnBtnModelessPopupTemplateCloseClicked( HISender pSender, HKEvent pEvent )
{
mPopupTemplateModeless.Close();
mPopupTemplateModeless.Modal = false;
mPopupTemplateModeless.Show();
}