#include "orimpexpdevice_layout.h"
#define ORDEVICEEXPORT__LAYOUT ORDeviceExportLayout
ORDEVICEEXPORT__CLASSSTR,
bool ORDeviceExportLayout::FBCreate()
{
mDevice = ((ORDeviceExport *)(FBDevice *)Device);
UICreate ();
UIConfigure ();
UIReset ();
return true;
}
void ORDeviceExportLayout::FBDestroy()
{
}
void ORDeviceExportLayout::UICreate()
{
int lS = 5;
int lW = 100;
int lW2 = 150;
int lH = 18;
int lH2= 200;
AddRegion("LabelExportFilename", "LabelExportFilename",
AddRegion("EditExportFilename", "EditExportFilename",
AddRegion("LabelExportRate", "LabelExportRate",
AddRegion("EditNumberExportRate", "EditNumberExportRate",
AddRegion("ButtonClearList", "ButtonClearList",
AddRegion("ListExportModels", "ListExportModels",
SetControl("LabelExportFilename", mLabelExportFilename );
SetControl("EditExportFilename", mEditExportFilename );
SetControl("LabelExportRate", mLabelExportRate );
SetControl("EditNumberExportRate", mEditNumberExportRate );
SetControl("ButtonClearList", mButtonClearList );
SetControl("ListExportModels", mListExportModels );
}
void ORDeviceExportLayout::UIConfigure()
{
mLabelExportFilename.Caption = "Export File :";
mLabelExportRate.Caption = "Export Rate :";
mEditNumberExportRate.Min = 1.0;
mEditNumberExportRate.Max = 100.0;
mButtonClearList.Caption = "Clear List";
mEditExportFilename.OnChange.Add (
this, (
FBCallback)&ORDeviceExportLayout::EventEditExportFilenameChange );
mEditNumberExportRate.OnChange.Add (
this, (
FBCallback)&ORDeviceExportLayout::EventEditNumberExportRateChange );
mButtonClearList.OnClick.Add (
this, (
FBCallback)&ORDeviceExportLayout::EventButtonClearListClick );
mListExportModels.OnDragAndDrop.Add (
this, (
FBCallback)&ORDeviceExportLayout::EventListExportModelsDragAndDrop );
}
void ORDeviceExportLayout::UIReset()
{
mEditNumberExportRate.Value = mDevice->GetExportRate();
mEditExportFilename.Text = mDevice->GetExportFilename();
mListExportModels.Items.Clear();
if( mDevice->mModels.GetCount() == 0 )
{
mListExportModels.Items.Add( "--- No Models ---" );
}
for(i=0;i<mDevice->mModels.GetCount();i++)
{
mListExportModels.Items.Add( mDevice->mModels[i]->Name, (unsigned long) mDevice->mModels[i] );
}
}
void ORDeviceExportLayout::EventEditExportFilenameChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetExportFilename( mEditExportFilename.Text );
mEditExportFilename.Text = mDevice->GetExportFilename();
}
void ORDeviceExportLayout::EventEditNumberExportRateChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetExportRate( mEditNumberExportRate.Value );
mEditNumberExportRate.Value = mDevice->GetExportRate();
}
void ORDeviceExportLayout::EventButtonClearListClick(
HISender pSender,
HKEvent pEvent )
{
mDevice->mModels.Clear();
UIReset();
}
void ORDeviceExportLayout::EventListExportModelsDragAndDrop(
HISender pSender,
HKEvent pEvent )
{
FBEventDragAndDrop lDragAndDrop( pEvent );
switch( lDragAndDrop.State )
{
{
lDragAndDrop.Accept();
}
break;
{
for(i=0;i<lDragAndDrop.GetCount();i++)
{
lModel = (FBModel*)(FBComponent*) lDragAndDrop.Get(i);
if( mDevice->mModels.Find( lModel ) == -1 )
{
mDevice->mModels.Add( lModel );
}
}
UIReset();
}
break;
}
}