Exemple #1
0
wxMenu* DesignerWindow::GetMenuFromObject(PObjectBase menu)
{
	int lastMenuId = wxID_HIGHEST + 1;
	wxMenu* menuWidget = new wxMenu();
	for ( unsigned int j = 0; j < menu->GetChildCount(); j++ )
	{
		PObjectBase menuItem = menu->GetChild( j );
		if ( menuItem->GetObjectTypeName() == wxT("submenu") )
		{
			menuWidget->Append( lastMenuId++, menuItem->GetPropertyAsString( wxT("label") ), GetMenuFromObject( menuItem ) );
		}
		else if ( menuItem->GetClassName() == wxT("separator") )
		{
			menuWidget->AppendSeparator();
		}
		else
		{
			wxString label = menuItem->GetPropertyAsString( wxT("label") );
			wxString shortcut = menuItem->GetPropertyAsString( wxT("shortcut") );
			if ( !shortcut.IsEmpty() )
			{
				label = label + wxChar('\t') + shortcut;
			}

			wxMenuItem *item = new wxMenuItem( 	menuWidget,
												lastMenuId++,
												label,
												menuItem->GetPropertyAsString( wxT("help") ),
												( wxItemKind ) menuItem->GetPropertyAsInteger( wxT("kind") )
											);

			if ( !menuItem->GetProperty( wxT("bitmap") )->IsNull() )
			{
				wxBitmap unchecked = wxNullBitmap;
				if ( !menuItem->GetProperty( wxT("unchecked_bitmap") )->IsNull() )
				{
					unchecked = menuItem->GetPropertyAsBitmap( wxT("unchecked_bitmap") );
				}
				#ifdef __WXMSW__
					item->SetBitmaps( menuItem->GetPropertyAsBitmap( wxT("bitmap") ), unchecked );
				#elif defined( __WXGTK__ )
					item->SetBitmap( menuItem->GetPropertyAsBitmap( wxT("bitmap") ) );
				#endif
			}
			else
			{
				if ( !menuItem->GetProperty( wxT("unchecked_bitmap") )->IsNull() )
				{
					#ifdef __WXMSW__
						item->SetBitmaps( wxNullBitmap,  menuItem->GetPropertyAsBitmap( wxT("unchecked_bitmap") ) );
					#endif
				}
			}

			menuWidget->Append( item );

			if ( item->GetKind() == wxITEM_CHECK && menuItem->GetPropertyAsInteger( wxT("checked") ) )
			{
				item->Check( true );
			}

			item->Enable( ( menuItem->GetPropertyAsInteger( wxT("enabled") ) != 0 ) );
		}
	}

	return menuWidget;
}
Exemple #2
0
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 );
                }
            }
        }
    }

}
Exemple #3
0
void VisualEditor::SetupAui( PObjectBase obj, wxWindow* window )
{
    wxAuiPaneInfo info;

    // check whether the object contains AUI info...
    if( !obj->GetProperty( wxT("aui_name") ) ) return;

    wxString name = obj->GetPropertyAsString( wxT("aui_name") );
    if( name != wxT("") ) info.Name( name );

    if( obj->GetPropertyAsInteger( wxT("center_pane") )) info.CenterPane();
    if( obj->GetPropertyAsInteger( wxT("default_pane") )) info.DefaultPane();

    if( !obj->IsNull(wxT("caption"))) info.Caption(obj->GetPropertyAsString(wxT("caption")));
    info.CaptionVisible( obj->GetPropertyAsInteger( wxT("caption_visible") ) );
    info.CloseButton( obj->GetPropertyAsInteger( wxT("close_button") ) );
    info.MaximizeButton( obj->GetPropertyAsInteger( wxT("maximize_button") ) );
    info.MinimizeButton( obj->GetPropertyAsInteger( wxT("minimize_button") ) );
    info.PinButton( obj->GetPropertyAsInteger( wxT("pin_button") ) );
    info.PaneBorder( obj->GetPropertyAsInteger( wxT("pane_border") ) );
    info.Gripper(obj->GetPropertyAsInteger( wxT("gripper") ));

    info.BottomDockable( obj->GetPropertyAsInteger( wxT("BottomDockable") ) );
    info.TopDockable( obj->GetPropertyAsInteger( wxT("TopDockable") ) );
    info.LeftDockable( obj->GetPropertyAsInteger( wxT("LeftDockable") ) );
    info.RightDockable( obj->GetPropertyAsInteger( wxT("RightDockable") ) );

    if( !obj->IsNull(wxT("dock")) )
    {
        if( obj->GetPropertyAsString( wxT("dock") ) == wxT("Dock"))
        {
            info.Dock();
            if( !obj->IsNull(wxT("docking")) )
            {
                if( obj->GetPropertyAsString(wxT("docking")) == wxT("Bottom") ) info.Bottom();
                else if( obj->GetPropertyAsString(wxT("docking")) == wxT("Top") ) info.Top();
                else if( obj->GetPropertyAsString(wxT("docking")) == wxT("Center") ) info.Center();
                else if( obj->GetPropertyAsString(wxT("docking")) == wxT("Right") ) info.Right();
            }
        }
        else
        {
            info.Float();
            info.FloatingPosition( obj->GetPropertyAsPoint( wxT("pane_position") ) );
        }
    }

    if( !obj->IsNull(wxT("resize")) )
    {
        if( obj->GetPropertyAsString( wxT("resize") ) == wxT("Resizable")) info.Resizable();
        else info.Fixed();
    }

    info.DockFixed( obj->GetPropertyAsInteger( wxT("dock_fixed") ) );
    info.Movable( obj->GetPropertyAsInteger( wxT("moveable") ));
    info.Floatable(obj->GetPropertyAsInteger( wxT("floatable") ));

    if( !obj->GetProperty( wxT("pane_size" ) )->IsNull() ) info.FloatingSize( obj->GetPropertyAsSize( wxT("pane_size") ));
    if( !obj->GetProperty( wxT("best_size" ) )->IsNull() ) info.BestSize( obj->GetPropertyAsSize( wxT("best_size") ) );
    if( !obj->GetProperty( wxT("min_size" ) )->IsNull() ) info.MinSize( obj->GetPropertyAsSize( wxT("min_size") ) );
    if( !obj->GetProperty( wxT("max_size" ) )->IsNull() ) info.MaxSize( obj->GetPropertyAsSize( wxT("max_size") ) );

    if( obj->GetPropertyAsInteger( wxT("toolbar_pane") ) ) info.ToolbarPane();
    if( !obj->IsNull( wxT("aui_position") ) ) info.Position( obj->GetPropertyAsInteger( wxT("aui_position") ));
    if( !obj->IsNull( wxT("aui_row") ) ) info.Row( obj->GetPropertyAsInteger( wxT("aui_row") ));
    if( !obj->IsNull( wxT("aui_layer") ) ) info.Layer( obj->GetPropertyAsInteger( wxT("aui_layer") ));
    if( !obj->GetPropertyAsInteger( wxT("show") ) ) info.Hide();

    m_auimgr->AddPane( window, info );
}
Exemple #4
0
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;
}