本文整理汇总了C++中ContainerPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ContainerPtr类的具体用法?C++ ContainerPtr怎么用?C++ ContainerPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContainerPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TXT
void ReflectInterpreter::InterpretFilePathField( const std::vector< Reflect::Pointer >& pointers, Reflect::Translator* translator, const Reflect::Field* field, Container* parent )
{
#if INSPECT_REFACTOR
if (field->m_Flags & FieldFlags::Hide)
{
return;
}
//
// Create the ui we are generating
//
std::vector< ContainerPtr > groups;
ContainerPtr container = CreateControl<Container>();
groups.push_back( container );
bool pathField = field->m_DataClass == Reflect::GetMetaClass< PathData >();
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
DataChangingSignature::Delegate changingDelegate;
FileDialogButtonPtr fileDialogButton;
//
// Parse
//
std::string fieldUI;
field->GetProperty( TXT( "UIScript" ), fieldUI );
bool result = Script::Parse(fieldUI, this, parent->GetCanvas(), container, field->m_Flags);
if (!result)
{
if ( pathField || field->m_DataClass == Reflect::GetMetaClass<StlStringData>() )
{
ContainerPtr valueContainer = CreateControl<Container>();
ValuePtr value = CreateControl< Value >();
value->a_Justification.Set( Justifications::Right );
value->a_IsReadOnly.Set( readOnly );
value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
valueContainer->AddChild( value );
groups.push_back( valueContainer );
if ( !readOnly )
{
changingDelegate = DataChangingSignature::Delegate(this, &PathInterpreter::DataChanging);
// File dialog button
fileDialogButton = CreateControl< FileDialogButton >();
fileDialogButton->a_HelpText.Set( TXT( "Open a file dialog to choose a new file." ) );
field->GetProperty( TXT( "FileFilter" ), m_FileFilter );
if ( !m_FileFilter.empty() )
{
fileDialogButton->a_Filter.Set( m_FileFilter );
}
container->AddChild( fileDialogButton );
value->SetProperty( TXT( "FileFilter" ), m_FileFilter );
}
if ( objects.size() == 1 )
{
// File edit button
ButtonPtr editButton = CreateControl< Button >();
editButton->ButtonClickedEvent().Add( ButtonClickedSignature::Delegate ( this, &PathInterpreter::Edit ) );
editButton->a_Label.Set( TXT( "Edit" ) );
editButton->a_HelpText.Set( TXT( "Attempt to edit the file using its associated default application." ) );
container->AddChild( editButton );
}
}
}
else
{
ValuePtr value = CreateControl< Value >();
value->a_IsReadOnly.Set( readOnly );
value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( value );
}
//
// Setup label
//
LabelPtr label = NULL;
{
std::vector< ControlPtr >::const_iterator itr = container->GetChildren().begin();
std::vector< ControlPtr >::const_iterator end = container->GetChildren().end();
for( ; itr != end; ++itr )
{
Label* label = Reflect::SafeCast<Label>( *itr );
if (label)
{
break;
}
}
}
//.........这里部分代码省略.........
示例2: refreshContainer
void Game::refreshContainer(const ContainerPtr& container)
{
if(!canPerformGameAction())
return;
m_protocolGame->sendRefreshContainer(container->getId());
}
示例3: HELIUM_ASSERT
void ReflectInterpreter::InterpretBitfieldField( const std::vector< Reflect::Pointer >& pointers, Reflect::Translator* translator, const Reflect::Field* field, Container* parent )
{
bool isEnumeration = field->m_Translator->IsA( Reflect::MetaIds::EnumerationTranslator );
// If you hit this, you are misusing this interpreter
HELIUM_ASSERT( isEnumeration );
if ( !isEnumeration )
{
return;
}
if ( field->m_Flags & FieldFlags::Hide )
{
return;
}
// create the container
ContainerPtr container = CreateControl<Container>();
std::string temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
container->a_Name.Set( temp );
parent->AddChild(container);
// create the data objects
std::vector<Data*> datas;
for ( std::vector< Reflect::Pointer >::const_iterator itr = pointers.begin(), end = pointers.end(); itr != end; ++itr )
{
datas.push_back( new Data ( *itr, translator ) );
}
String defaultStr;
Pointer defaultPtr ( field, field->m_Structure->m_Default, NULL );
ScalarTranslator* scalar = Reflect::ReflectionCast< ScalarTranslator >( field->m_Translator );
if ( scalar )
{
scalar->Print( defaultPtr, defaultStr );
}
const Reflect::MetaEnum* enumeration = Reflect::ReflectionCast< MetaEnum >( field->m_ValueType );
// build the child gui elements
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
DynamicArray< Reflect::MetaEnum::Element >::ConstIterator enumItr = enumeration->m_Elements.Begin();
DynamicArray< Reflect::MetaEnum::Element >::ConstIterator enumEnd = enumeration->m_Elements.End();
for ( ; enumItr != enumEnd; ++enumItr )
{
ContainerPtr row = CreateControl< Container >();
container->AddChild( row );
LabelPtr label = CreateControl< Label >();
label->a_HelpText.Set( enumItr->m_HelpText );
label->BindText( enumItr->m_Name );
row->AddChild( label );
CheckBoxPtr checkbox = CreateControl< CheckBox >();
checkbox->a_IsReadOnly.Set( readOnly );
checkbox->a_HelpText.Set( enumItr->m_HelpText );
// TODO: Compute correct default value
checkbox->a_Default.Set( defaultStr.GetData() );
checkbox->Bind( new MultiBitfieldStringFormatter ( &*enumItr, datas ) );
row->AddChild( checkbox );
}
}
示例4: InterpretColorField
void ReflectInterpreter::InterpretColorField( const std::vector< Reflect::Pointer >& pointers, Reflect::Translator* translator, const Reflect::Field* field, Container* parent )
{
#if INSPECT_REFACTOR
ContainerPtr container = CreateControl< Container >();
parent->AddChild( container );
LabelPtr label = CreateControl< Label >();
std::string temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
label->BindText( temp );
label->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( label );
bool color3 = field->m_ValueType == Reflect::GetMetaStruct<Color3>() || field->m_ValueType == Reflect::GetMetaStruct<HDRColor3>();
bool color4 = field->m_ValueType == Reflect::GetMetaStruct<Color4>() || field->m_ValueType == Reflect::GetMetaStruct<HDRColor4>();
HELIUM_ASSERT( !(color3 && color4) ); // we shouldn't ever have both!
if ( color3 || color4 )
{
std::vector<Data*> datas;
std::vector<Reflect::Object*>::const_iterator itr = objects.begin();
std::vector<Reflect::Object*>::const_iterator end = objects.end();
for ( ; itr != end; ++itr )
{
Data s;
if ( color3 )
{
s = new Color3Data();
}
if ( color4 )
{
s = new Color4Data();
}
if (s.ReferencesObject())
{
s->ConnectField( *itr, field );
datas.push_back( s );
m_Datas.push_back( s );
}
}
if ( !m_Datas.empty() )
{
ColorPickerPtr colorPicker = CreateControl<ColorPicker>();
container->AddChild( colorPicker );
colorPicker->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
colorPicker->a_IsReadOnly.Set( readOnly );
DataBindingPtr data = new MultiStringFormatter<Data>( datas );
colorPicker->Bind( data );
if ( color3 )
{
colorPicker->a_Alpha.Set( false );
}
if ( color4 )
{
colorPicker->a_Alpha.Set( true );
SliderPtr slider = CreateControl<Slider>();
container->AddChild( slider );
slider->a_Min.Set( 0.0 );
slider->a_Max.Set( 255.0f );
slider->a_IsReadOnly.Set( readOnly );
slider->a_HelpText.Set( TXT( "Sets the alpha value for the color." ) );
ValuePtr value = CreateControl<Value>();
container->AddChild( value );
value->a_IsReadOnly.Set( readOnly );
value->a_HelpText.Set( TXT( "Sets the alpha value for the color." ) );
std::vector<Data*> alphaSer;
std::vector<Reflect::Object*>::const_iterator itr = objects.begin();
std::vector<Reflect::Object*>::const_iterator end = objects.end();
for ( ; itr != end; ++itr )
{
Data s = new UInt8Data ();
uintptr_t fieldAddress = (uintptr_t)(*itr) + field->m_Offset;
Color4* col = (Color4*)fieldAddress;
intptr_t offsetInField = (intptr_t)( &col->a ) - fieldAddress;
s->ConnectField( *itr, field, offsetInField );
alphaSer.push_back( s );
//.........这里部分代码省略.........
示例5: InterpretValueField
void ReflectInterpreter::InterpretValueField( const std::vector< Reflect::Pointer >& pointers, Reflect::Translator* translator, const Field* field, Container* parent )
{
if (field->m_Flags & FieldFlags::Hide)
{
return;
}
//
// Create the ui we are generating
//
ContainerPtr container = CreateControl<Container>();
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
if ( field->m_ValueType && field->m_ValueType->IsA( MetaIds::MetaEnum ) )
{
const Reflect::MetaEnum* enumeration = Reflect::ReflectionCast< MetaEnum >( field->m_ValueType );
ChoicePtr choice = CreateControl<Choice>();
std::vector< ChoiceItem > items;
items.resize( enumeration->m_Elements.GetSize() );
DynamicArray< MetaEnum::Element >::ConstIterator itr = enumeration->m_Elements.Begin();
DynamicArray< MetaEnum::Element >::ConstIterator end = enumeration->m_Elements.End();
for ( size_t index=0; itr != end; ++itr, ++index )
{
ChoiceItem& item = items[index];
item.m_Key = itr->m_Name;
item.m_Data = itr->m_Name;
}
choice->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
choice->a_Items.Set( items );
choice->a_IsDropDown.Set( true );
choice->a_IsReadOnly.Set( readOnly );
container->AddChild(choice);
}
else
{
ScalarTranslator* scalar = ReflectionCast< ScalarTranslator >( field->m_Translator );
if ( scalar && scalar->m_Type == ScalarTypes::Boolean )
{
CheckBoxPtr checkBox = CreateControl<CheckBox>();
checkBox->a_IsReadOnly.Set( readOnly );
checkBox->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( checkBox );
}
else
{
ValuePtr value = CreateControl<Value>();
value->a_IsReadOnly.Set( readOnly );
value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( value );
}
}
//
// Setup label
//
LabelPtr label = NULL;
{
std::vector< ControlPtr >::const_iterator itr = container->GetChildren().begin();
std::vector< ControlPtr >::const_iterator end = container->GetChildren().end();
for( ; itr != end; ++itr )
{
Label* label = Reflect::SafeCast<Label>( *itr );
if (label)
{
break;
}
}
}
if (!label.ReferencesObject())
{
label = CreateControl<Label>();
std::string temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
label->BindText( temp );
label->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->InsertChild(0, label);
}
//
// Bind data
//
//.........这里部分代码省略.........
示例6: MIN
OGRErr OGRLIBKMLLayer::ICreateFeature (
OGRFeature * poOgrFeat )
{
if ( !bUpdate )
return OGRERR_UNSUPPORTED_OPERATION;
if( m_bRegionBoundsAuto && poOgrFeat->GetGeometryRef() != NULL &&
!(poOgrFeat->GetGeometryRef()->IsEmpty()) )
{
OGREnvelope sEnvelope;
poOgrFeat->GetGeometryRef()->getEnvelope(&sEnvelope);
m_dfRegionMinX = MIN(m_dfRegionMinX, sEnvelope.MinX);
m_dfRegionMinY = MIN(m_dfRegionMinY, sEnvelope.MinY);
m_dfRegionMaxX = MAX(m_dfRegionMaxX, sEnvelope.MaxX);
m_dfRegionMaxY = MAX(m_dfRegionMaxY, sEnvelope.MaxY);
}
FeaturePtr poKmlFeature =
feat2kml ( m_poOgrDS, this, poOgrFeat, m_poOgrDS->GetKmlFactory ( ),
m_bUseSimpleField );
if( m_poKmlLayer != NULL )
m_poKmlLayer->add_feature ( poKmlFeature );
else
{
CPLAssert( m_poKmlUpdate != NULL );
KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory ( );
CreatePtr poCreate = poKmlFactory->CreateCreate();
ContainerPtr poContainer;
if( m_bUpdateIsFolder )
poContainer = poKmlFactory->CreateFolder();
else
poContainer = poKmlFactory->CreateDocument();
poContainer->set_targetid(OGRLIBKMLGetSanitizedNCName(GetName()));
poContainer->add_feature ( poKmlFeature );
poCreate->add_container(poContainer);
m_poKmlUpdate->add_updateoperation(poCreate);
}
/***** update the layer class count of features *****/
if( m_poKmlLayer != NULL )
{
nFeatures++;
const char* pszId = CPLSPrintf("%s.%d",
OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), nFeatures);
poOgrFeat->SetFID(nFeatures);
poKmlFeature->set_id(pszId);
}
else
{
if( poOgrFeat->GetFID() < 0 )
{
static int bAlreadyWarned = FALSE;
if( !bAlreadyWarned )
{
bAlreadyWarned = TRUE;
CPLError(CE_Warning, CPLE_AppDefined,
"It is recommended to define a FID when calling CreateFeature() in a update document");
}
}
else
{
const char* pszId = CPLSPrintf("%s." CPL_FRMT_GIB,
OGRLIBKMLGetSanitizedNCName(GetName()).c_str(), poOgrFeat->GetFID());
poOgrFeat->SetFID(nFeatures);
poKmlFeature->set_id(pszId);
}
}
/***** mark the layer as updated *****/
bUpdated = TRUE;
m_poOgrDS->Updated ( );
return OGRERR_NONE;
}
示例7: tr
void ReadiumJSApi::on_actionOpen_ePub3(std::string path) //QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.epub)"));
{
// CSingleLock lock(&g_cs, TRUE);
try{
////qDebug() << fileName;
DWORD beginTimeMs = GetTickCount();
ContainerPtr container = Container::OpenContainer(path);
DWORD containerOpened = GetTickCount();
if (container)
{
pkg = container->DefaultPackage();
if (pkg == 0)
{
auto pkgs = container->Packages();
if (pkgs.size() <= 0)
{
//QMessageBox messageBox;
//messageBox.critical(0, "Error", "ReadiumSDK: No packages found !");
//messageBox.setFixedSize(500, 200);
//messageBox.exec();
return;
}
pkg = pkgs[0];
}
//int contentLength = container->getArchiveInfoSize("titlepage.xhtml");
OpenPageRequest req = OpenPageRequest::fromContentUrl("", "chapter_001.xhtml");//TODO:
ViewerSettings set(true, 100, 20);
DWORD openBookStartedMs = GetTickCount();
openBook(pkg, set, req);
DWORD EndTimeTimeMs = GetTickCount();
//char buf[1024];wsprintf((LPWSTR)buf, L"TotalTime:%d ms\n Container::OpenContainer:%d ms\nopenBook:%d ms\n", (EndTimeTimeMs - beginTimeMs), (openBookStartedMs - beginTimeMs), (EndTimeTimeMs - containerOpened));
//AfxMessageBox((LPCTSTR)buf);
//BYTE* bytes = 0;
//ULONGLONG pSize = 0;
//getByteResp("/chapter_001.xhtml", &bytes, &pSize);
//delete[]bytes;
//getByteResp("/chapter_002.xhtml", &bytes, &pSize);
//delete[]bytes;
//getByteResp("/chapter_003.xhtml", &bytes, &pSize);
//openContentUrl("chapter_001.xhtml", "");
//ReadiumJsApi.openContentUrl((*list.begin())->Title().c_str(), "");
//unique_ptr<ePub3::ByteStream> byteStream = pkg->ReadStreamForItemAtPath("titlepage.xhtml");
//if (pkg)
//{
//CollectionPtr previewCollection = pkg->PreviewCollection();
//unique_ptr<ePub3::ByteStream> byteStream1 = previewCollection->ReadStreamForItemAtPath("titlepage.xhtml");
//}
}
}
//catch (ePub3::epub_spec_error err)
//{
//}
catch (...)
{
//qDebug() << "Exception!!!";
throw;
}
//openContentUrl("chapter_001.xhtml", "");
}
示例8: HELIUM_ASSERT
void ReflectBitfieldInterpreter::InterpretField(const Field* field, const std::vector<Reflect::Element*>& instances, Container* parent)
{
// If you hit this, you are misusing this interpreter
HELIUM_ASSERT( field->m_SerializerID == Reflect::GetType<Reflect::BitfieldSerializer>() );
if ( field->m_SerializerID != Reflect::GetType<Reflect::BitfieldSerializer>() )
{
return;
}
if ( field->m_Flags & FieldFlags::Hide )
{
return;
}
const EnumerationField* enumField = static_cast< const EnumerationField* >( field );
// create the panel
PanelPtr panel = m_Container->GetCanvas()->Create<Panel>(this);
tstring temp;
bool converted = Helium::ConvertString( field->m_UIName, temp );
panel->SetText( temp );
panel->SetExpanded( true );
parent->AddControl(panel);
// build the child gui elements
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
M_StrEnumerationElement::const_iterator enumItr = enumField->m_Enumeration->m_ElementsByLabel.begin();
M_StrEnumerationElement::const_iterator enumEnd = enumField->m_Enumeration->m_ElementsByLabel.end();
for ( ; enumItr != enumEnd; ++enumItr )
{
ContainerPtr row = m_Container->GetCanvas()->Create<Container>( this );
panel->AddControl( row );
LabelPtr label = m_Container->GetCanvas()->Create<Label>( this );
row->AddControl( label );
tstring temp;
bool converted = Helium::ConvertString( enumItr->first, temp );
HELIUM_ASSERT( converted );
label->SetText( temp );
BitfieldCheckBoxPtr checkbox = m_Container->GetCanvas()->Create<ReflectBitfieldCheckBox>( this );
row->AddControl( checkbox );
converted = Helium::ConvertString( enumItr->first, temp );
HELIUM_ASSERT( converted );
checkbox->SetBitfieldString( temp );
checkbox->SetReadOnly( readOnly );
}
// create the serializers
std::vector<Reflect::Element*>::const_iterator itr = instances.begin();
std::vector<Reflect::Element*>::const_iterator end = instances.end();
for ( ; itr != end; ++itr )
{
SerializerPtr s = field->CreateSerializer();
s->ConnectField(*itr, field);
m_Serializers.push_back(s);
}
// bind the ui to the serializers
panel->Bind( new MultiStringFormatter<Serializer>( (std::vector<Reflect::Serializer*>&)m_Serializers ) );
// setup the default value
if (field->m_Default != NULL)
{
tstringstream outStream;
*field->m_Default >> outStream;
panel->SetDefault( outStream.str() );
}
示例9: TXT
void ReflectInterpreter::InterpretType(const std::vector<Reflect::Object*>& instances, Container* parent, int32_t includeFlags, int32_t excludeFlags, bool expandPanel)
{
const Composite* composite = instances[0]->GetClass();
// create a container
ContainerPtr container = CreateControl<Container>();
// parse
ContainerPtr scriptOutput = CreateControl<Container>();
tstring typeInfoUI;
composite->GetProperty( TXT( "UIScript" ), typeInfoUI );
bool result = Script::Parse(typeInfoUI, this, parent->GetCanvas(), scriptOutput);
// compute container label
tstring labelText;
if (result)
{
V_Control::const_iterator itr = scriptOutput->GetChildren().begin();
V_Control::const_iterator end = scriptOutput->GetChildren().end();
for( ; itr != end; ++itr )
{
Label* label = Reflect::SafeCast<Label>( *itr );
if (label)
{
label->ReadStringData( labelText );
if ( !labelText.empty() )
{
break;
}
}
}
}
if (labelText.empty())
{
composite->GetProperty( TXT( "UIName" ), labelText );
}
if ( labelText.empty() )
{
labelText = *composite->m_Name;
}
container->a_Name.Set( labelText );
std::map< tstring, ContainerPtr > containersMap;
containersMap.insert( std::make_pair( TXT( "" ), container) );
std::stack< const Composite* > bases;
for ( const Composite* current = composite; current != NULL; current = current->m_Base )
{
bases.push( current );
}
while ( !bases.empty() )
{
const Composite* current = bases.top();
bases.pop();
// for each field in the type
DynArray< Field >::ConstIterator itr = current->m_Fields.Begin();
DynArray< Field >::ConstIterator end = current->m_Fields.End();
for ( ; itr != end; ++itr )
{
const Field* field = &*itr;
bool noFlags = ( field->m_Flags == 0 && includeFlags == 0xFFFFFFFF );
bool doInclude = ( field->m_Flags & includeFlags ) != 0;
bool dontExclude = ( excludeFlags == 0 ) || !(field->m_Flags & excludeFlags );
bool hidden = (field->m_Flags & Reflect::FieldFlags::Hide) != 0;
// if we don't have flags (or we are included, and we aren't excluded) then make UI
if ( ( noFlags || doInclude ) && ( dontExclude ) )
{
tstring fieldUIGroup;
field->GetProperty( TXT( "UIGroup" ), fieldUIGroup );
if ( !fieldUIGroup.empty() )
{
std::map< tstring, ContainerPtr >::iterator itr = containersMap.find( fieldUIGroup );
if ( itr == containersMap.end() )
{
// This container isn't in our list so make a new one
ContainerPtr newContainer = CreateControl<Container>();
containersMap.insert( std::make_pair(fieldUIGroup, newContainer) );
ContainerPtr parent;
tstring groupName;
size_t idx = fieldUIGroup.find_last_of( TXT( "/" ) );
if ( idx != tstring::npos )
{
tstring parentName = fieldUIGroup.substr( 0, idx );
groupName = fieldUIGroup.substr( idx+1 );
if ( containersMap.find( parentName ) == containersMap.end() )
{
parent = CreateControl<Container>();
// create the parent hierarchy since it hasn't already been made
tstring currentParent = parentName;
//.........这里部分代码省略.........
示例10: TXT
///////////////////////////////////////////////////////////////////////////////
// Creates UI for the field variable specified.
//
void ReflectStlSetInterpreter::InterpretField( const Reflect::Field* field, const std::vector<Reflect::Object*>& instances, Container* parent )
{
if ( field->m_Flags & Reflect::FieldFlags::Hide )
{
return;
}
// create the container
ContainerPtr container = CreateControl< Container >();
parent->AddChild( container );
tstring temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
container->a_Name.Set( temp );
// create the data objects
std::vector< Reflect::Object* >::const_iterator itr = instances.begin();
std::vector< Reflect::Object* >::const_iterator end = instances.end();
for ( ; itr != end; ++itr )
{
Reflect::DataPtr ser = Reflect::AssertCast< Reflect::Data >( Reflect::Registry::GetInstance()->CreateInstance( field->m_DataClass ) );
uintptr_t fieldAddress = ( uintptr_t )( *itr ) + field->m_Offset;
ser->ConnectData( ( void* )fieldAddress );
m_Datas.push_back( ser );
}
// create the list
ListPtr list = CreateControl< List >();
list->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( list );
// bind the ui to the serialiers
list->Bind( new MultiStringFormatter< Reflect::Data >( (std::vector<Reflect::Data*>&)m_Datas ) );
// create the buttons if we are not read only
if ( !( field->m_Flags & Reflect::FieldFlags::ReadOnly ) )
{
ContainerPtr buttonContainer = CreateControl< Container >();
container->AddChild( buttonContainer );
ButtonPtr buttonAdd = CreateControl< Button >();
buttonContainer->AddChild( buttonAdd );
buttonAdd->a_Label.Set( TXT( "Add" ) );
buttonAdd->a_HelpText.Set( TXT( "Add an item to the list." ) );
buttonAdd->ButtonClickedEvent().Add( ButtonClickedSignature::Delegate ( this, &ReflectStlSetInterpreter::OnAdd ) );
buttonAdd->SetClientData( new ClientData( list ) );
ButtonPtr buttonRemove = CreateControl< Button >();
buttonContainer->AddChild( buttonRemove );
buttonRemove->a_Label.Set( TXT( "Remove" ) );
buttonRemove->a_HelpText.Set( TXT( "Remove the selected item(s) from the list." ) );
buttonRemove->ButtonClickedEvent().Add( ButtonClickedSignature::Delegate ( this, &ReflectStlSetInterpreter::OnRemove ) );
buttonRemove->SetClientData( new ClientData( list ) );
}
// for now let's just disable this container if there is more than one item selected. I'm not sure if it will behave properly in this case.
if ( instances.size() > 1 )
{
container->a_IsEnabled.Set( false );
}
}
示例11: InterpretField
void ReflectValueInterpreter::InterpretField(const Field* field, const std::vector<Reflect::Object*>& instances, Container* parent)
{
if (field->m_Flags & FieldFlags::Hide)
{
return;
}
//
// Create the ui we are generating
//
ContainerPtr container = CreateControl<Container>();
bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;
//
// Parse
//
tstring fieldUI;
field->GetProperty( TXT( "UIScript" ), fieldUI );
bool result = Script::Parse(fieldUI, this, parent->GetCanvas(), container, field->m_Flags);
if (!result)
{
if ( field->m_DataClass == Reflect::GetClass<EnumerationData>() )
{
ChoicePtr choice = CreateControl<Choice>();
const Reflect::Enumeration* enumeration = Reflect::ReflectionCast< Enumeration >( field->m_Type );
std::vector< ChoiceItem > items;
items.resize( enumeration->m_Elements.GetSize() );
DynamicArray< EnumerationElement >::ConstIterator itr = enumeration->m_Elements.Begin();
DynamicArray< EnumerationElement >::ConstIterator end = enumeration->m_Elements.End();
for ( size_t index=0; itr != end; ++itr, ++index )
{
ChoiceItem& item = items[index];
item.m_Key = itr->m_Name;
item.m_Data = itr->m_Name;
}
choice->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
choice->a_Items.Set( items );
choice->a_IsDropDown.Set( true );
choice->a_IsReadOnly.Set( readOnly );
container->AddChild(choice);
}
else
{
if ( field->m_DataClass == Reflect::GetClass<BoolData>() )
{
CheckBoxPtr checkBox = CreateControl<CheckBox>();
checkBox->a_IsReadOnly.Set( readOnly );
checkBox->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( checkBox );
}
else
{
ValuePtr value = CreateControl<Value>();
value->a_IsReadOnly.Set( readOnly );
value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
container->AddChild( value );
}
}
}
//
// Setup label
//
LabelPtr label = NULL;
{
V_Control::const_iterator itr = container->GetChildren().begin();
V_Control::const_iterator end = container->GetChildren().end();
for( ; itr != end; ++itr )
{
Label* label = Reflect::SafeCast<Label>( *itr );
if (label)
{
break;
}
}
}
if (!label.ReferencesObject())
{
label = CreateControl<Label>();
tstring temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
//.........这里部分代码省略.........
示例12: TEST_CASE
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <ePub3/container.h>
#include <ePub3/package.h>
#include <ePub3/spine.h>
#include "catch.hpp"
#define LR_SPREAD_EPUB_PATH "TestData/page-blanche.epub"
#define NO_SPREAD_EPUB_PATH "TestData/cole-voyage-of-life-20120320.epub"
using namespace ePub3;
TEST_CASE("Page spread comes back correctly", "")
{
ContainerPtr c = Container::OpenContainer(LR_SPREAD_EPUB_PATH);
PackagePtr pkg = c->DefaultPackage();
SpineItemPtr item = pkg->FirstSpineItem();
REQUIRE(item->Spread() == PageSpread::Right);
item = item->Next();
REQUIRE(item->Spread() == PageSpread::Left);
}
TEST_CASE("Multiple spine item properties should work", "")
{
ContainerPtr c = Container::OpenContainer(NO_SPREAD_EPUB_PATH);
PackagePtr pkg = c->DefaultPackage();
SpineItemPtr item = pkg->SpineItemWithIDRef("s1b");
示例13: TXT
void ReflectStlVectorInterpreter::InterpretField(const Field* field, const std::vector<Reflect::Object*>& instances, Container* parent)
{
if (field->m_Flags & FieldFlags::Hide)
{
return;
}
// create the label
ContainerPtr labelContainer = CreateControl<Container>();
parent->AddChild( labelContainer );
LabelPtr label = CreateControl< Label >();
label->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
labelContainer->AddChild( label );
tstring temp;
field->GetProperty( TXT( "UIName" ), temp );
if ( temp.empty() )
{
bool converted = Helium::ConvertString( field->m_Name, temp );
HELIUM_ASSERT( converted );
}
label->BindText( temp );
// create the list view
ContainerPtr listContainer = CreateControl<Container>();
parent->AddChild( listContainer );
ListPtr list = CreateControl<List>();
list->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
listContainer->AddChild( list );
// create the buttons
ButtonPtr addButton;
ButtonPtr removeButton;
ButtonPtr upButton;
ButtonPtr downButton;
if ( !(field->m_Flags & FieldFlags::ReadOnly) )
{
addButton = AddAddButton( list );
removeButton = AddRemoveButton( list );
upButton = AddMoveUpButton( list );
downButton = AddMoveDownButton( list );
}
// add the buttons to the container
ContainerPtr buttonContainer = CreateControl<Container>();
parent->AddChild( buttonContainer );
if ( addButton )
{
buttonContainer->AddChild( addButton );
}
if ( removeButton )
{
buttonContainer->AddChild( removeButton );
}
if ( upButton )
{
buttonContainer->AddChild( upButton );
}
if ( downButton )
{
buttonContainer->AddChild( downButton );
}
// create the data objects
std::vector<Reflect::Object*>::const_iterator itr = instances.begin();
std::vector<Reflect::Object*>::const_iterator end = instances.end();
for ( ; itr != end; ++itr )
{
DataPtr s = field->CreateData();
OnCreateFieldData( s );
s->ConnectField(*itr, field);
m_Datas.push_back(s);
}
// bind the ui to the data objects
Helium::SmartPtr< MultiStringFormatter<Data> > data = new MultiStringFormatter<Reflect::Data>( (std::vector<Reflect::Data*>&)m_Datas );
list->Bind( data );
// setup the default value
DataPtr defaultData = field->CreateDefaultData();
if (defaultData)
{
tstringstream defaultStream;
*defaultData >> defaultStream;
list->a_Default.Set( defaultStream.str() );
}
}
示例14: SetErrorHandler
static std::once_flag __once;
std::call_once(__once, [&]() {
SetErrorHandler([](const error_details& err) {
if (err.epub_error_code() == EPUBError::OPFMissingModificationDateMetadata)
return true;
return DefaultErrorHandler(err);
});
__c = Container::OpenContainer(EPUB_PATH);
SetErrorHandler(DefaultErrorHandler);
});
return __c;
}
TEST_CASE("SpineItems should have titles when they match a TOC item", "[toc]")
{
ContainerPtr container = GetContainer();
auto pkg = container->DefaultPackage();
auto spine = pkg->FirstSpineItem();
// in alice3.epub, the first item isn't in the TOC, and has an empty title
// the full list should be:
/*
- ""
- "I. Down the Rabbit-Hole"
- "II. The Pool of Tears"
- "III. A Caucus-Race and a Long Tale"
- "IV. The Rabbit Sends in a Little Bill"
- "V. Advice from a Caterpillar"
- "VI. Pig and Pepper"
- "VII. A Mad Tea-Party"
- "VIII. The Queen's Croquet-Ground"
示例15: InterpretType
void ReflectInterpreter::InterpretType(const std::vector<Reflect::Element*>& instances, Container* parent, i32 includeFlags, i32 excludeFlags, bool expandPanel)
{
const Class* typeInfo = instances[0]->GetClass();
// create a panel
PanelPtr panel = m_Container->GetCanvas()->Create<Panel>(this);
// parse
ContainerPtr scriptOutput = m_Container->GetCanvas()->Create<Container>(this);
tstring typeInfoUI;
typeInfo->GetProperty( TXT( "UIScript" ), typeInfoUI );
bool result = Script::Parse(typeInfoUI, this, parent->GetCanvas(), scriptOutput);
// compute panel label
tstring labelText;
if (result)
{
V_Control::const_iterator itr = scriptOutput->GetControls().begin();
V_Control::const_iterator end = scriptOutput->GetControls().end();
for( ; itr != end; ++itr )
{
Label* label = Reflect::ObjectCast<Label>( *itr );
if (label)
{
bool converted = Helium::ConvertString( label->GetText(), labelText );
HELIUM_ASSERT( converted );
if ( !labelText.empty() )
{
break;
}
}
}
}
if (labelText.empty())
{
std::vector<Reflect::Element*>::const_iterator itr = instances.begin();
std::vector<Reflect::Element*>::const_iterator end = instances.end();
for ( ; itr != end; ++itr )
{
Reflect::Element* instance = *itr;
if ( labelText.empty() )
{
labelText = instance->GetTitle();
}
else
{
if ( labelText != instance->GetTitle() )
{
labelText.clear();
break;
}
}
}
if ( labelText.empty() )
{
labelText = typeInfo->m_UIName;
}
}
tstring temp;
bool converted = Helium::ConvertString( labelText, temp );
HELIUM_ASSERT( converted );
panel->SetText( temp );
M_Panel panelsMap;
panelsMap.insert( std::make_pair( TXT( "" ), panel) );
// don't bother including Element's fields
int offset = Reflect::GetClass<Element>()->m_LastFieldID;
// for each field in the type
M_FieldIDToInfo::const_iterator itr = typeInfo->m_FieldIDToInfo.find(offset + 1);
M_FieldIDToInfo::const_iterator end = typeInfo->m_FieldIDToInfo.end();
for ( ; itr != end; ++itr )
{
const Field* field = itr->second;
bool noFlags = ( field->m_Flags == 0 && includeFlags == 0xFFFFFFFF );
bool doInclude = ( field->m_Flags & includeFlags ) != 0;
bool dontExclude = ( excludeFlags == 0 ) || !(field->m_Flags & excludeFlags );
bool hidden = (field->m_Flags & Reflect::FieldFlags::Hide) != 0;
// if we don't have flags (or we are included, and we aren't excluded) then make UI
if ( ( noFlags || doInclude ) && ( dontExclude ) )
{
//
// Handle sub panels for grouping content
//
bool groupExpanded = false;
field->GetProperty( TXT( "UIGroupExpanded" ), groupExpanded );
tstring fieldUIGroup;
field->GetProperty( TXT( "UIGroup" ), fieldUIGroup );
//.........这里部分代码省略.........