コード例 #1
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::GenObjectIncludes( PObjectBase project, std::vector< wxString >* includes, std::set< wxString >* templates )
{
	// Fill the set
	PCodeInfo code_info = project->GetObjectInfo()->GetCodeInfo( wxT("PHP") );
	if (code_info)
	{
		PHPTemplateParser parser( project, code_info->GetTemplate( wxT("include") ), m_i18n, m_useRelativePath, m_basePath );
		wxString include = parser.ParseTemplate();
		if ( !include.empty() )
		{
			if ( templates->insert( include ).second )
			{
				AddUniqueIncludes( include, includes );
			}
		}
	}

	// Call GenIncludes on all children as well
	for ( unsigned int i = 0; i < project->GetChildCount(); i++ )
	{
		GenObjectIncludes( project->GetChild(i), includes, templates );
	}

	// Generate includes for base classes
	GenBaseIncludes( project->GetObjectInfo(), project, includes, templates );
}
コード例 #2
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
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 );
	}
}
コード例 #3
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
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;
}
コード例 #4
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
void VisualEditor::SetupWizard( PObjectBase obj, wxWindow *window, bool pageAdding )
{
    WizardPageSimple *wizpage = wxDynamicCast( window, WizardPageSimple );

    if ( pageAdding )
    {
        m_wizard->AddPage( wizpage );
        m_wizard->Connect( wxID_ANY, wxFB_EVT_WIZARD_PAGE_CHANGED, WizardEventHandler( VisualEditor::OnWizardPageChanged ) );
    }
    else
    {
        WizardEvent eventChanged( wxFB_EVT_WIZARD_PAGE_CHANGED, m_wizard->GetId(), false, wizpage );
        eventChanged.SetInt( 1 );
        wizpage->GetEventHandler()->ProcessEvent( eventChanged );

        bool wizBmpOk = !obj->GetParent()->GetProperty( wxT("bitmap") )->IsNull();
        bool pgeBmpOk = !obj->GetProperty( wxT("bitmap") )->IsNull();
        wxBitmap wizBmp = obj->GetParent()->GetPropertyAsBitmap( wxT("bitmap") );
        wxBitmap pgeBmp = obj->GetPropertyAsBitmap( wxT("bitmap") );

        if ( pgeBmpOk && pgeBmp.IsOk() )
        {
            m_wizard->SetBitmap( pgeBmp );
        }
        else if ( wizBmpOk && wizBmp.IsOk() )
        {
            m_wizard->SetBitmap( wizBmp );
        }
        size_t selection = m_wizard->GetPageIndex( wizpage );
        m_wizard->SetSelection( selection );
    }
}
コード例 #5
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::GenDestruction( PObjectBase obj )
{
	wxString _template;
	PCodeInfo code_info = obj->GetObjectInfo()->GetCodeInfo( wxT( "PHP" ) );

	if ( code_info )
	{
		_template = code_info->GetTemplate( wxT( "destruction" ) );

		if ( !_template.empty() )
		{
			PHPTemplateParser parser( obj, _template, m_i18n, m_useRelativePath, m_basePath );
			wxString code = parser.ParseTemplate();
			if ( !code.empty() )
			{
				m_source->WriteLn( code );
			}
		}
	}

	// Process child widgets
	for ( unsigned int i = 0; i < obj->GetChildCount() ; i++ )
	{
		PObjectBase child = obj->GetChild( i );
		GenDestruction( child );
	}
}
コード例 #6
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::GetGenEventHandlers( PObjectBase obj )
{
	GenDefinedEventHandlers( obj->GetObjectInfo(), obj );

	for (unsigned int i = 0; i < obj->GetChildCount() ; i++)
	{
		PObjectBase child = obj->GetChild(i);
		GetGenEventHandlers(child);
	}
}
コード例 #7
0
ファイル: wxfbmanager.cpp プロジェクト: heyuqi/wxFormBuilder
size_t wxFBManager::GetChildCount( wxObject* wxobject )
{
	CHECK_VISUAL_EDITOR( 0 )

	CHECK_WX_OBJECT( 0 )

	PObjectBase obj = m_visualEdit->GetObjectBase( wxobject );

	CHECK_OBJECT_BASE( 0 )

	return obj->GetChildCount();
}
コード例 #8
0
ファイル: wxfbmanager.cpp プロジェクト: heyuqi/wxFormBuilder
IObject* wxFBManager::GetIObject( wxObject* wxobject )
{
	CHECK_VISUAL_EDITOR( NULL )

	CHECK_WX_OBJECT( NULL )

	PObjectBase obj = m_visualEdit->GetObjectBase( wxobject );

	CHECK_OBJECT_BASE( NULL )

	return obj.get();
}
コード例 #9
0
ファイル: codegen.cpp プロジェクト: joro75/wxFormBuilder
void TemplateParser::ParseLuaTable()
{
	PObjectBase project = PObjectBase(new ObjectBase(*AppData()->GetProjectData()));
	PProperty propNs= project->GetProperty( wxT( "ui_table" ) );
	if ( propNs )
	{
		wxString strTableName = propNs->GetValueAsString();
		if(strTableName.length() <= 0)
			strTableName = wxT("UI");
		m_out <<strTableName + wxT(".");
	}
}
コード例 #10
0
ファイル: cppcg.cpp プロジェクト: idrassi/wxFormBuilder
void CppCodeGenerator::GenConstructor(PObjectBase class_obj)
{
  m_source->WriteLn(GetCode(class_obj,"cons_def"));
  m_source->WriteLn("{");
  m_source->Indent();
  
  for (unsigned int i=0; i<class_obj->GetChildCount() ; i++)
    GenConstruction(class_obj->GetChild(i),true);
  
  m_source->Unindent();
  m_source->WriteLn("}");
  m_source->WriteLn("");
}
コード例 #11
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
ObjectBase::~ObjectBase()
{
	// remove the reference in the parent
	PObjectBase parent = m_parent.lock();

	if (parent)
	{
		PObjectBase pobj(GetThis());
		parent->RemoveChild(pobj);
	}

	LogDebug(wxT("delete ObjectBase"));
}
コード例 #12
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void DesignerWindow::HighlightSelection( wxDC& dc )
{
	wxSize size;
	PObjectBase object = m_selObj.lock();
	if ( m_selSizer )
	{
		wxPoint point = m_selSizer->GetPosition();
		size = m_selSizer->GetSize();
		wxPen bluePen( *wxBLUE, 1, wxSOLID );
		dc.SetPen( bluePen );
		dc.SetBrush( *wxTRANSPARENT_BRUSH );
		PObjectBase sizerParent = object->FindNearAncestorByBaseClass( wxT("sizer") );
		if ( sizerParent && sizerParent->GetParent() )
		{
			DrawRectangle( dc, point, size, sizerParent );
		}
	}

	if ( m_selItem )
	{
		wxPoint point;
		bool shown;

		wxWindow* windowItem = wxDynamicCast( m_selItem, wxWindow );
		wxSizer* sizerItem = wxDynamicCast( m_selItem, wxSizer );
		if ( NULL != windowItem )
		{
			point = windowItem->GetPosition();
			size = windowItem->GetSize();
			shown = windowItem->IsShown();
		}
		else if ( NULL != sizerItem )
		{
			point = sizerItem->GetPosition();
			size = sizerItem->GetSize();
			shown = true;
		}
		else
		{
			return;
		}

		if ( shown )
		{
			wxPen redPen( *wxRED, 1, wxSOLID );
			dc.SetPen( redPen );
			dc.SetBrush( *wxTRANSPARENT_BRUSH );
			DrawRectangle( dc, point, size, object );
		}
	}
}
コード例 #13
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
PObjectBase ObjectBase::FindNearAncestor(wxString type)
{
	PObjectBase result;
	PObjectBase parent = GetParent();
	if (parent)
	{
		if (parent->GetObjectTypeName() == type)
			result = parent;
		else
			result = parent->FindNearAncestor(type);
	}

	return result;
}
コード例 #14
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
PObjectBase ObjectBase::FindNearAncestorByBaseClass(wxString type)
{
	PObjectBase result;
	PObjectBase parent = GetParent();
	if (parent)
	{
		if ( parent->GetObjectInfo()->IsSubclassOf( type ) )
			result = parent;
		else
			result = parent->FindNearAncestorByBaseClass( type );
	}

	return result;
}
コード例 #15
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::FindDependencies( PObjectBase obj, std::set< PObjectInfo >& info_set )
{
	unsigned int ch_count = obj->GetChildCount();
	if (ch_count > 0)
	{
		unsigned int i;
		for (i = 0; i<ch_count; i++)
		{
			PObjectBase child = obj->GetChild(i);
			info_set.insert(child->GetObjectInfo());
			FindDependencies(child, info_set);
		}
	}
}
コード例 #16
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::GenConstructor( PObjectBase class_obj, const EventVector &events )
{
	m_source->WriteLn();
	// generate function definition
	m_source->WriteLn( GetCode( class_obj, wxT("cons_def") ) );
	m_source->Indent();

	m_source->WriteLn( GetCode( class_obj, wxT("cons_call") ) );
	m_source->WriteLn();

	wxString settings = GetCode( class_obj, wxT("settings") );
	if ( !settings.IsEmpty() )
	{
		m_source->WriteLn( settings );
	}

	for ( unsigned int i = 0; i < class_obj->GetChildCount(); i++ )
	{
		GenConstruction( class_obj->GetChild( i ), true );
	}

	wxString afterAddChild = GetCode( class_obj, wxT("after_addchild") );
	if ( !afterAddChild.IsEmpty() )
	{
		m_source->WriteLn( afterAddChild );
	}

	GenEvents( class_obj, events );

	m_source->Unindent();
	m_source->WriteLn( wxT("}") );
	m_source->WriteLn( wxT("") );

	if ( class_obj->GetObjectTypeName() == wxT("wizard") && class_obj->GetChildCount() > 0 )
	{
		m_source->WriteLn( wxT("function AddPage($page){") );
		m_source->Indent();
		m_source->WriteLn( wxT("if(count($this->m_pages) > 0){") );
		m_source->Indent();
		m_source->WriteLn( wxT("$previous_page = $this->m_pages[count($this->m_pages)-1];") );
		m_source->WriteLn( wxT("$page->SetPrev($previous_page);") );
		m_source->WriteLn( wxT("$previous_page->SetNext($page);") );
		m_source->Unindent();
		m_source->WriteLn( wxT("}") );
		m_source->WriteLn( wxT("$this->m_pages[] = $page;") );
		m_source->Unindent();
		m_source->WriteLn( wxT("}") );
	}
}
コード例 #17
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
void PHPCodeGenerator::FindEventHandlers(PObjectBase obj, EventVector &events)
{
  unsigned int i;
  for (i=0; i < obj->GetEventCount(); i++)
  {
	PEvent event = obj->GetEvent(i);
	if (!event->GetValue().IsEmpty())
	  events.push_back(event);
  }

  for (i=0; i < obj->GetChildCount(); i++)
  {
	PObjectBase child = obj->GetChild(i);
	FindEventHandlers(child,events);
  }
}
コード例 #18
0
ファイル: dataobject.cpp プロジェクト: heyuqi/wxFormBuilder
wxFBDataObject::wxFBDataObject( PObjectBase obj )
:
wxDataObject()
{
	if ( obj )
	{
		// create xml representation of ObjectBase
		ticpp::Element element;
		obj->SerializeObject( &element );

		// add version info to xml data, just in case it is pasted into a different version of wxFB
		element.SetAttribute( "fbp_version_major", AppData()->m_fbpVerMajor );
		element.SetAttribute( "fbp_version_minor", AppData()->m_fbpVerMinor );

		ticpp::Document doc;
		doc.LinkEndChild( &element );
		TiXmlPrinter printer;
        printer.SetIndent( "\t" );

        #if defined( __WXMSW__ )
            printer.SetLineBreak( "\r\n" );
        #else
            printer.SetLineBreak( "\n" );
        #endif

        doc.Accept( &printer );
		m_data = printer.Str();
	}
}
コード例 #19
0
ファイル: wxfbmanager.cpp プロジェクト: heyuqi/wxFormBuilder
wxObject* wxFBManager::GetChild( wxObject* wxobject, size_t childIndex )
{
	CHECK_VISUAL_EDITOR( NULL )

	CHECK_WX_OBJECT( NULL )

	PObjectBase obj = m_visualEdit->GetObjectBase( wxobject );

	CHECK_OBJECT_BASE( NULL )

	if ( childIndex >= obj->GetChildCount() )
	{
		return NULL;
	}

	return m_visualEdit->GetWxObject( obj->GetChild( childIndex ) );
}
コード例 #20
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::SetupSizer( PObjectBase obj, wxSizer* sizer )
{
	wxSize minsize = obj->GetPropertyAsSize( wxT("minimum_size") );
	if ( minsize != wxDefaultSize )
	{
		sizer->SetMinSize( minsize );
		sizer->Layout();
	}
}
コード例 #21
0
ファイル: cppcg.cpp プロジェクト: idrassi/wxFormBuilder
void CppCodeGenerator::FindMacros(PObjectBase obj, set<string> &macro_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);
  }
}
コード例 #22
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::ClearComponents( wxWindow* parent )
{
    wxLogNull stopTheLogging;
    const wxWindowList& children = parent->GetChildren();
    for ( wxWindowList::const_reverse_iterator child = children.rbegin(); child != children.rend(); ++child )
    {
        ClearComponents( *child );

        PObjectBase obj = GetObjectBase( *child );
        if ( obj )
        {
            PObjectInfo obj_info = obj->GetObjectInfo();
            IComponent* comp = obj_info->GetComponent();
            if ( comp )
            {
                comp->Cleanup( *child );
            }
        }
    }
}
コード例 #23
0
ファイル: cppcg.cpp プロジェクト: idrassi/wxFormBuilder
string CppCodeGenerator::GetCode(PObjectBase obj, string name)
{
  string _template;
  PCodeInfo code_info = obj->GetObjectInfo()->GetCodeInfo("C++");
  _template = code_info->GetTemplate(name);
  
  CppTemplateParser parser(obj,_template);
  string code = parser.ParseTemplate();

  return code;
}
コード例 #24
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
bool ObjectBase::AddChild (unsigned int idx, PObjectBase obj)
{
	bool result = false;
	if (ChildTypeOk(obj->GetObjectInfo()->GetObjectType()) && idx <= m_children.size())
		//if (ChildTypeOk(obj->GetObjectTypeName()) && idx <= m_children.size())
	{
		m_children.insert(m_children.begin() + idx,obj);
		result = true;
	}

	return result;
}
コード例 #25
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
bool ObjectBase::AddChild (PObjectBase obj)
{
	bool result = false;
	if (ChildTypeOk(obj->GetObjectInfo()->GetObjectType()))
		//if (ChildTypeOk(obj->GetObjectTypeName()))
	{
		m_children.push_back(obj);
		result = true;
	}

	return result;
}
コード例 #26
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::OnResizeBackPanel (wxCommandEvent &) //(wxSashEvent &event)
{
	/*wxRect rect(event.GetDragRect());
	Debug::Print("VisualEditor::OnResizeBackPanel [%d,%d,%d,%d]",rect.x,rect.y,rect.width, rect.height);
	m_back->SetSize(rect.width,rect.height);
	m_back->Layout();*/

	PObjectBase form (AppData()->GetSelectedForm());

	if (form)
	{
		PProperty prop(form->GetProperty( wxT("size") ));
		if (prop)
		{
			wxString value(TypeConv::PointToString(wxPoint(m_back->GetSize().x, m_back->GetSize().y)));
			AppData()->ModifyProperty(prop, value);
		}
	}

	//event.Skip();
}
コード例 #27
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void DesignerWindow::DrawRectangle( wxDC& dc, const wxPoint& point, const wxSize& size, PObjectBase object )
{
	bool isSizer = ( object->GetObjectInfo()->IsSubclassOf( wxT("sizer") ) );
	int min = ( isSizer ? 0 : 1 );

	int border = object->GetParent()->GetPropertyAsInteger( wxT("border") );
	if ( border == 0 )
	{
		border = min;
	}

	int flag = object->GetParent()->GetPropertyAsInteger( wxT("flag") );
	int topBorder = 	( flag & wxTOP ) 	== 0 ? min : border;
	int bottomBorder = 	( flag & wxBOTTOM ) == 0 ? min : border;
	int rightBorder = 	( flag & wxRIGHT ) 	== 0 ? min : border;
	int leftBorder = 	( flag & wxLEFT ) 	== 0 ? min : border;

	dc.DrawRectangle( 	point.x - leftBorder,
						point.y - topBorder,
						size.x + leftBorder + rightBorder,
						size.y + topBorder + bottomBorder );
}
コード例 #28
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
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("") );
}
コード例 #29
0
ファイル: cppcg.cpp プロジェクト: idrassi/wxFormBuilder
bool CppCodeGenerator::GenerateCode(PObjectBase project)
{
  m_header->Clear();
  m_source->Clear();
  string date(__DATE__);
  string time(__TIME__);
  string code_header (
   "///////////////////////////////////////////////////////////////////////////\n"
   "// C++ code generated with wxFormBuilder (version " __DATE__ ")\n" 
   "// http://wxformbuilder.software-libre.org/\n"
   "//\n"
   "// PLEASE DO \"NOT\" EDIT THIS FILE!\n"
   "///////////////////////////////////////////////////////////////////////////\n");
   
  m_header->WriteLn(code_header);
  m_source->WriteLn(code_header);
  
  string file = project->GetProperty("file")->GetValue();
  
  m_header->WriteLn("#ifndef __" + file + "__");
  m_header->WriteLn("#define __" + file + "__");

  m_source->WriteLn("#include \""+file+".h\"");
  
  
  GenIncludes(project);
  GenDefines(project);
  
  for (unsigned int i=0; i<project->GetChildCount(); i++)
  {
    GenClassDeclaration(project->GetChild(i));
    GenConstructor(project->GetChild(i));
  }
  
  m_header->WriteLn("#endif //__" + file + "__");
  m_header->WriteLn("");
  
  return true;
}
コード例 #30
0
ファイル: cppcg.cpp プロジェクト: idrassi/wxFormBuilder
void CppCodeGenerator::GenIncludes(PObjectBase project)
{
  m_header->WriteLn("#include <wx/wx.h>");
  // almacenaremos todos los objetos diferentes que se encuentran en el
  // proyecto para luego generar los includes.
  set<PObjectInfo> info_set;
 
  // buscamos todas las dependencias
  for (unsigned int i=0; i<project->GetChildCount(); i++)
    FindDependencies(project->GetChild(i), info_set);

  // generamos los includes
  set<PObjectInfo>::iterator it;
  for (it = info_set.begin() ; it != info_set.end() ; it++)
  {
    PCodeInfo code_info = (*it)->GetCodeInfo("C++");
    string include = code_info->GetTemplate("include");
    if (include != "")
      m_header->WriteLn(include);
  }
  
  m_header->WriteLn("");
}