status_t PControl::SetProperty(const char *name, PValue *value, const int32 &index) { // Modal, Front, and Floating properties are missing because they are read-only if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; status_t status = prop->SetValue(value); if (status != B_OK) return status; if (!fView) return B_NO_INIT; BControl *viewAsControl = (BControl*)fView; BoolValue bv; IntValue iv; StringValue sv; if (viewAsControl->Window()) viewAsControl->Window()->Lock(); if (str.ICompare("Enabled") == 0) { prop->GetValue(&bv); viewAsControl->SetEnabled(bv.value); } else if (str.ICompare("Label") == 0) { prop->GetValue(&sv); viewAsControl->SetLabel(sv.value->String()); viewAsControl->Invalidate(); } else if (str.ICompare("Value") == 0) { prop->GetValue(&iv); viewAsControl->SetValue(*iv.value); } else { if (viewAsControl->Window()) viewAsControl->Window()->Unlock(); return PView::SetProperty(name,value,index); } if (viewAsControl->Window()) viewAsControl->Window()->Unlock(); return prop->GetValue(value); }
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); }
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 ); } }
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); }
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); }
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; }
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); }
bool TemplateParser::ParseForEach() { // Whitespaces at the very start are ignored ignore_whitespaces(); // parsing the property if (GetNextToken() == TOK_PROPERTY) { wxString propname = ParsePropertyName(); wxString inner_template = ExtractInnerTemplate(); PProperty property = m_obj->GetProperty(propname); wxString propvalue = property->GetValue(); // Property value must be an string using ',' as separator. // The template will be generated nesting as many times as // tokens were found in the property value. if (property->GetType() == PT_INTLIST || property->GetType() == PT_UINTLIST) { // For doing that we will use wxStringTokenizer class from wxWidgets wxStringTokenizer tkz( propvalue, wxT(",")); int i = 0; while (tkz.HasMoreTokens()) { wxString token; token = tkz.GetNextToken(); token.Trim(true); token.Trim(false); // Parsing the internal template { wxString code; PTemplateParser parser = CreateParser( this, inner_template ); parser->SetPredefined( token, wxString::Format( wxT("%i"), i++ ) ); code = parser->ParseTemplate(); m_out << wxT("\n") << code; } } } else if (property->GetType() == PT_STRINGLIST) { wxArrayString array = property->GetValueAsArrayString(); for ( unsigned int i = 0 ; i < array.Count(); i++ ) { wxString code; PTemplateParser parser = CreateParser(this,inner_template); parser->SetPredefined( ValueToCode( PT_WXSTRING_I18N, array[i] ), wxString::Format( wxT("%i"), i ) ); code = parser->ParseTemplate(); m_out << wxT("\n") << code; } } else wxLogError(wxT("Property type not compatible with \"foreach\" macro")); } return true; }
wxString TemplateParser::PropertyToCode(PProperty property) { if ( property ) { return ValueToCode(property->GetType(), property->GetValue()); } else { return wxEmptyString; } }
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); }
void CppCodeGenerator::FindMacros(PObjectBase obj, set<string> ¯o_set) { // recorre cada propiedad de cada objeto identificando aquellas // que sean macros, en cuyo caso la añade al conjunto. unsigned int i; for (i=0; i<obj->GetPropertyCount(); i++) { PProperty prop = obj->GetProperty(i); if (prop->GetType() == PT_MACRO) macro_set.insert(prop->GetValue()); } for (i=0; i<obj->GetChildCount(); i++) { FindMacros(obj->GetChild(i),macro_set); } }
void PHPCodeGenerator::GenClassDeclaration(PObjectBase class_obj, bool use_enum, const wxString& classDecoration, const EventVector &events, const wxString& eventHandlerPostfix) { PProperty propName = class_obj->GetProperty( wxT("name") ); if ( !propName ) { wxLogError(wxT("Missing \"name\" property on \"%s\" class. Review your XML object description"), class_obj->GetClassName().c_str()); return; } wxString class_name = propName->GetValue(); if ( class_name.empty() ) { wxLogError( wxT("Object name can not be null") ); return; } m_source->WriteLn( wxT("/*") ); m_source->WriteLn( wxT(" * Class ") + class_name); m_source->WriteLn( wxT(" */") ); m_source->WriteLn( ); m_source->WriteLn( wxT("class ") + classDecoration + class_name + wxT(" extends ") + GetCode( class_obj, wxT("base") ).Trim() + wxT(" {") ); m_source->Indent(); // The constructor is also included within public GenConstructor( class_obj, events ); GenDestructor( class_obj, events ); m_source->WriteLn( wxT("") ); // event handlers GenVirtualEventHandlers(events, eventHandlerPostfix); GetGenEventHandlers( class_obj ); m_source->Unindent(); m_source->WriteLn( wxT("}") ); m_source->WriteLn( wxT("") ); }
status_t PDirectory::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; BDirectory *backend = (BDirectory*)fBackend; if (str.ICompare("IsRoot") == 0) ((BoolProperty*)prop)->SetValue(backend->IsRootDirectory()); else if (str.ICompare("EntryCount") == 0) ((IntProperty*)prop)->SetValue(backend->CountEntries()); else { return PNode::GetProperty(name, value, index); } return prop->GetValue(value); }
status_t PTextView::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; BTextView *backend = (BTextView*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("LineCount") == 0) ((IntProperty*)prop)->SetValue(backend->CountLines()); else if (str.ICompare("Selectable") == 0) ((BoolProperty*)prop)->SetValue(backend->IsSelectable()); else if (str.ICompare("CurrentLine") == 0) ((IntProperty*)prop)->SetValue(backend->CurrentLine()); else if (str.ICompare("TabWidth") == 0) ((FloatProperty*)prop)->SetValue(backend->TabWidth()); else if (str.ICompare("TextRect") == 0) ((RectProperty*)prop)->SetValue(backend->TextRect()); else if (str.ICompare("MaxBytes") == 0) ((IntProperty*)prop)->SetValue(backend->MaxBytes()); else if (str.ICompare("UseWordWrap") == 0) ((BoolProperty*)prop)->SetValue(backend->DoesWordWrap()); else if (str.ICompare("HideTyping") == 0) ((BoolProperty*)prop)->SetValue(backend->IsTypingHidden()); else if (str.ICompare("Editable") == 0) ((BoolProperty*)prop)->SetValue(backend->IsEditable()); else if (str.ICompare("ColorSpace") == 0) ((IntProperty*)prop)->SetValue(backend->ColorSpace()); else if (str.ICompare("TextLength") == 0) ((IntProperty*)prop)->SetValue(backend->TextLength()); else if (str.ICompare("Text") == 0) ((StringProperty*)prop)->SetValue(backend->Text()); else if (str.ICompare("Resizable") == 0) ((BoolProperty*)prop)->SetValue(backend->IsResizable()); else if (str.ICompare("Alignment") == 0) ((EnumProperty*)prop)->SetValue(backend->Alignment()); else if (str.ICompare("Undoable") == 0) ((BoolProperty*)prop)->SetValue(backend->DoesUndo()); else if (str.ICompare("AutoIndent") == 0) ((BoolProperty*)prop)->SetValue(backend->DoesAutoindent()); else if (str.ICompare("Stylable") == 0) ((BoolProperty*)prop)->SetValue(backend->IsStylable()); 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 PProgressBar::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; BStatusBar *backend = (BStatusBar*)fView; BoolValue boolval; 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("BarColor") == 0) { prop->GetValue(&colorval); backend->SetBarColor(*colorval.value); } else if (str.ICompare("BarHeight") == 0) { prop->GetValue(&floatval); backend->SetBarHeight(*floatval.value); } else if (str.ICompare("CurrentValue") == 0) { prop->GetValue(&floatval); float current = backend->CurrentValue(); backend->Update((*floatval.value) - current); } else if (str.ICompare("MaxValue") == 0) { prop->GetValue(&floatval); backend->SetMaxValue(*floatval.value); } else if (str.ICompare("Text") == 0) { prop->GetValue(&stringval); backend->SetText(*stringval.value); } else if (str.ICompare("TrailingText") == 0) { prop->GetValue(&stringval); backend->SetTrailingText(*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); }
PObjectBase XrcLoader::GetObject( ticpp::Element *xrcObj, PObjectBase parent ) { // First, create the object by the name, the modify the properties std::string className = xrcObj->GetAttribute( "class" ); if ( parent->GetObjectTypeName() == wxT( "project" ) ) { if ( className == "wxBitmap" ) { PProperty bitmapsProp = parent->GetProperty( _( "bitmaps" ) ); if ( bitmapsProp ) { wxString value = bitmapsProp->GetValue(); wxString text = _WXSTR( xrcObj->GetText() ); text.Replace( wxT( "\'" ), wxT( "\'\'" ), true ); value << wxT( "\'" ) << text << wxT( "\' " ); bitmapsProp->SetValue( value ); return PObjectBase(); } } if ( className == "wxIcon" ) { PProperty iconsProp = parent->GetProperty( _( "icons" ) ); if ( iconsProp ) { wxString value = iconsProp->GetValue(); wxString text = _WXSTR( xrcObj->GetText() ); text.Replace( wxT( "\'" ), wxT( "\'\'" ), true ); value << wxT( "\'" ) << text << wxT( "\' " ); iconsProp->SetValue( value ); return PObjectBase(); } } // Forms wxPanel, wxFrame, wxDialog are stored internally as Panel, Frame, and Dialog // to prevent conflicts with wxPanel as a container className = className.substr( 2, className.size() - 2 ); } // Well, this is not nice. wxMenu class name is ambiguous, so we'll get the // correct class by the context. If the parent of a wxMenu is another wxMenu // then the class name will be "submenu" else if ( className == "wxMenu" && ( parent->GetClassName() == wxT( "wxMenu" ) || parent->GetClassName() == wxT( "submenu" ) ) ) { className = "submenu"; } // "separator" is also ambiguous - could be a toolbar separator or a menu separator else if ( className == "separator" ) { if ( parent->GetClassName() == wxT( "wxToolBar" ) ) { className = "toolSeparator"; } } // replace "spacer" with "sizeritem" so it will be imported as a "sizeritem" // "sizeritem" is ambiguous - could also be a grid bag sizeritem else if ( className == "spacer" || className == "sizeritem" ) { if ( parent->GetClassName() == wxT( "wxGridBagSizer" ) ) { className = "gbsizeritem"; } else { className = "sizeritem"; } } PObjectBase object; PObjectInfo objInfo = m_objDb->GetObjectInfo( _WXSTR( className ) ); if ( objInfo ) { IComponent *comp = objInfo->GetComponent(); if ( !comp ) { wxLogError( _("No component found for class \"%s\", found on line %i."), _WXSTR( className ).c_str(), xrcObj->Row() ); } else { ticpp::Element *fbObj = comp->ImportFromXrc( xrcObj ); if ( !fbObj ) { wxLogError( _("ImportFromXrc returned NULL for class \"%s\", found on line %i."), _WXSTR( className ).c_str(), xrcObj->Row() ); } else { object = m_objDb->CreateObject( fbObj, parent ); if ( !object ) { // Unable to create the object and add it to the parent - probably needs a sizer PObjectBase newsizer = m_objDb->CreateObject( "wxBoxSizer", parent ); if ( newsizer ) { // It is possible the CreateObject returns an "item" containing the object, e.g. SizerItem or SplitterItem // If that is the case, reassign "object" to the actual object PObjectBase sizer = newsizer; if ( sizer->GetChildCount() > 0 ) { sizer = sizer->GetChild( 0 ); } if ( sizer ) { object = m_objDb->CreateObject( fbObj, sizer ); if ( object ) { parent->AddChild( newsizer ); newsizer->SetParent( parent ); } } } } if ( !object ) { wxLogError( wxT( "CreateObject failed for class \"%s\", with parent \"%s\", found on line %i" ), _WXSTR( className ).c_str(), parent->GetClassName().c_str(), xrcObj->Row() ); } else { // It is possible the CreateObject returns an "item" containing the object, e.g. SizerItem or SplitterItem // If that is the case, reassign "object" to the actual object if ( object && object->GetChildCount() > 0 ) object = object->GetChild( 0 ); if ( object ) { // Recursively import the children ticpp::Element *element = xrcObj->FirstChildElement( "object", false ); while ( element ) { GetObject( element, object ); element = element->NextSiblingElement( "object", false ); } } } } } } else { // Create a wxPanel to represent unknown classes object = m_objDb->CreateObject( "wxPanel", parent ); if ( object ) { parent->AddChild( object ); object->SetParent( parent ); wxLogError( wxT( "Unknown class \"%s\" found on line %i, replaced with a wxPanel" ), _WXSTR( className ).c_str(), xrcObj->Row() ); } else { wxString msg( wxString::Format( wxT( "Unknown class \"%s\" found on line %i, and could not replace with a wxPanel as child of \"%s:%s\"" ), _WXSTR( className ).c_str(), xrcObj->Row(), parent->GetPropertyAsString( wxT( "name" ) ).c_str(), parent->GetClassName().c_str() ) ); wxLogError( msg ); } } return object; }
/** * Convierte el valor de una propiedad a código C++. */ string CppTemplateParser::PropertyToCode(PProperty property) { PropertyType type = property->GetType(); string value = property->GetValue(); string result; switch (type) { case PT_WXSTRING: // TO-DO's // Las cadenas de caracteres (wxString) hay que pasarlas a cadenas tipo "C" // "Hola" -> wxT("\"Hola\"") result = "wxT(\"" + ConvertCppString(value) + "\")"; break; case PT_MACRO: case PT_TEXT: case PT_OPTION: result = value; break; case PT_BITLIST: if (value == "") result = "0"; else result = value; break; case PT_WXPOINT: if (value == "") result = "wxDefaultPosition"; else result = "wxPoint(" + value + ")"; break; case PT_WXSIZE: if (value == "") result = "wxDefaultSize"; else result = "wxSize(" + value + ")"; break; case PT_BOOL: if (value == "0") result = "false"; else result = "true"; break; case PT_WXFONT: if (value != "") { wxFont font = TypeConv::StringToFont(wxString(value.c_str(),wxConvUTF8)); wxString underlined(wxT("false")); if (font.GetUnderlined()) underlined = wxT("true"); wxString font_str = wxString::Format(wxT("wxFont(%d,%d,%d,%d,%s,wxT(\"%s\"))"), font.GetPointSize(), font.GetFamily(), font.GetStyle(), font.GetWeight(), underlined.c_str(), font.GetFaceName().c_str()); result = string(font_str.mb_str()); } else result = "wxFont()"; break; case PT_WXCOLOUR: if (value != "") { wxColour colour = TypeConv::StringToColour(wxString(value.c_str(),wxConvUTF8)); wxString col_str = wxString::Format(wxT("wxColour(%d,%d,%d)"), colour.Red(),colour.Green(),colour.Blue()); result = string(col_str.mb_str()); } else result = "wxColour()"; break; case PT_BITMAP: // La generación de esta propiedad es provisional ya que la idea // principal es que los archivos xpm se incluyan (#include) en el // fichero cpp y no cargarlo de un fichero. result = "wxBitmap(wxT(\"" + ConvertCppString(value) + "\"), wxBITMAP_TYPE_XPM)"; break; default: break; } return result; }
void VisualEditor::ScanPanes( wxWindow* parent) { bool updateNeeded; wxLogNull stopTheLogging; const wxWindowList& children = parent->GetChildren(); for ( wxWindowList::const_reverse_iterator child = children.rbegin(); child != children.rend(); ++child ) { ScanPanes(*child); PObjectBase obj = GetObjectBase( *child ); if ( obj ) { updateNeeded = false; PObjectInfo obj_info = obj->GetObjectInfo(); wxString cname = obj_info->GetObjectType()->GetName(); if( cname == wxT("widget") || cname == wxT("expanded_widget") || cname == wxT("toolbar") || cname == wxT("container") ) { wxAuiPaneInfo inf = m_auimgr->GetPane(*child); if(inf.IsOk()) { // scan position and docking mode if( !obj->GetPropertyAsInteger( wxT("center_pane") ) ) { wxString dock; if( inf.IsDocked()) { wxString dockDir; switch(inf.dock_direction) { case 1: dockDir = wxT("Top"); break; case 2: dockDir = wxT("Right"); break; case 3: dockDir = wxT("Bottom"); break; case 4: dockDir = wxT("Left"); break; case 5: dockDir = wxT("Center"); break; default: dockDir = wxT("Left"); break; } PProperty pdock = obj->GetProperty( wxT("docking") ); if( pdock->GetValue() != dockDir ) { pdock->SetValue( dockDir ); updateNeeded = true; } dock = wxT("Dock"); } else { // scan "floating position" wxPoint pos = inf.floating_pos; if ( pos.x != -1 && pos.y != -1 ) { PProperty pposition = obj->GetProperty( wxT("pane_position") ); if( pposition->GetValue() != TypeConv::PointToString( pos ) ) { pposition->SetValue( TypeConv::PointToString( pos ) ); updateNeeded = true; } } // scan "floating size" wxSize paneSize = inf.floating_size; if ( paneSize.x != -1 && paneSize.y != -1 ) { PProperty psize = obj->GetProperty( wxT("pane_size") ); if( psize->GetValue() != TypeConv::SizeToString( paneSize ) ) { psize->SetValue( TypeConv::SizeToString( paneSize ) ); obj->GetProperty( wxT("resize") )->SetValue( wxT("Resizable") ); updateNeeded = true; } } dock = wxT("Float"); } PProperty pfloat = obj->GetProperty(wxT("dock") ); if( pfloat->GetValue() != dock ) { pfloat->SetValue( dock ); updateNeeded = true; } // scan "best size" /*wxSize bestSize = inf.best_size; if ( bestSize.x != -1 && bestSize.y != -1 ) { PProperty psize = obj->GetProperty( wxT("best_size") ); if( psize->GetValue() != TypeConv::SizeToString( bestSize ) ) { psize->SetValue( TypeConv::SizeToString( bestSize ) ); obj->GetProperty( wxT("resize") )->SetValue( wxT("Resizable") ); updateNeeded = true; } }*/ // scan "row" and "layer" PProperty prop = obj->GetProperty(wxT("aui_row") ); if( obj->GetPropertyAsInteger( wxT("aui_row") ) != inf.dock_row ) { prop->SetValue( inf.dock_row ); updateNeeded = true; } prop = obj->GetProperty(wxT("aui_layer") ); if( obj->GetPropertyAsInteger( wxT("aui_layer") ) != inf.dock_layer ) { prop->SetValue( inf.dock_layer ); updateNeeded = true; } } // scan "show" property PProperty pshow = obj->GetProperty(wxT("show") ); if( obj->GetPropertyAsInteger( wxT("show") ) != (int) inf.IsShown() ) { pshow->SetValue( inf.IsShown() ); updateNeeded = true; } if( updateNeeded ) AppData()->SelectObject( obj, true, true ); } } } } }
void VisualEditor::SetupWindow( PObjectBase obj, wxWindow* window ) { // All of the properties of the wxWindow object are applied in this function // Position /* Position does nothing in wxFB - this is pointless wxPoint pos; PProperty ppos = obj->GetProperty( wxT("pos") ); if ( ppos ) { pos = TypeConv::StringToPoint( ppos->GetValue() ); } */ // Size wxSize size = obj->GetPropertyAsSize( wxT("size") ); if ( size != wxDefaultSize ) { window->SetSize( size ); } // Minimum size wxSize minsize = obj->GetPropertyAsSize( wxT("minimum_size") ); if ( minsize != wxDefaultSize ) { window->SetMinSize( minsize ); } // Maximum size wxSize maxsize = obj->GetPropertyAsSize( wxT("maximum_size") ); if ( maxsize != wxDefaultSize ) { window->SetMaxSize( maxsize ); } // Font PProperty pfont = obj->GetProperty( wxT("font") ); if ( pfont && !pfont->GetValue().empty() ) { window->SetFont( TypeConv::StringToFont( pfont->GetValue() ) ); } // Foreground PProperty pfg_colour = obj->GetProperty( wxT("fg") ); if ( pfg_colour && !pfg_colour->GetValue().empty() ) { window->SetForegroundColour( TypeConv::StringToColour( pfg_colour->GetValue() ) ); } // Background PProperty pbg_colour = obj->GetProperty( wxT("bg") ); if ( pbg_colour && !pbg_colour->GetValue().empty() ) { window->SetBackgroundColour( TypeConv::StringToColour( pbg_colour->GetValue() ) ); } // Extra Style PProperty pextra_style = obj->GetProperty( wxT("window_extra_style") ); if ( pextra_style ) { window->SetExtraStyle( TypeConv::StringToInt( pextra_style->GetValue() ) ); } // Enabled PProperty penabled = obj->GetProperty( wxT("enabled") ); if ( penabled ) { window->Enable( ( penabled->GetValueAsInteger() !=0 ) ); } // Hidden PProperty phidden = obj->GetProperty( wxT("hidden") ); if ( phidden ) { window->Show( !phidden->GetValueAsInteger() ); } // Tooltip PProperty ptooltip = obj->GetProperty( wxT("tooltip") ); if ( ptooltip ) { window->SetToolTip( ptooltip->GetValueAsString() ); } //AUI wxString tname = obj->GetObjectInfo()->GetObjectType()->GetName(); if( m_auimgr && ( tname == wxT("widget") || tname == wxT("expanded_widget") || tname == wxT("container") || tname == wxT("notebook") || tname == wxT("auinotebook") || tname == wxT("choicebook") || tname == wxT("treelistctrl") || tname == wxT("splitter") ) ) { if( obj->GetParent()->GetObjectTypeName() == wxT("form") ) { SetupAui(obj, window); } } // Wizard else if ( obj->GetParent()->GetObjectTypeName() == wxT("wizard") ) { SetupWizard( obj, window, true ); } }
status_t PMenuItem::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; BMenuItem *backend = (BMenuItem*)fBackend; 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 (str.ICompare("Message") == 0) { prop->GetValue(&intval); backend->SetMessage(new BMessage(*intval.value)); } else if (str.ICompare("Trigger") == 0) { prop->GetValue(&charval); backend->SetTrigger(*charval.value); } else if (str.ICompare("Label") == 0) { prop->GetValue(&stringval); backend->SetLabel(*stringval.value); } else if (str.ICompare("Marked") == 0) { prop->GetValue(&boolval); backend->SetMarked(*boolval.value); } else if (str.ICompare("Enabled") == 0) { prop->GetValue(&boolval); backend->SetEnabled(*boolval.value); } else { return PObject::SetProperty(name, value, index); } return prop->GetValue(value); }
void VisualEditor::SetupWindow( PObjectBase obj, wxWindow* window ) { // All of the properties of the wxWindow object are applied in this function // Position /* Position does nothing in wxFB - this is pointless wxPoint pos; PProperty ppos = obj->GetProperty( wxT("pos") ); if ( ppos ) { pos = TypeConv::StringToPoint( ppos->GetValue() ); } */ // Size wxSize size = obj->GetPropertyAsSize( wxT("size") ); if ( size != wxDefaultSize ) { window->SetSize( size ); } // Minimum size wxSize minsize = obj->GetPropertyAsSize( wxT("minimum_size") ); if ( minsize != wxDefaultSize ) { window->SetMinSize( minsize ); } // Maximum size wxSize maxsize = obj->GetPropertyAsSize( wxT("maximum_size") ); if ( maxsize != wxDefaultSize ) { window->SetMaxSize( maxsize ); } // Font PProperty pfont = obj->GetProperty( wxT("font") ); if ( pfont && !pfont->GetValue().empty() ) { window->SetFont( TypeConv::StringToFont( pfont->GetValue() ) ); } // Foreground PProperty pfg_colour = obj->GetProperty( wxT("fg") ); if ( pfg_colour && !pfg_colour->GetValue().empty() ) { window->SetForegroundColour( TypeConv::StringToColour( pfg_colour->GetValue() ) ); } // Background PProperty pbg_colour = obj->GetProperty( wxT("bg") ); if ( pbg_colour && !pbg_colour->GetValue().empty() ) { window->SetBackgroundColour( TypeConv::StringToColour( pbg_colour->GetValue() ) ); } // Extra Style PProperty pextra_style = obj->GetProperty( wxT("window_extra_style") ); if ( pextra_style ) { window->SetExtraStyle( TypeConv::StringToInt( pextra_style->GetValue() ) ); } // Enabled PProperty penabled = obj->GetProperty( wxT("enabled") ); if ( penabled ) { window->Enable( ( penabled->GetValueAsInteger() !=0 ) ); } // Hidden PProperty phidden = obj->GetProperty( wxT("hidden") ); if ( phidden ) { window->Show( !phidden->GetValueAsInteger() ); } // Tooltip PProperty ptooltip = obj->GetProperty( wxT("tooltip") ); if ( ptooltip ) { window->SetToolTip( ptooltip->GetValueAsString() ); } }
status_t PListView::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; BListView *backend = (BListView*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("PreferredWidth") == 0) { if (backend->CountItems() == 0) ((FloatProperty*)prop)->SetValue(100); else { float pw, ph; backend->GetPreferredSize(&pw, &ph); if (pw < 10) pw = 100; if (ph < 10) ph = 30; ((FloatProperty*)prop)->SetValue(pw); } } else if (str.ICompare("ItemCount") == 0) ((IntProperty*)prop)->SetValue(backend->CountItems()); else if (str.ICompare("SelectionMessage") == 0) ((IntProperty*)prop)->SetValue(backend->SelectionCommand()); else if (str.ICompare("PreferredHeight") == 0) { if (backend->CountItems() == 0) ((FloatProperty*)prop)->SetValue(30); else { float pw, ph; backend->GetPreferredSize(&pw, &ph); if (pw < 10) pw = 100; if (ph < 10) ph = 30; ((FloatProperty*)prop)->SetValue(ph); } } else if (str.ICompare("InvocationMessage") == 0) ((IntProperty*)prop)->SetValue(backend->InvocationCommand()); else if (str.ICompare("SelectionType") == 0) ((EnumProperty*)prop)->SetValue(backend->ListType()); 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 PTextView::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; BTextView *backend = (BTextView*)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("Selectable") == 0) { prop->GetValue(&boolval); backend->MakeSelectable(*boolval.value); } else if (str.ICompare("CurrentLine") == 0) { prop->GetValue(&intval); backend->GoToLine(*intval.value); } else if (str.ICompare("TabWidth") == 0) { prop->GetValue(&floatval); backend->SetTabWidth(*floatval.value); } else if (str.ICompare("TextRect") == 0) { prop->GetValue(&rectval); backend->SetTextRect(*rectval.value); } else if (str.ICompare("MaxBytes") == 0) { prop->GetValue(&intval); backend->SetMaxBytes(*intval.value); } else if (str.ICompare("UseWordWrap") == 0) { prop->GetValue(&boolval); backend->SetWordWrap(*boolval.value); } else if (str.ICompare("HideTyping") == 0) { prop->GetValue(&boolval); backend->HideTyping(*boolval.value); } else if (str.ICompare("Editable") == 0) { prop->GetValue(&boolval); backend->MakeEditable(*boolval.value); } else if (str.ICompare("ColorSpace") == 0) { prop->GetValue(&intval); backend->SetColorSpace((color_space)*intval.value); } else if (str.ICompare("Text") == 0) { prop->GetValue(&stringval); backend->SetText(*stringval.value); } else if (str.ICompare("Resizable") == 0) { prop->GetValue(&boolval); backend->MakeResizable(*boolval.value); } else if (str.ICompare("Alignment") == 0) { prop->GetValue(&intval); backend->SetAlignment((alignment)*intval.value); } else if (str.ICompare("Undoable") == 0) { prop->GetValue(&boolval); backend->SetDoesUndo(*boolval.value); } else if (str.ICompare("AutoIndent") == 0) { prop->GetValue(&boolval); backend->SetAutoindent(*boolval.value); } else if (str.ICompare("Stylable") == 0) { prop->GetValue(&boolval); backend->SetStylable(*boolval.value); } else { if (backend->Window()) backend->Window()->Unlock(); return PView::SetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }
void PHPCodeGenerator::GenEvents( PObjectBase class_obj, const EventVector &events, bool disconnect ) { if ( events.empty() ) { return; } if( disconnect ) { m_source->WriteLn( wxT("// Disconnect Events") ); } else { m_source->WriteLn(); m_source->WriteLn( wxT("// Connect Events") ); } PProperty propName = class_obj->GetProperty( wxT("name") ); if ( !propName ) { wxLogError(wxT("Missing \"name\" property on \"%s\" class. Review your XML object description"), class_obj->GetClassName().c_str()); return; } wxString class_name = propName->GetValue(); if ( class_name.empty() ) { wxLogError( wxT("Object name cannot be null") ); return; } wxString base_class; wxString handlerName; PProperty propSubclass = class_obj->GetProperty( wxT("subclass") ); if ( propSubclass ) { wxString subclass = propSubclass->GetChildFromParent( wxT("name") ); if ( !subclass.empty() ) { base_class = subclass; } } if ( base_class.empty() ) base_class = wxT("wx") + class_obj->GetClassName(); if ( events.size() > 0 ) { for ( size_t i = 0; i < events.size(); i++ ) { PEvent event = events[i]; handlerName = event->GetValue(); wxString templateName = wxString::Format( wxT("connect_%s"), event->GetName().c_str() ); PObjectBase obj = event->GetObject(); if ( !GenEventEntry( obj, obj->GetObjectInfo(), templateName, handlerName, disconnect ) ) { wxLogError( wxT("Missing \"evt_%s\" template for \"%s\" class. Review your XML object description"), templateName.c_str(), class_name.c_str() ); } } } }
bool PHPCodeGenerator::GenerateCode( PObjectBase project ) { if (!project) { wxLogError(wxT("There is no project to generate code")); return false; } m_i18n = false; PProperty i18nProperty = project->GetProperty( wxT("internationalize") ); if (i18nProperty && i18nProperty->GetValueAsInteger()) m_i18n = true; m_disconnectEvents = ( project->GetPropertyAsInteger( wxT("disconnect_php_events") ) != 0 ); m_source->Clear(); // Insert php preamble wxString code = GetCode( project, wxT("php_preamble") ); if ( !code.empty() ) { m_source->WriteLn( code ); m_source->WriteLn( wxEmptyString ); } code = ( wxT("/*\n") wxT(" * PHP code generated with wxFormBuilder (version ") wxT(__DATE__) wxT(")\n") wxT(" * http://www.wxformbuilder.org/\n") wxT(" *\n") wxT(" * PLEASE DO *NOT* EDIT THIS FILE!\n") wxT(" */\n") ); m_source->WriteLn( code ); PProperty propFile = project->GetProperty( wxT("file") ); if (!propFile) { wxLogError( wxT("Missing \"file\" property on Project Object") ); return false; } wxString file = propFile->GetValue(); if ( file.empty() ) { file = wxT("noname"); } // Generate the subclass sets std::set< wxString > subclasses; std::vector< wxString > headerIncludes; GenSubclassSets( project, &subclasses, &headerIncludes ); // Generating in the .h header file those include from components dependencies. std::set< wxString > templates; GenIncludes(project, &headerIncludes, &templates ); // Write the include lines std::vector<wxString>::iterator include_it; for ( include_it = headerIncludes.begin(); include_it != headerIncludes.end(); ++include_it ) { m_source->WriteLn( *include_it ); } if ( !headerIncludes.empty() ) { m_source->WriteLn( wxT("") ); } // Write internationalization support if( m_i18n ) { //PHP gettext already implements this function //m_source->WriteLn( wxT("function _(){ /*TODO: Implement this function on wxPHP*/ }") ); //m_source->WriteLn( wxT("") ); } // Generating "defines" for macros GenDefines( project ); wxString eventHandlerPostfix; PProperty eventKindProp = project->GetProperty( wxT("skip_php_events") ); if( eventKindProp->GetValueAsInteger() ) { eventHandlerPostfix = wxT("$event->Skip();"); } else eventHandlerPostfix = wxT(""); PProperty disconnectMode = project->GetProperty( wxT("disconnect_mode") ); m_disconnecMode = disconnectMode->GetValueAsString(); for ( unsigned int i = 0; i < project->GetChildCount(); i++ ) { PObjectBase child = project->GetChild( i ); EventVector events; FindEventHandlers( child, events ); //GenClassDeclaration( child, useEnum, classDecoration, events, eventHandlerPrefix, eventHandlerPostfix ); GenClassDeclaration( child, false, wxT(""), events, eventHandlerPostfix ); } code = GetCode( project, wxT("php_epilogue") ); if( !code.empty() ) m_source->WriteLn( code ); return true; }