status_t PListView::SetProperty(const char *name, PValue *value, const int32 &index) { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; if (FlagsForProperty(prop) & PROPERTY_READ_ONLY) return B_READ_ONLY; BListView *backend = (BListView*)fView; BoolValue boolval; CharValue charval; ColorValue colorval; FloatValue floatval; IntValue intval; PointValue pointval; RectValue rectval; StringValue stringval; status_t status = prop->SetValue(value); if (status != B_OK) return status; if (backend->Window()) backend->Window()->Lock(); else if (str.ICompare("SelectionMessage") == 0) { BMessage selMsg(*intval.value); backend->SetSelectionMessage(&selMsg); } else if (str.ICompare("InvocationMessage") == 0) { BMessage invMsg(*intval.value); backend->SetInvocationMessage(&invMsg); } else if (str.ICompare("SelectionType") == 0) { prop->GetValue(&intval); backend->SetListType((list_view_type)*intval.value); } else { if (backend->Window()) backend->Window()->Unlock(); return PView::SetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }
status_t PLabel::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; BStringView *backend = (BStringView*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("Alignment") == 0) ((EnumProperty*)prop)->SetValue(backend->Alignment()); else if (str.ICompare("Text") == 0) ((StringProperty*)prop)->SetValue(backend->Text()); else { if (backend->Window()) backend->Window()->Unlock(); return PView::GetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }
status_t PControl::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; if (!fView) return B_NO_INIT; BControl *viewAsControl = (BControl*)fView; if (str.ICompare("Enabled") == 0) ((BoolProperty*)prop)->SetValue(viewAsControl->IsEnabled()); else if (str.ICompare("Label") == 0) ((StringProperty*)prop)->SetValue(viewAsControl->Label()); else if (str.ICompare("Value") == 0) ((IntProperty*)prop)->SetValue(viewAsControl->Value()); else return PView::GetProperty(name,value,index); return prop->GetValue(value); }
bool TemplateParser::ParseProperty() { wxString childName; wxString propname = ParsePropertyName( &childName ); PProperty property = m_obj->GetProperty(propname); if ( NULL == property.get() ) { wxLogError( wxT("The property '%s' does not exist for objects of class '%s'"), propname.c_str(), m_obj->GetClassName().c_str() ); return true; } if ( childName.empty() ) { wxString code = PropertyToCode(property); m_out << code; } else { m_out << property->GetChildFromParent( childName ); } // LogDebug("parsing property %s",propname.c_str()); return true; }
void PHPCodeGenerator::FindMacros( PObjectBase obj, std::vector<wxString>* macros ) { // iterate through all of the properties of all objects, add the macros // to the vector unsigned int i; for ( i = 0; i < obj->GetPropertyCount(); i++ ) { PProperty prop = obj->GetProperty( i ); if ( prop->GetType() == PT_MACRO ) { wxString value = prop->GetValue(); if( value.IsEmpty() ) continue; // Skip wx IDs if ( ( ! value.Contains( wxT("XRCID" ) ) ) && ( m_predMacros.end() == m_predMacros.find( value ) ) ) { if ( macros->end() == std::find( macros->begin(), macros->end(), value ) ) { macros->push_back( value ); } } } } for ( i = 0; i < obj->GetChildCount(); i++ ) { FindMacros( obj->GetChild( i ), macros ); } }
CProperty* CEntityFactory::AttachProperty(CEntity& Entity, const nString& TypeName) const { CPropertyInfo PropInfo; nString Type = TypeName; if (!PropertyMeta.Get(Type.Get(), PropInfo)) { Type = StrPropPrefix + TypeName; if (!PropertyMeta.Get(Type.Get(), PropInfo)) n_error("No such property \"%s\"", TypeName.Get()); } n_assert(PropInfo.pStorage); if (PropInfo.ActivePools & Entity.GetEntityPool()) { PProperty Prop; if (!PropInfo.pStorage->Get(Entity.GetUniqueID(), Prop)) { Prop = (CProperty*)CoreFct->Create(Type); PropInfo.pStorage->Add(Entity.GetUniqueID(), Prop); Prop->SetEntity(&Entity); } return Prop.get_unsafe(); } return NULL; }
void ObjectBase::SerializeObject( ticpp::Element* serializedElement ) { ticpp::Element element( "object" ); element.SetAttribute( "class", _STDSTR( GetClassName() ) ); element.SetAttribute( "expanded", GetExpanded() ); for ( unsigned int i = 0; i < GetPropertyCount(); i++ ) { PProperty prop = GetProperty( i ); ticpp::Element prop_element( "property" ); prop_element.SetAttribute( "name", _STDSTR( prop->GetName() ) ); prop_element.SetText( _STDSTR( prop->GetValue() ) ); element.LinkEndChild( &prop_element ); } for ( unsigned int i = 0; i < GetEventCount(); i++ ) { PEvent event = GetEvent( i ); ticpp::Element event_element( "event" ); event_element.SetAttribute( "name", _STDSTR( event->GetName() ) ); event_element.SetText( _STDSTR( event->GetValue() ) ); element.LinkEndChild( &event_element ); } for ( unsigned int i = 0 ; i < GetChildCount(); i++ ) { PObjectBase child = GetChild( i ); ticpp::Element child_element; child->SerializeObject( &child_element ); element.LinkEndChild( &child_element ); } *serializedElement = element; }
bool TemplateParser::ParseWxParent() { PObjectBase wxparent( GetWxParent() ); if ( wxparent ) { PProperty property = GetRelatedProperty( wxparent ); //m_out << PropertyToCode(property); if (wxparent->GetClassName() == wxT("wxStaticBoxSizer")) { // We got a wxStaticBoxSizer as parent, use the special PT_WXPARENT_SB type to // generate code to get its static box m_out << ValueToCode(PT_WXPARENT_SB, property->GetValue()); } else { m_out << ValueToCode(PT_WXPARENT, property->GetValue()); } } else { ignore_whitespaces(); ParsePropertyName(); m_out << RootWxParentToCode(); } return true; }
status_t PMenuItem::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; BMenuItem *backend = (BMenuItem*)fBackend; if (str.ICompare("Message") == 0) ((IntProperty*)prop)->SetValue(backend->Command()); else if (str.ICompare("Trigger") == 0) ((CharProperty*)prop)->SetValue(backend->Trigger()); else if (str.ICompare("Label") == 0) ((StringProperty*)prop)->SetValue(backend->Label()); else if (str.ICompare("Frame") == 0) ((RectProperty*)prop)->SetValue(backend->Frame()); else if (str.ICompare("Marked") == 0) ((BoolProperty*)prop)->SetValue(backend->IsMarked()); else if (str.ICompare("Enabled") == 0) ((BoolProperty*)prop)->SetValue(backend->IsEnabled()); else { return PObject::GetProperty(name, value, index); } return prop->GetValue(value); }
//ru Возвращает значение свойства в виде C строки. EXPORT const char *propToString(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return 0; return fcgt::strToCString(p->toString()); }
//ru Возвращает значение свойства в формате float. EXPORT qreal propToReal(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return 0; return p->toReal(); }
//ru Возвращает значение свойства в формате int. EXPORT int propToInteger(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return 0; return p->toInt(); }
//ru Возвращает значение свойства в формате uchar. EXPORT uchar propToByte(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return 0; return p->toByte(); }
wxString ObjectBase::GetChildFromParentProperty( const wxString& parentName, const wxString& childName ) { PProperty property = GetProperty( parentName ); if (property) return property->GetChildFromParent( childName ); else return wxEmptyString; }
//!~~~~~~~~~~~~~~~~~~~~~~~~ свойства элемента ~~~~~~~~~~~~~~~~~~~~~~~~~~ //ru Возвращает тип свойства. EXPORT DataType propGetType(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return data_null; return p->getType(); }
wxBitmap ObjectBase::GetPropertyAsBitmap (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsBitmap(); else return wxBitmap(); }
wxArrayString ObjectBase::GetPropertyAsArrayString(const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsArrayString(); else return wxArrayString(); }
double ObjectBase::GetPropertyAsFloat( const wxString& pname ) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsFloat(); else return 0; }
wxPoint ObjectBase::GetPropertyAsPoint (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsPoint(); else return wxPoint(); }
wxSize ObjectBase::GetPropertyAsSize (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsSize(); else return wxDefaultSize; }
wxFontContainer ObjectBase::GetPropertyAsFont(const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsFont(); else return wxFontContainer(); }
wxColour ObjectBase::GetPropertyAsColour (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsColour(); else return wxColour(); }
bool ObjectBase::IsNull (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->IsNull(); else return true; }
int ObjectBase::GetPropertyAsInteger (const wxString& pname) { PProperty property = GetProperty( pname ); if (property) return property->GetValueAsInteger(); else return 0; }
//ru Возвращает имя свойства. EXPORT const char *propGetName(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return nullptr; return fcgt::strToCString(p->getName()); }
status_t PLabel::SetProperty(const char *name, PValue *value, const int32 &index) { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; if (FlagsForProperty(prop) & PROPERTY_READ_ONLY) return B_READ_ONLY; BStringView *backend = (BStringView*)fView; BoolValue boolval; CharValue charval; ColorValue colorval; FloatValue floatval; IntValue intval; PointValue pointval; RectValue rectval; StringValue stringval; status_t status = prop->SetValue(value); if (status != B_OK) return status; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("Alignment") == 0) { prop->GetValue(&intval); backend->SetAlignment((alignment)*intval.value); } else if (str.ICompare("Text") == 0) { prop->GetValue(&stringval); backend->SetText(*stringval.value); } else { if (backend->Window()) backend->Window()->Unlock(); return PView::SetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }
wxString TemplateParser::PropertyToCode(PProperty property) { if ( property ) { return ValueToCode(property->GetType(), property->GetValue()); } else { return wxEmptyString; } }
//ru Возвращает значение свойства в виде указателя на данные. EXPORT quintptr propGetValue(quintptr id_prop) { PProperty p = m_model->getPropertyById(id_prop); if (!p) return 0; const PValue v = p->getValue(); if (!v) return 0; return v->getId(); }
wxArrayInt ObjectBase::GetPropertyAsArrayInt(const wxString& pname) { wxArrayInt array; PProperty property = GetProperty( pname ); if (property) { IntList il( property->GetValue(), property->GetType() == PT_UINTLIST ); for (unsigned int i=0; i < il.GetSize() ; i++) array.Add(il.GetValue(i)); } return array; }
status_t PProgressBar::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; BStatusBar *backend = (BStatusBar*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("BarColor") == 0) ((ColorProperty*)prop)->SetValue(backend->BarColor()); else if (str.ICompare("BarHeight") == 0) ((FloatProperty*)prop)->SetValue(backend->BarHeight()); else if (str.ICompare("Label") == 0) ((StringProperty*)prop)->SetValue(backend->Label()); else if (str.ICompare("CurrentValue") == 0) { ((FloatProperty*)prop)->SetValue(backend->CurrentValue()); } else if (str.ICompare("MaxValue") == 0) ((FloatProperty*)prop)->SetValue(backend->MaxValue()); else if (str.ICompare("Text") == 0) ((StringProperty*)prop)->SetValue(backend->Text()); else if (str.ICompare("TrailingLabel") == 0) ((StringProperty*)prop)->SetValue(backend->TrailingLabel()); else if (str.ICompare("TrailingText") == 0) ((StringProperty*)prop)->SetValue(backend->TrailingText()); else { if (backend->Window()) backend->Window()->Unlock(); return PView::GetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }